All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] vrf: local route leaking
@ 2019-05-24  8:05 George Wilkie
  2019-05-24 20:19 ` David Ahern
  0 siblings, 1 reply; 10+ messages in thread
From: George Wilkie @ 2019-05-24  8:05 UTC (permalink / raw)
  To: David Ahern, Shrijeet Mukherjee, David S. Miller,
	Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: netdev

If have an interface in vrf A:

  10.10.2.0/24 dev ens9 proto kernel scope link src 10.10.2.2
  local 10.10.2.2 dev ens9 proto kernel scope host src 10.10.2.2

and want to leak it into vrf B, it is not sufficient to leak just
the interface route:

  ip route add 10.10.2.0/24 vrf B dev ens9

as traffic arriving into vrf B that is destined for 10.10.2.2 will
not arrive - it will be sent to the ens9 interface and nobody will
respond to the ARP.

In order to handle the traffic locally, the local route must also
be leaked to vrf B:

  ip route add local 10.10.2.2 vrf B dev ens9

However, that still doesn't work as the traffic is processed in
the context of the input vrf B and does not find a socket that is
bound to the destination vrf A.

Add a new vector to l3mdev_ops for receiving a local packet.
This checks if the local interface is enslaved to a different vrf
than the input interface, and if so, updates the skb so that it
will be handled by a socket in the vrf associated with the local
interface.
For ipv4, the local interface is obtained from the fib result in
the RTN_LOCAL route lookup path.
For ipv6, the local interface is obtained from the skb_dst in
ip6_input.

Signed-off-by: George Wilkie <gwilkie@vyatta.att-mail.com>
---
 drivers/net/vrf.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
 include/net/l3mdev.h | 41 +++++++++++++++++++++++++++++++++++++++++
 net/ipv4/route.c     |  2 ++
 net/ipv6/ip6_input.c |  1 +
 4 files changed, 87 insertions(+)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index cf7e6a92e73c..719e10f7761b 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -1106,6 +1106,48 @@ static struct dst_entry *vrf_link_scope_lookup(const struct net_device *dev,
 }
 #endif
 
+static void vrf_ip6_local_rcv(struct net_device *vrf_dev, struct sk_buff *skb)
+{
+#if IS_ENABLED(CONFIG_IPV6)
+	if (vrf_dev) {
+		skb->dev = vrf_dev;
+		skb->skb_iif = vrf_dev->ifindex;
+		IP6CB(skb)->flags |= IP6SKB_L3SLAVE;
+		vrf_rx_stats(vrf_dev, skb->len);
+	} else {
+		/* Moving from VRF to global */
+		IP6CB(skb)->flags &= ~IP6SKB_L3SLAVE;
+	}
+#endif
+}
+
+static void vrf_ip_local_rcv(struct net_device *vrf_dev, struct sk_buff *skb)
+{
+	if (vrf_dev) {
+		skb->dev = vrf_dev;
+		skb->skb_iif = vrf_dev->ifindex;
+		IPCB(skb)->flags |= IPSKB_L3SLAVE;
+		vrf_rx_stats(vrf_dev, skb->len);
+	} else {
+		/* Moving from VRF to global */
+		IPCB(skb)->flags &= ~IPSKB_L3SLAVE;
+	}
+}
+
+/* called with rcu lock held */
+static void vrf_local_rcv(struct net_device *vrf_dev, struct sk_buff *skb,
+			  u16 proto)
+{
+	switch (proto) {
+	case AF_INET:
+		vrf_ip_local_rcv(vrf_dev, skb);
+		break;
+	case AF_INET6:
+		vrf_ip6_local_rcv(vrf_dev, skb);
+		break;
+	}
+}
+
 static const struct l3mdev_ops vrf_l3mdev_ops = {
 	.l3mdev_fib_table	= vrf_fib_table,
 	.l3mdev_l3_rcv		= vrf_l3_rcv,
@@ -1113,6 +1155,7 @@ static const struct l3mdev_ops vrf_l3mdev_ops = {
 #if IS_ENABLED(CONFIG_IPV6)
 	.l3mdev_link_scope_lookup = vrf_link_scope_lookup,
 #endif
+	.l3mdev_local_rcv	= vrf_local_rcv,
 };
 
 static void vrf_get_drvinfo(struct net_device *dev,
diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h
index 5175fd63cd82..d1008437a769 100644
--- a/include/net/l3mdev.h
+++ b/include/net/l3mdev.h
@@ -24,6 +24,8 @@
  * @l3mdev_l3_out:    Hook in L3 output path
  *
  * @l3mdev_link_scope_lookup: IPv6 lookup for linklocal and mcast destinations
+ *
+ * @l3mdev_local_rcv: Hook in local receive path
  */
 
 struct l3mdev_ops {
@@ -37,6 +39,8 @@ struct l3mdev_ops {
 	/* IPv6 ops */
 	struct dst_entry * (*l3mdev_link_scope_lookup)(const struct net_device *dev,
 						 struct flowi6 *fl6);
+	void (*l3mdev_local_rcv)(struct net_device *dev, struct sk_buff *skb,
+				 u16 proto);
 };
 
 #ifdef CONFIG_NET_L3_MASTER_DEV
@@ -203,6 +207,35 @@ struct sk_buff *l3mdev_ip6_out(struct sock *sk, struct sk_buff *skb)
 {
 	return l3mdev_l3_out(sk, skb, AF_INET6);
 }
+
+static inline
+void l3mdev_local_rcv(struct net_device *dev, struct sk_buff *skb, u16 proto)
+{
+	struct net_device *l3mdev1 = l3mdev_master_dev_rcu(skb->dev);
+	struct net_device *l3mdev2 = l3mdev_master_dev_rcu(dev);
+
+	/* local device enslaved to a different L3 master from input device */
+	if (l3mdev1 != l3mdev2) {
+		if (l3mdev1 && l3mdev1->l3mdev_ops->l3mdev_local_rcv)
+			l3mdev1->l3mdev_ops->l3mdev_local_rcv(l3mdev2, skb,
+							      proto);
+		else if (l3mdev2 && l3mdev2->l3mdev_ops->l3mdev_local_rcv)
+			l3mdev2->l3mdev_ops->l3mdev_local_rcv(l3mdev2, skb,
+							      proto);
+	}
+}
+
+static inline
+void l3mdev_ip_local_rcv(struct net_device *dev, struct sk_buff *skb)
+{
+	return l3mdev_local_rcv(dev, skb, AF_INET);
+}
+
+static inline
+void l3mdev_ip6_local_rcv(struct net_device *dev, struct sk_buff *skb)
+{
+	return l3mdev_local_rcv(dev, skb, AF_INET6);
+}
 #else
 
 static inline int l3mdev_master_ifindex_rcu(const struct net_device *dev)
@@ -294,6 +327,14 @@ static inline
 void l3mdev_update_flow(struct net *net, struct flowi *fl)
 {
 }
+static inline
+void l3mdev_ip_local_rcv(struct net_device *fib_dev, struct sk_buff *skb)
+{
+}
+static inline
+void l3mdev_ip6_local_rcv(struct net_device *fib_dev, struct sk_buff *skb)
+{
+}
 #endif
 
 #endif /* _NET_L3MDEV_H_ */
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 11ddc276776e..c91b8ab06b86 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2070,6 +2070,8 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 					  0, dev, in_dev, &itag);
 		if (err < 0)
 			goto martian_source;
+
+		l3mdev_ip_local_rcv(res->fi->fib_dev, skb);
 		goto local_input;
 	}
 
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index b50b1af1f530..4def37f73363 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -448,6 +448,7 @@ static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *sk
 
 int ip6_input(struct sk_buff *skb)
 {
+	l3mdev_ip6_local_rcv(skb_dst(skb)->dev, skb);
 	return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN,
 		       dev_net(skb->dev), NULL, skb, skb->dev, NULL,
 		       ip6_input_finish);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next] vrf: local route leaking
  2019-05-24  8:05 [PATCH net-next] vrf: local route leaking George Wilkie
@ 2019-05-24 20:19 ` David Ahern
  2019-05-25  7:09   ` George Wilkie
  0 siblings, 1 reply; 10+ messages in thread
From: David Ahern @ 2019-05-24 20:19 UTC (permalink / raw)
  To: George Wilkie, Shrijeet Mukherjee, David S. Miller,
	Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: netdev

On 5/24/19 2:05 AM, George Wilkie wrote:
> If have an interface in vrf A:
> 
>   10.10.2.0/24 dev ens9 proto kernel scope link src 10.10.2.2
>   local 10.10.2.2 dev ens9 proto kernel scope host src 10.10.2.2
> 
> and want to leak it into vrf B, it is not sufficient to leak just
> the interface route:
> 
>   ip route add 10.10.2.0/24 vrf B dev ens9
> 
> as traffic arriving into vrf B that is destined for 10.10.2.2 will
> not arrive - it will be sent to the ens9 interface and nobody will
> respond to the ARP.
> 
> In order to handle the traffic locally, the local route must also
> be leaked to vrf B:
> 
>   ip route add local 10.10.2.2 vrf B dev ens9
> 
> However, that still doesn't work as the traffic is processed in
> the context of the input vrf B and does not find a socket that is
> bound to the destination vrf A.

I presume you mean traffic arrives on another interface assigned to VRF
B with the final destination being the local address of ens9 in VRF-A.


I think this codifies the use case:
  ip li add vrf-a up type vrf table 1
  ip route add vrf vrf-a unreachable default
  ip li add vrf-b up type vrf table 2
  ip route add vrf vrf-b unreachable default
  ip ru add pref 32765 from all lookup local
  ip ru del pref 0

  ip netns add foo
  ip li add veth1 type veth peer name veth11 netns foo
  ip addr add dev veth1 10.1.1.1/24
  ip li set veth1 vrf vrf-b up
  ip -netns foo li set veth11 up
  ip -netns foo addr add dev veth11 10.1.1.11/24
  ip -netns foo ro add 10.1.2.0/24 via 10.1.1.1

  ip netns add bar
  ip li add veth2 type veth peer name veth12 netns bar
  ip li set veth2 vrf vrf-a up
  ip addr add dev veth2 10.1.2.1/24
  ip -netns bar li set veth12 up
  ip -netns bar addr add dev veth12 10.1.2.12/24

If you do route leaking this way:
  ip ro add vrf vrf-b 10.1.2.0/24 dev veth2
  ip ro add vrf vrf-a 10.1.1.0/24 dev veth1

yes, you hit problems trying to connect to a local address.

If you do route leaking this way:
  ip ro add vrf vrf-b 10.1.2.0/24 dev vrf-a
  ip ro add vrf vrf-a 10.1.1.0/24 dev vrf-b

you do not.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next] vrf: local route leaking
  2019-05-24 20:19 ` David Ahern
