Skip to contentSkip to conversation

IPv6: RTM_GETROUTE: Add RTA_ENCAP to result

PATCH Superseded Oliver Herms 2 participants 3 messages Nov 18, 2020

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 IPv6: RTM_GETROUTE: Add RTA_ENCAP to result

This patch adds an IPv6 routes encapsulation attribute to the result of netlink RTM_GETROUTE requests (i.e. ip route get 2001:db8::).

---
 net/ipv6/route.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv6/route.c +4 -0
index 7e0ce7af8234..64bda402357b 100644
@@ -5558,6 +5558,10 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
 
 		if (dst->dev && nla_put_u32(skb, RTA_OIF, dst->dev->ifindex))
 			goto nla_put_failure;
+
+		if (dst && dst->lwtstate &&
+		    lwtunnel_fill_encap(skb, dst->lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
+			goto nla_put_failure;
 	} else if (rt->fib6_nsiblings) {
 		struct fib6_info *sibling, *next_sibling;
 		struct nlattr *mp;
Signature · 1 line
2.25.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 15 lines · Oliver Herms

This patch adds an IPv6 routes encapsulation attribute to the result of netlink RTM_GETROUTE requests (i.e. ip route get 2001:db8::).

---
 net/ipv6/route.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv6/route.c +0 -0
index 7e0ce7af8234..64bda402357b 100644

net/ipv6/route.c static int rt6_fill_node(struct net *net, struct sk_buff *skb, · line 5567

Quoted 10 lines
net/ipv6/route.c +4 -0
@@ -5558,6 +5558,10 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
 
 		if (dst->dev && nla_put_u32(skb, RTA_OIF, dst->dev->ifindex))
 			goto nla_put_failure;
+
+		if (dst && dst->lwtstate &&
+		    lwtunnel_fill_encap(skb, dst->lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
+			goto nla_put_failure;
 	} else if (rt->fib6_nsiblings) {
 		struct fib6_info *sibling, *next_sibling;
 		struct nlattr *mp;

You forgot to remove the dst part of that. rt6 == dst so to be in this branch dst != NULL.

Besides that nit that maybe Jakub will fixup before applying:

#2 lore raw
Quoted 3 lines · David Ahern

You forgot to remove the dst part of that. rt6 == dst so to be in this branch dst != NULL.

Damn. I've indeed overseen that one.
Just submitted version 4.

Thanks for guiding me through this!