[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140214165222.GC27343@order.stressinduktion.org>
Date: Fri, 14 Feb 2014 17:52:22 +0100
From: Hannes Frederic Sowa <hannes@...essinduktion.org>
To: David Howells <dhowells@...hat.com>
Cc: netdev@...r.kernel.org
Subject: Re: Getting a NIC's MTU size
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists