Skip to contentSkip to conversation

IPv4: RTM_GETROUTE: Add RTA_ENCAP to result

PATCH Applied Oliver Herms 3 participants 3 messages Nov 13, 2020 – Nov 15, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 IPv4: RTM_GETROUTE: Add RTA_ENCAP to result

This patch adds an IPv4 routes encapsulation attribute to the result of netlink RTM_GETROUTE requests (e.g. ip route get 192.0.2.1).

---
 net/ipv4/route.c | 3 +++
 1 file changed, 3 insertions(+)
net/ipv4/route.c +3 -0
index 1d7076b78e63..0fbb4adee3d4 100644
@@ -2860,6 +2860,9 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
 	if (rt->dst.dev &&
 	    nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex))
 		goto nla_put_failure;
+	if (rt->dst.lwtstate &&
+	    lwtunnel_fill_encap(skb, rt->dst.lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
+		goto nla_put_failure;
 #ifdef CONFIG_IP_ROUTE_CLASSID
 	if (rt->dst.tclassid &&
 	    nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid))
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 15 lines · Oliver Herms

This patch adds an IPv4 routes encapsulation attribute to the result of netlink RTM_GETROUTE requests (e.g. ip route get 192.0.2.1).

---
 net/ipv4/route.c | 3 +++
 1 file changed, 3 insertions(+)
net/ipv4/route.c +0 -0
index 1d7076b78e63..0fbb4adee3d4 100644

net/ipv4/route.c static int rt_fill_info(struct net *net, __be32 dst, __be32 src, · line 2868

Quoted 9 lines
net/ipv4/route.c +3 -0
@@ -2860,6 +2860,9 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
 	if (rt->dst.dev &&
 	    nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex))
 		goto nla_put_failure;
+	if (rt->dst.lwtstate &&
+	    lwtunnel_fill_encap(skb, rt->dst.lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
+		goto nla_put_failure;
 #ifdef CONFIG_IP_ROUTE_CLASSID
 	if (rt->dst.tclassid &&
 	    nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid))