浏览代码

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.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
David Ahern 10 年之前
父节点
当前提交
4ec3b28c27
共有 2 个文件被更改,包括 10 次插入4 次删除
  1. 5 2
      net/ipv4/xfrm4_policy.c
  2. 5 2
      net/ipv6/xfrm6_policy.c

+ 5 - 2
net/ipv4/xfrm4_policy.c

@@ -15,6 +15,7 @@
 #include <net/dst.h>
 #include <net/dst.h>
 #include <net/xfrm.h>
 #include <net/xfrm.h>
 #include <net/ip.h>
 #include <net/ip.h>
+#include <net/vrf.h>
 
 
 static struct xfrm_policy_afinfo xfrm4_policy_afinfo;
 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;
 	struct flowi4 *fl4 = &fl->u.ip4;
 	int oif = 0;
 	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));
 	memset(fl4, 0, sizeof(struct flowi4));
 	fl4->flowi4_mark = skb->mark;
 	fl4->flowi4_mark = skb->mark;

+ 5 - 2
net/ipv6/xfrm6_policy.c

@@ -20,6 +20,7 @@
 #include <net/ip.h>
 #include <net/ip.h>
 #include <net/ipv6.h>
 #include <net/ipv6.h>
 #include <net/ip6_route.h>
 #include <net/ip6_route.h>
+#include <net/vrf.h>
 #if IS_ENABLED(CONFIG_IPV6_MIP6)
 #if IS_ENABLED(CONFIG_IPV6_MIP6)
 #include <net/mip6.h>
 #include <net/mip6.h>
 #endif
 #endif
@@ -131,8 +132,10 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
 
 
 	nexthdr = nh[nhoff];
 	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));
 	memset(fl6, 0, sizeof(struct flowi6));
 	fl6->flowi6_mark = skb->mark;
 	fl6->flowi6_mark = skb->mark;