@ 2019-05-25  7:09   ` George Wilkie
  2019-05-25 15:13     ` David Ahern
  0 siblings, 1 reply; 10+ messages in thread
From: George Wilkie @ 2019-05-25  7:09 UTC (permalink / raw)
  To: David Ahern
  Cc: Shrijeet Mukherjee, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev

On Fri, May 24, 2019 at 02:19:45PM -0600, David Ahern wrote:
> I think this codifies the use case:
>   ip li add vrf-a up type vrf table 1
>   ip route add vrf vrf-a unreachable default
>   ip li add vrf-b up type vrf table 2
>   ip route add vrf vrf-b unreachable default
>   ip ru add pref 32765 from all lookup local
>   ip ru del pref 0
> 
>   ip netns add foo
>   ip li add veth1 type veth peer name veth11 netns foo
>   ip addr add dev veth1 10.1.1.1/24
>   ip li set veth1 vrf vrf-b up
>   ip -netns foo li set veth11 up
>   ip -netns foo addr add dev veth11 10.1.1.11/24
>   ip -netns foo ro add 10.1.2.0/24 via 10.1.1.1
> 
>   ip netns add bar
>   ip li add veth2 type veth peer name veth12 netns bar
>   ip li set veth2 vrf vrf-a up
>   ip addr add dev veth2 10.1.2.1/24
>   ip -netns bar li set veth12 up
>   ip -netns bar addr add dev veth12 10.1.2.12/24

Although I'm not using namespaces:
   ip link add vrfA type vrf table 256
   ip link set dev vrfA up
   ip route add table 256 unreachable default metric 4278198272
   ip link set dev ens4 master vrfA
   ip address add 10.10.2.9/24 dev ens4
   ip link set dev ens4 up

   ip link add vrfB type vrf table 257
   ip link set dev vrfB up
   ip route add table 257 unreachable default metric 4278198272
   ip link set dev ens5 master vrfB
   ip address add 10.10.3.9/24 dev ens5
   ip link set dev ens5 up

> 
> If you do route leaking this way:
>   ip ro add vrf vrf-b 10.1.2.0/24 dev veth2
>   ip ro add vrf vrf-a 10.1.1.0/24 dev veth1
> 
> yes, you hit problems trying to connect to a local address.
> 
> If you do route leaking this way:
>   ip ro add vrf vrf-b 10.1.2.0/24 dev vrf-a
>   ip ro add vrf vrf-a 10.1.1.0/24 dev vrf-b
> 
> you do not.
> 

That was my initial thought, although it needs a 2nd lookup.
The problem I hit though was I couldn't figure out how to make it work
when leaking from global into a VRF. I couldn't see how to indicate
a lookup in the global table.  Is there a way to do this?
Using a loopback doesn't work, e.g. if 10.1.1.0/24 was on a global interface:
   ip ro add vrf vrf-a 10.1.1.0/24 dev lo

It seemed if something new was needed, leaking the locals was neater approach?

Thanks.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next] vrf: local route leaking
  2019-05-25  7:09   ` George Wilkie
@ 2019-05-25 15:13     ` David Ahern
  2019-05-27  8:34       ` George Wilkie
  0 siblings, 1 reply; 10+ messages in thread
From: David Ahern @ 2019-05-25 15:13 UTC (permalink / raw)
  To: George Wilkie
  Cc: Shrijeet Mukherjee, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev

On 5/25/19 1:09 AM, George Wilkie wrote:
> 
> That was my initial thought, although it needs a 2nd lookup.
> The problem I hit though was I couldn't figure out how to make it work
> when leaking from global into a VRF. I couldn't see how to indicate
> a lookup in the global table.  Is there a way to do this?
> Using a loopback doesn't work, e.g. if 10.1.1.0/24 was on a global interface:
>    ip ro add vrf vrf-a 10.1.1.0/24 dev lo

That works for MPLS when you exit the LSP and deliver locally, so it
should work here as well. I'll take a look early next week.

> 
> It seemed if something new was needed, leaking the locals was neater approach?
> 

I would prefer to avoid it if possible. VRF route leaking for forwarding
does not have the second lookup and that is the primary use case. VRL
with local delivery is a 1-off use case and you could just easily argue
that the connection should not rely on the leaked route. ie., the
control plane is aware of both VRFs, and the userspace process could use
the VRF-B path.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next] vrf: local route leaking
  2019-05-25 15:13     ` David Ahern
@ 2019-05-27  8:34       ` George Wilkie
  2019-05-30  3:29         ` David Ahern
  0 siblings, 1 reply; 10+ messages in thread
From: George Wilkie @ 2019-05-27  8:34 UTC (permalink / raw)
  To: David Ahern
  Cc: Shrijeet Mukherjee, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev

On Sat, May 25, 2019 at 09:13:13AM -0600, David Ahern wrote:
> > Using a loopback doesn't work, e.g. if 10.1.1.0/24 was on a global interface:
> >    ip ro add vrf vrf-a 10.1.1.0/24 dev lo
> 
> That works for MPLS when you exit the LSP and deliver locally, so it
> should work here as well. I'll take a look early next week.

OK, thanks.

> I would prefer to avoid it if possible. VRF route leaking for forwarding
> does not have the second lookup and that is the primary use case. VRL
> with local delivery is a 1-off use case and you could just easily argue
> that the connection should not rely on the leaked route. ie., the
> control plane is aware of both VRFs, and the userspace process could use
> the VRF-B path.
> 

Although it isn't always possible to change the userspace process -
may be running in a specific vrf by 'ip vrf exec'

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next] vrf: local route leaking
  2019-05-27  8:34       ` George Wilkie
@ 2019-05-30  3:29         ` David Ahern
  2019-05-30 20:52           ` George Wilkie
  0 siblings, 1 reply; 10+ messages in thread
From: David Ahern @ 2019-05-30  3:29 UTC (permalink / raw)
  To: George Wilkie
  Cc: Shrijeet Mukherjee, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev

On 5/27/19 2:34 AM, George Wilkie wrote:
> On Sat, May 25, 2019 at 09:13:13AM -0600, David Ahern wrote:
>>> Using a loopback doesn't work, e.g. if 10.1.1.0/24 was on a global interface:
>>>    ip ro add vrf vrf-a 10.1.1.0/24 dev lo
>>
>> That works for MPLS when you exit the LSP and deliver locally, so it
>> should work here as well. I'll take a look early next week.
> 
> OK, thanks.
> 
>> I would prefer to avoid it if possible. VRF route leaking for forwarding
>> does not have the second lookup and that is the primary use case. VRL
>> with local delivery is a 1-off use case and you could just easily argue
>> that the connection should not rely on the leaked route. ie., the
>> control plane is aware of both VRFs, and the userspace process could use
>> the VRF-B path.
>>
> 
> Although it isn't always possible to change the userspace process -
> may be running in a specific vrf by 'ip vrf exec'
> 

sure, but that is a design choice for the control plane. Effectively,
you have this setup:

    { process }
         |
         |  packet
         |
  +--------------+          +--------------+
  |     VRF A    |          |     VRF B    |
  |              |          |              |
  |              |     <------ route to A  |
  |   +------+   |          |   +------+   |
  +---| ens1 |---+          +---| ens2 |---+
      +------+                  +------+
                                    ^
                                    |
                                    |
                                 packet

ie., the process is potentially bound to VRF-A, and you want it handle
packets from VRF-B and without binding to VRF-B.

I already mentioned one solution that works well if the route is only
used for forwarding (add a route to VRF-B using ens1 as the egress
device) and a solution that works for local delivery (add route to VRF-B
using vrf-A device to do a second lookup).

you are correct that use of loopback here for default VRF does not work
-- the lookup code gets confused because it is a forward path (as
opposed to MPLS which is a local input). I found a couple of solutions
that work for default VRF.

Again, using namespaces to demonstrate within a single node. This is the
base setup:

 ip li add vrf-b up type vrf table 2
 ip route add vrf vrf-b unreachable default
 ip ru add pref 32765 from all lookup local
 ip ru del pref 0

 ip netns add foo
 ip li add veth1 type veth peer name veth11 netns foo
 ip addr add dev veth1 10.200.1.1/24
 ip li set veth1 vrf vrf-b up
 ip -netns foo li set veth11 up
 ip -netns foo addr add dev veth11 10.200.1.11/24
 ip -netns foo ro add 10.200.2.0/24 via 10.200.1.1

 ip netns add bar
 ip li add veth2 type veth peer name veth12 netns bar
 ip li set veth2 up
 ip addr add dev veth2 10.200.2.1/24
 ip -netns bar li set veth12 up
 ip -netns bar addr add dev veth12 10.200.2.12/24

Cross VRF routing can be done with a veth pair, without addresses:

 ip li add xvrf1 type veth peer name xvrf2
 ip li set xvrf1 up
 ip li set xvrf2 master vrf-b up

 ip ro add vrf vrf-b 10.200.2.0/24 dev xvrf2
 ip ro add 10.200.1.0/24 dev vrf-b

or with addresses:

 ip li add xvrf1 type veth peer name xvrf2
 ip li set xvrf1 up
 ip addr add dev xvrf1 10.200.3.1/30
 ip li set xvrf2 master vrf-b up
 ip addr add dev xvrf2 10.200.3.2/30

 ip ro add vrf vrf-b 10.200.2.0/24 via 10.200.3.1 dev xvrf2
 ip ro add 10.200.1.0/24 via 10.200.3.2 dev xvrf1

Yes, this does have a double FIB lookup - one in VRF-B and again in
VRF-A, but I contend this is a design choice. Bind the process to VRF-B
and it works with 1 lookup.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next] vrf: local route leaking
  2019-05-30  3:29         ` David Ahern
