Re: Getting a NIC's MTU size
From: Hannes Frederic Sowa <hidden>
Date: 2014-02-14 16:52:23
On Fri, Feb 14, 2014 at 03:49:17PM +0000, David Howells wrote:
One further question: If I want to get the MTU size of the NIC through which packets will go to get to a particular peer, can I do: struct rtable *rt; struct flowi4 fl4; unsigned if_mtu; rt = ip_route_output_ports(&init_net, &fl4, NULL, peer->srx.transport.sin.sin_addr.s_addr, 0, htons(7000), htons(7001), IPPROTO_UDP, 0, 0); if_mtu = rt->dst->dev->mtu; dst_release(&rt->dst); Or might this go wrong if rt->dst->dev changes under me? Can it change without replacing the dst record?
If it is a one-shot query this is fine. If you store the dst somewhere you need to check dst->obsolete flags and redo the lookup if it is > 0. ->dev pointer won't change for a created dst. Bye, Hannes