All of lore.kernel.org
 help / color / mirror / Atom feed
* Does ICMP_FRAG_NEEDED automatically update the routing cache?
@ 2014-02-14 14:36 David Howells
  2014-02-14 14:44 ` Hannes Frederic Sowa
  2014-02-14 15:00 ` David Howells
  0 siblings, 2 replies; 11+ messages in thread
From: David Howells @ 2014-02-14 14:36 UTC (permalink / raw)
  To: netdev; +Cc: dhowells


Am I reading the ipv4 code right?  If a UDP packet we send results in an
ICMP_FRAG_NEEDED packet being received, the cached routing information for the
peer will automatically be updated by __udp4_lib_err()?

And something similar in __udp6_lib_err()?

David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Does ICMP_FRAG_NEEDED automatically update the routing cache?
  2014-02-14 14:36 Does ICMP_FRAG_NEEDED automatically update the routing cache? David Howells
@ 2014-02-14 14:44 ` Hannes Frederic Sowa
  2014-02-14 15:00 ` David Howells
  1 sibling, 0 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-02-14 14:44 UTC (permalink / raw)
  To: David Howells; +Cc: netdev

Hi!

On Fri, Feb 14, 2014 at 02:36:48PM +0000, David Howells wrote:
> Am I reading the ipv4 code right?  If a UDP packet we send results in an
> ICMP_FRAG_NEEDED packet being received, the cached routing information for the
> peer will automatically be updated by __udp4_lib_err()?

A next hop exception will be generated (or reused) which stores the path
mtu towards that target, yes (there is no more routing cache).

Prior to that a validation check happens if the socket really exists (this is
e.g. needed to identify the namespace or routing table the update should occur
on).

> And something similar in __udp6_lib_err()?

Exactly.

Greetings,

  Hannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Does ICMP_FRAG_NEEDED automatically update the routing cache?
  2014-02-14 14:36 Does ICMP_FRAG_NEEDED automatically update the routing cache? David Howells
  2014-02-14 14:44 ` Hannes Frederic Sowa
@ 2014-02-14 15:00 ` David Howells
  2014-02-14 15:03   ` Hannes Frederic Sowa
                     ` (2 more replies)
  1 sibling, 3 replies; 11+ messages in thread
From: David Howells @ 2014-02-14 15:00 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: dhowells, netdev

Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:

> On Fri, Feb 14, 2014 at 02:36:48PM +0000, David Howells wrote:
> > Am I reading the ipv4 code right?  If a UDP packet we send results in an
> > ICMP_FRAG_NEEDED packet being received, the cached routing information for
> > the peer will automatically be updated by __udp4_lib_err()?
> 
> A next hop exception will be generated (or reused) which stores the path
> mtu towards that target, yes (there is no more routing cache).
> 
> Prior to that a validation check happens if the socket really exists (this is
> e.g. needed to identify the namespace or routing table the update should occur
> on).

Sounds good.  Does this work even if the socket is not connected (ie. the UDP
packets are being routed by the address fields in struct msghdr)?

David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Does ICMP_FRAG_NEEDED automatically update the routing cache?
  2014-02-14 15:00 ` David Howells
@ 2014-02-14 15:03   ` Hannes Frederic Sowa
  2014-02-14 15:42   ` David Howells
  2014-02-14 15:49   ` Getting a NIC's MTU size David Howells
  2 siblings, 0 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-02-14 15:03 UTC (permalink / raw)
  To: David Howells; +Cc: netdev

On Fri, Feb 14, 2014 at 03:00:42PM +0000, David Howells wrote:
> Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:
> 
> > On Fri, Feb 14, 2014 at 02:36:48PM +0000, David Howells wrote:
> > > Am I reading the ipv4 code right?  If a UDP packet we send results in an
> > > ICMP_FRAG_NEEDED packet being received, the cached routing information for
> > > the peer will automatically be updated by __udp4_lib_err()?
> > 
> > A next hop exception will be generated (or reused) which stores the path
> > mtu towards that target, yes (there is no more routing cache).
> > 
> > Prior to that a validation check happens if the socket really exists (this is
> > e.g. needed to identify the namespace or routing table the update should occur
> > on).
> 
> Sounds good.  Does this work even if the socket is not connected (ie. the UDP
> packets are being routed by the address fields in struct msghdr)?

Yes, but connected sockets are checked prior to unconnected sockets, so the
most specific one wins.

For unconnected ones only the local ip/port is checked because kernel
does not know the past destination addresses.

Greetings,

  Hannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Does ICMP_FRAG_NEEDED automatically update the routing cache?
  2014-02-14 15:00 ` David Howells
  2014-02-14 15:03   ` Hannes Frederic Sowa
@ 2014-02-14 15:42   ` David Howells
  2014-02-14 15:49   ` Getting a NIC's MTU size David Howells
  2 siblings, 0 replies; 11+ messages in thread
From: David Howells @ 2014-02-14 15:42 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: dhowells, netdev

Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:

> Yes, but connected sockets are checked prior to unconnected sockets, so the
> most specific one wins.
> 
> For unconnected ones only the local ip/port is checked because kernel
> does not know the past destination addresses.

Okay, thanks!

David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Getting a NIC's MTU size
  2014-02-14 15:00 ` David Howells
  2014-02-14 15:03   ` Hannes Frederic Sowa
  2014-02-14 15:42   ` David Howells
@ 2014-02-14 15:49   ` David Howells
  2014-02-14 16:52     ` Hannes Frederic Sowa
                       ` (2 more replies)
  2 siblings, 3 replies; 11+ messages in thread
From: David Howells @ 2014-02-14 15:49 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: dhowells, netdev


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?

David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Getting a NIC's MTU size
  2014-02-14 15:49   ` Getting a NIC's MTU size David Howells
@ 2014-02-14 16:52     ` Hannes Frederic Sowa
  2014-02-17  5:21     ` David Miller
  2014-02-20 17:30     ` David Howells
  2 siblings, 0 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-02-14 16:52 UTC (permalink / raw)
  To: David Howells; +Cc: netdev

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Getting a NIC's MTU size
  2014-02-14 15:49   ` Getting a NIC's MTU size David Howells
  2014-02-14 16:52     ` Hannes Frederic Sowa
@ 2014-02-17  5:21     ` David Miller
  2014-02-20 17:30     ` David Howells
  2 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2014-02-17  5:21 UTC (permalink / raw)
  To: dhowells; +Cc: hannes, netdev

From: David Howells <dhowells@redhat.com>
Date: Fri, 14 Feb 2014 15:49:17 +0000

> 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:

As has been suggested or at least hinted to by others, you have to use
the route dst's device pointer.

Practically speaking, this means you'll have to cache the route, just
like we do in ipv4 sockets.  And on each packet send 1) validate the
route and relookup if it's become obsolute 2) dereference the dst->dev
to get the mtu.

This is because routes can change dynamically as can the physical
device's MTU setting, you'll therefore have to evaluate everything
on every packet send.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Getting a NIC's MTU size
  2014-02-14 15:49   ` Getting a NIC's MTU size David Howells
  2014-02-14 16:52     ` Hannes Frederic Sowa
  2014-02-17  5:21     ` David Miller
@ 2014-02-20 17:30     ` David Howells
  2014-02-20 18:12       ` Hannes Frederic Sowa
  2014-02-20 18:45       ` David Miller
  2 siblings, 2 replies; 11+ messages in thread
From: David Howells @ 2014-02-20 17:30 UTC (permalink / raw)
  To: David Miller; +Cc: dhowells, hannes, netdev

David Miller <davem@davemloft.net> 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:
> 
> As has been suggested or at least hinted to by others, you have to use
> the route dst's device pointer.

So I gather.  My query was intended to be about the safety of accessing the
dst->dev pointer.  Can I just dereference it?  Or do I need to take a lock or
use RCU?

David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Getting a NIC's MTU size
  2014-02-20 17:30     ` David Howells
@ 2014-02-20 18:12       ` Hannes Frederic Sowa
  2014-02-20 18:45       ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-02-20 18:12 UTC (permalink / raw)
  To: David Howells; +Cc: David Miller, netdev

On Thu, Feb 20, 2014 at 05:30:23PM +0000, David Howells wrote:
> David Miller <davem@davemloft.net> 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:
> > 
> > As has been suggested or at least hinted to by others, you have to use
> > the route dst's device pointer.
> 
> So I gather.  My query was intended to be about the safety of accessing the
> dst->dev pointer.  Can I just dereference it?  Or do I need to take a lock or
> use RCU?

No, you can just dereference it. dst holds a reference on ->dev, so it
is safe without lock or rcu as long as dst is alive and referenced.

Greetings,

  Hannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Getting a NIC's MTU size
  2014-02-20 17:30     ` David Howells
  2014-02-20 18:12       ` Hannes Frederic Sowa
@ 2014-02-20 18:45       ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2014-02-20 18:45 UTC (permalink / raw)
  To: dhowells; +Cc: hannes, netdev

From: David Howells <dhowells@redhat.com>
Date: Thu, 20 Feb 2014 17:30:23 +0000

> David Miller <davem@davemloft.net> 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:
>> 
>> As has been suggested or at least hinted to by others, you have to use
>> the route dst's device pointer.
> 
> So I gather.  My query was intended to be about the safety of accessing the
> dst->dev pointer.  Can I just dereference it?  Or do I need to take a lock or
> use RCU?

If the dst is valid and you have a reference to it, dst->dev is good.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-02-20 18:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14 14:36 Does ICMP_FRAG_NEEDED automatically update the routing cache? David Howells
2014-02-14 14:44 ` Hannes Frederic Sowa
2014-02-14 15:00 ` David Howells
2014-02-14 15:03   ` Hannes Frederic Sowa
2014-02-14 15:42   ` David Howells
2014-02-14 15:49   ` Getting a NIC's MTU size David Howells
2014-02-14 16:52     ` Hannes Frederic Sowa
2014-02-17  5:21     ` David Miller
2014-02-20 17:30     ` David Howells
2014-02-20 18:12       ` Hannes Frederic Sowa
2014-02-20 18:45       ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.