@ 2019-05-30 20:52           ` George Wilkie
  2019-05-30 21:50             ` David Ahern
  0 siblings, 1 reply; 10+ messages in thread
From: George Wilkie @ 2019-05-30 20:52 UTC (permalink / raw)
  To: David Ahern
  Cc: Shrijeet Mukherjee, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev

On Wed, May 29, 2019 at 09:29:22PM -0600, David Ahern wrote:
> you are correct that use of loopback here for default VRF does not work
> -- the lookup code gets confused because it is a forward path (as
> opposed to MPLS which is a local input). I found a couple of solutions
> that work for default VRF.
> 
> Again, using namespaces to demonstrate within a single node. This is the
> base setup:
> 
>  ip li add vrf-b up type vrf table 2
>  ip route add vrf vrf-b unreachable default
>  ip ru add pref 32765 from all lookup local
>  ip ru del pref 0
> 
>  ip netns add foo
>  ip li add veth1 type veth peer name veth11 netns foo
>  ip addr add dev veth1 10.200.1.1/24
>  ip li set veth1 vrf vrf-b up
>  ip -netns foo li set veth11 up
>  ip -netns foo addr add dev veth11 10.200.1.11/24
>  ip -netns foo ro add 10.200.2.0/24 via 10.200.1.1
> 
>  ip netns add bar
>  ip li add veth2 type veth peer name veth12 netns bar
>  ip li set veth2 up
>  ip addr add dev veth2 10.200.2.1/24
>  ip -netns bar li set veth12 up
>  ip -netns bar addr add dev veth12 10.200.2.12/24
> 
> Cross VRF routing can be done with a veth pair, without addresses:
> 
>  ip li add xvrf1 type veth peer name xvrf2
>  ip li set xvrf1 up
>  ip li set xvrf2 master vrf-b up
> 
>  ip ro add vrf vrf-b 10.200.2.0/24 dev xvrf2
>  ip ro add 10.200.1.0/24 dev vrf-b


This doesn't work for me (again, not using namespaces).
For traffic coming in on vrf-b to a destination on 10.200.2.0,
I see ARPs going out for the destination on xvrf2/in on xvrf1,
but nothing replies to it.

> 
> or with addresses:
> 
>  ip li add xvrf1 type veth peer name xvrf2
>  ip li set xvrf1 up
>  ip addr add dev xvrf1 10.200.3.1/30
>  ip li set xvrf2 master vrf-b up
>  ip addr add dev xvrf2 10.200.3.2/30
> 
>  ip ro add vrf vrf-b 10.200.2.0/24 via 10.200.3.1 dev xvrf2
>  ip ro add 10.200.1.0/24 via 10.200.3.2 dev xvrf1

Having to use additional addresses is not ideal.

However, there does seem to be an alternative approach which works.
If I create another vrf "vrfdefault" and associate it with table "local"
and use that to leak routes from global into a vrf, then it seems to
work for both v4 and v6.
Can reach both local and remote destinations
(which was somewhat surprising to me anyway).

 ip link add vrfdefault type vrf table local
 ip route add 10.10.4.0/24 vrf vrfA dev vrfdefault
 ip -6 route add 10:10:4::/64 vrf vrfA dev vrfdefault

Do you see any issue with relying on that?
Thx.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next] vrf: local route leaking
  2019-05-30 20:52           ` George Wilkie
@ 2019-05-30 21:50             ` David Ahern
  2019-05-31 10:38               ` George Wilkie
  0 siblings, 1 reply; 10+ messages in thread
From: David Ahern @ 2019-05-30 21:50 UTC (permalink / raw)
  To: George Wilkie
  Cc: Shrijeet Mukherjee, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev

On 5/30/19 2:52 PM, George Wilkie wrote:
> This doesn't work for me (again, not using namespaces).
> For traffic coming in on vrf-b to a destination on 10.200.2.0,
> I see ARPs going out for the destination on xvrf2/in on xvrf1,
> but nothing replies to it.

Is rp_filter set?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next] vrf: local route leaking
  2019-05-30 21:50             ` David Ahern
