Skip to contentSkip to conversation

xfrm: Use VRF master index if output device is enslaved

PATCH In review David Ahern 4 participants 4 messages Aug 20, 2015 – Aug 25, 2015

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

PATCH v2 1/1 xfrm: Use VRF master index if output device is enslaved

Directs route lookups to VRF table. Compiles out if NET_VRF is not enabled. With this patch able to successfully bring up ipsec tunnels in VRFs, even with duplicate network configuration.

---
v2
- use vrf_master_ifindex rather than vrf_master_ifindex_rcu

 net/ipv4/xfrm4_policy.c | 7 +++++--
 net/ipv6/xfrm6_policy.c | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)
net/ipv4/xfrm4_policy.c +5 -2
index 55b3c0f4dde5..35757f6af2d5 100644
@@ -15,6 +15,7 @@
 #include <net/dst.h>
 #include <net/xfrm.h>
 #include <net/ip.h>
+#include <net/vrf.h>
 
 static struct xfrm_policy_afinfo xfrm4_policy_afinfo;
 
@@ -107,8 +108,10 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
 	struct flowi4 *fl4 = &fl->u.ip4;
 	int oif = 0;
 
-	if (skb_dst(skb))
-		oif = skb_dst(skb)->dev->ifindex;
+	if (skb_dst(skb)) {
+		oif = vrf_master_ifindex(skb_dst(skb)->dev) ?
+			: skb_dst(skb)->dev->ifindex;
+	}
 
 	memset(fl4, 0, sizeof(struct flowi4));
 	fl4->flowi4_mark = skb->mark;
net/ipv6/xfrm6_policy.c +5 -2
index a74013d3eceb..4a88b89becf5 100644
@@ -20,6 +20,7 @@
 #include <net/ip.h>
 #include <net/ipv6.h>
 #include <net/ip6_route.h>
+#include <net/vrf.h>
 #if IS_ENABLED(CONFIG_IPV6_MIP6)
 #include <net/mip6.h>
 #endif
@@ -131,8 +132,10 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
 
 	nexthdr = nh[nhoff];
 
-	if (skb_dst(skb))
-		oif = skb_dst(skb)->dev->ifindex;
+	if (skb_dst(skb)) {
+		oif = vrf_master_ifindex(skb_dst(skb)->dev) ?
+			: skb_dst(skb)->dev->ifindex;
+	}
 
 	memset(fl6, 0, sizeof(struct flowi6));
 	fl6->flowi6_mark = skb->mark;
Signature · 1 line
2.3.2 (Apple Git-55)
Acked-by on v2 1/1
#1 lore raw
Quoted 7 lines · David Ahern

Directs route lookups to VRF table. Compiles out if NET_VRF is not enabled. With this patch able to successfully bring up ipsec tunnels in VRFs, even with duplicate network configuration.

Quoted 9 lines

---
v2
- use vrf_master_ifindex rather than vrf_master_ifindex_rcu

net/ipv4/xfrm4_policy.c | 7 +++++--
net/ipv6/xfrm6_policy.c | 7 +++++--

2 files changed, 10 insertions(+), 4 deletions(-)

Looks good to me,

maintainer Acked-by
#2 lore raw
Quoted 12 lines · Nikolay Aleksandrov
Quoted 12 lines · David Ahern

Directs route lookups to VRF table. Compiles out if NET_VRF is not enabled. With this patch able to successfully bring up ipsec tunnels in VRFs, even with duplicate network configuration.

---
v2
- use vrf_master_ifindex rather than vrf_master_ifindex_rcu

Quoted 8 lines
Quoted 4 lines

net/ipv4/xfrm4_policy.c | 7 +++++--
net/ipv6/xfrm6_policy.c | 7 +++++--

2 files changed, 10 insertions(+), 4 deletions(-)

Looks good to me,

David, can you please take this directly into net-next?

maintainer
#3 lore raw

From: Steffen Klassert <[email protected]>
Date: Fri, 21 Aug 2015 22:31:32 +0200

Quoted 18 lines · Nikolay Aleksandrov
Quoted 17 lines
Quoted 16 lines · David Ahern

Directs route lookups to VRF table. Compiles out if NET_VRF is not enabled. With this patch able to successfully bring up ipsec tunnels in VRFs, even with duplicate network configuration.

---
v2
- use vrf_master_ifindex rather than vrf_master_ifindex_rcu

net/ipv4/xfrm4_policy.c | 7 +++++--
net/ipv6/xfrm6_policy.c | 7 +++++--

2 files changed, 10 insertions(+), 4 deletions(-)
Quoted 7 lines
Quoted 3 lines

Looks good to me,

David, can you please take this directly into net-next?

Ok, done, thanks.