Does ICMP_FRAG_NEEDED automatically update the routing cache?
Subsystems (2)
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
Hi!
Quoted 3 lines · David Howells
Am I reading the ipv4 code right? If a UDP packet we send results in an
ICMP_FRAG_NEEDEDpacket 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).
Quoted 1 line
And something similar in
__udp6_lib_err()?
Exactly.
Greetings,
Hannes
Quoted 11 lines · Hannes Frederic Sowa
Quoted 3 lines · David Howells
Am I reading the ipv4 code right? If a UDP packet we send results in an
ICMP_FRAG_NEEDEDpacket 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
Quoted 10 lines · David Howells
Quoted 8 lines · Hannes Frederic Sowa
Quoted 3 lines · David Howells
Am I reading the ipv4 code right? If a UDP packet we send results in an
ICMP_FRAG_NEEDEDpacket 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).
Quoted 6 lines
Quoted 3 lines
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
Quoted 5 lines · Hannes Frederic Sowa
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
Getting a NIC's MTU size
In reply to Hannes Frederic SowaOne 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
Re: Getting a NIC's MTU size
Quoted 17 lines · David Howells
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);
Quoted 2 lines
Or might this go wrong if
rt->dst->devchanges 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
David Miller
maintainerRe: Getting a NIC's MTU size
In reply to David HowellsFrom: David Howells <[email protected]>
Date: Fri, 14 Feb 2014 15:49:17 +0000
Quoted 2 lines
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.
Re: Getting a NIC's MTU size
Quoted 5 lines · David Miller
Quoted 2 lines
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
Re: Getting a NIC's MTU size
Quoted 11 lines · David Howells
Quoted 5 lines · David Miller
Quoted 2 lines
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->devpointer. 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
David Miller
maintainerRe: Getting a NIC's MTU size
In reply to David HowellsFrom: David Howells <[email protected]>
Date: Thu, 20 Feb 2014 17:30:23 +0000
Quoted 11 lines
Quoted 5 lines · David Miller
Quoted 2 lines
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->devpointer. 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.