Thread (6 messages) 6 messages, 2 authors, 2021-12-03

Re: [[PATCH net-next v3] 3/3] udp6: Use Segment Routing Header for dest address if present

flat view

From: David Ahern <hidden>
Date: 2021-12-03 16:51:08

On 12/3/21 9:29 AM, Andrew Lunn wrote:
quoted hunk ↗ jump to hunk
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index 73aaabf0e966..4fd7d3793c1b 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -134,6 +134,27 @@ void seg6_icmp_srh(struct sk_buff *skb, struct inet6_skb_parm *opt)
 	skb->network_header = network_header;
 }
 
+/* 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.
+ */
+const struct in6_addr *seg6_get_daddr(struct sk_buff *skb,
+				      struct inet6_skb_parm *opt)
+{
+	/* ipv6_hdr() does not work here, since this IP header is
+	 * nested inside an ICMP error report packet
+	 */
+	const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;
+	struct ipv6_sr_hdr *srh;
+
+	if (opt->flags & IP6SKB_SEG6) {
+		srh = (struct ipv6_sr_hdr *)(skb->data + opt->srhoff);
+		return  &srh->segments[0];
+	}
+
+	return &hdr->daddr;
+}
+
also, that could be an inline in net/seg6.h given how short it is.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help