@ 2019-05-31 10:38               ` George Wilkie
  2019-05-31 14:54                 ` David Ahern
  0 siblings, 1 reply; 10+ messages in thread
From: George Wilkie @ 2019-05-31 10:38 UTC (permalink / raw)
  To: David Ahern
  Cc: Shrijeet Mukherjee, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev

On Thu, May 30, 2019 at 03:50:09PM -0600, David Ahern wrote:
> On 5/30/19 2:52 PM, George Wilkie wrote:
> > This doesn't work for me (again, not using namespaces).
> > For traffic coming in on vrf-b to a destination on 10.200.2.0,
> > I see ARPs going out for the destination on xvrf2/in on xvrf1,
> > but nothing replies to it.
> 
> Is rp_filter set?
> 

No, but arp_filter and arp_ignore was.
After setting net.ipv4.conf.all.arp_ignore=0 and
net.ipv4.conf.xvrf1.arp_filter=0 I can get ARP replies to the local address
but unsurprisingly not to the peer address.
So would only be able to leak the local /32 in this way,
and leak the /24 via the interface:
   sysctl net.ipv4.conf.all.arp_ignore=0
   ip li add xvrf1 type veth peer name xvrf2
   ip li set xvrf1 up
   ip li set xvrf2 master vrfA up
   sysctl net.ipv4.conf.xvrf1.arp_filter=0
   ip ro add vrf vrfA 10.10.3.0/24 dev enp1s3
   ip ro add vrf vrfA 10.10.3.2/32 dev xvrf2
   ip ro add 10.10.2.0/24 dev vrfA

It doesn't help for ipv6 though. No response to the neighbor solicitation.

What are your thoughts on creating a "vrfdefault" for "local" table?
   ip link add vrfdefault type vrf table local
   ip link set dev vrfdefault up
   ip ro add vrf vrfA 10.10.3.0/24 dev vrfdefault
   ip ro add 10.10.2.0/24 dev vrfA
   ip -6 ro add vrf vrfA 10:10:3::/64 dev vrfdefault
   ip -6 ro add 10:10:2::/64 dev vrfA

I'm able to reach local and peer addresses for both v4 and v6 with this
approach.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next] vrf: local route leaking
  2019-05-31 10:38               ` George Wilkie
@ 2019-05-31 14:54                 ` David Ahern
  0 siblings, 0 replies; 10+ messages in thread
From: David Ahern @ 2019-05-31 14:54 UTC (permalink / raw)
  To: George Wilkie
  Cc: Shrijeet Mukherjee, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev

On 5/31/19 4:38 AM, George Wilkie wrote:
> What are your thoughts on creating a "vrfdefault" for "local" table?
>    ip link add vrfdefault type vrf table local
>    ip link set dev vrfdefault up
>    ip ro add vrf vrfA 10.10.3.0/24 dev vrfdefault
>    ip ro add 10.10.2.0/24 dev vrfA
>    ip -6 ro add vrf vrfA 10:10:3::/64 dev vrfdefault
>    ip -6 ro add 10:10:2::/64 dev vrfA
> 
> I'm able to reach local and peer addresses for both v4 and v6 with this
> approach.

Robert looked into that some time back. I was not aware it is working,
but if it does, great.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-31 14:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24  8:05 [PATCH net-next] vrf: local route leaking George Wilkie
2019-05-24 20:19 ` David Ahern
2019-05-25  7:09   ` George Wilkie
2019-05-25 15:13     ` David Ahern
2019-05-27  8:34       ` George Wilkie
2019-05-30  3:29         ` David Ahern
2019-05-30 20:52           ` George Wilkie
2019-05-30 21:50             ` David Ahern
2019-05-31 10:38               ` George Wilkie
2019-05-31 14:54                 ` David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.