diff options
author | Andrew Lunn <andrew@lunn.ch> | 2022-01-03 18:11:32 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-01-04 13:17:35 +0100 |
commit | 222a011efc839ca1f51bf89fe7a2b3705fa55ccd (patch) | |
tree | af54a38b1570fc9bbade6c094f7b12d4151c86cb /include/net/seg6.h | |
parent | icmp: ICMPV6: Examine invoking packet for Segment Route Headers. (diff) | |
download | linux-222a011efc839ca1f51bf89fe7a2b3705fa55ccd.tar.xz linux-222a011efc839ca1f51bf89fe7a2b3705fa55ccd.zip |
udp6: Use Segment Routing Header for dest address if present
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>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/seg6.h')
-rw-r--r-- | include/net/seg6.h | 19 |
1 files changed, 19 insertions, 0 deletions
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 |