Message ID | 20220103171132.93456-4-andrew@lunn.ch (mailing list archive) |
---|---|
State | Accepted |
Commit | 222a011efc839ca1f51bf89fe7a2b3705fa55ccd |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Fix traceroute in the presence of SRv6 | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 31 this patch: 31 |
netdev/cc_maintainers | success | CCed 5 of 5 maintainers |
netdev/build_clang | success | Errors and warnings before: 20 this patch: 20 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 33 this patch: 33 |
netdev/checkpatch | warning | CHECK: Please don't use multiple blank lines |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On 1/3/22 10:11 AM, Andrew Lunn wrote: > When finding the socket to report an error on, if the invoking packet > is using Segment Routing, the IPv6 destination address is that of an > intermediate router, not the end destination. Extract the ultimate > destination address from the segment address. > > This change allows traceroute to function in the presence of Segment > Routing. > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > --- > include/net/seg6.h | 19 +++++++++++++++++++ > net/ipv6/udp.c | 3 ++- > 2 files changed, 21 insertions(+), 1 deletion(-) > Reviewed-by: David Ahern <dsahern@kernel.org>
On Mon, Jan 3, 2022 at 12:35 PM David Ahern <dsahern@gmail.com> wrote: > > On 1/3/22 10:11 AM, Andrew Lunn wrote: > > When finding the socket to report an error on, if the invoking packet > > is using Segment Routing, the IPv6 destination address is that of an > > intermediate router, not the end destination. Extract the ultimate > > destination address from the segment address. > > > > This change allows traceroute to function in the presence of Segment > > Routing. > > > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > > --- > > include/net/seg6.h | 19 +++++++++++++++++++ > > net/ipv6/udp.c | 3 ++- > > 2 files changed, 21 insertions(+), 1 deletion(-) > > > > Reviewed-by: David Ahern <dsahern@kernel.org> > Reviewed-by: Willem de Bruijn <willemb@google.com>
diff --git a/include/net/seg6.h b/include/net/seg6.h index 02b0cd305787..af668f17b398 100644 --- a/include/net/seg6.h +++ b/include/net/seg6.h @@ -65,4 +65,23 @@ extern int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, extern int seg6_do_srh_inline(struct sk_buff *skb, struct ipv6_sr_hdr *osrh); extern int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr, u32 tbl_id); + +/* If the packet which invoked an ICMP error contains an SRH return + * the true destination address from within the SRH, otherwise use the + * destination address in the IP header. + */ +static inline const struct in6_addr *seg6_get_daddr(struct sk_buff *skb, + struct inet6_skb_parm *opt) +{ + struct ipv6_sr_hdr *srh; + + if (opt->flags & IP6SKB_SEG6) { + srh = (struct ipv6_sr_hdr *)(skb->data + opt->srhoff); + return &srh->segments[0]; + } + + return NULL; +} + + #endif diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 1accc06abc54..df216268cb02 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -41,6 +41,7 @@ #include <net/transp_v6.h> #include <net/ip6_route.h> #include <net/raw.h> +#include <net/seg6.h> #include <net/tcp_states.h> #include <net/ip6_checksum.h> #include <net/ip6_tunnel.h> @@ -562,7 +563,7 @@ int __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt, struct ipv6_pinfo *np; const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data; const struct in6_addr *saddr = &hdr->saddr; - const struct in6_addr *daddr = &hdr->daddr; + const struct in6_addr *daddr = seg6_get_daddr(skb, opt) ? : &hdr->daddr; struct udphdr *uh = (struct udphdr *)(skb->data+offset); bool tunnel = false; struct sock *sk;
When finding the socket to report an error on, if the invoking packet is using Segment Routing, the IPv6 destination address is that of an intermediate router, not the end destination. Extract the ultimate destination address from the segment address. This change allows traceroute to function in the presence of Segment Routing. Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- include/net/seg6.h | 19 +++++++++++++++++++ net/ipv6/udp.c | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-)