netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Jeff Barnhill <0xeffeff@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: v6/sit tunnels and VRFs
Date: Thu, 26 Oct 2017 11:24:01 -0600	[thread overview]
Message-ID: <9cade21c-5d92-d435-386f-6d854e6b6d55@gmail.com> (raw)
In-Reply-To: <CAL6e_pdBDWBO796tfCnygj0e-c7S81O1y3hvZz3rgbMgxUobOg@mail.gmail.com>

On 10/25/17 9:28 PM, Jeff Barnhill wrote:
> Thanks, David.
> 
> VM1:
> sudo ip addr add 192.168.200.1/24 dev enp0s8 broadcast 192.168.200.255
> sudo ip link set enp0s8 up
> sudo ip route add 192.168.210.0/24 nexthop via 192.168.200.3 dev enp0s8
> sudo ip tunnel add jtun mode sit remote 192.168.210.2 local 192.168.200.1
> sudo ip -6 addr add 2001::1/64 dev jtun
> sudo ip link set jtun up
> 
> VM2:
> sudo ip addr add 192.168.210.2/24 dev enp0s8 broadcast 192.168.210.255
> sudo ip link set enp0s8 up
> sudo ip route add 192.168.200.0/24 nexthop via 192.168.210.3 dev enp0s8
> sudo ip link add dev myvrf type vrf table 256
> sudo ip link set myvrf up
> sudo ip link set enp0s8 vrf myvrf

You lost the static route by doing the enslaving here. When the device
is added to or removed from a VRF it is cycled specifically to dump
routes and neighbor entries associated with the prior vrf. Always create
the vrf and enslave first, then add routes:

sudo ip link add dev myvrf type vrf table 256
sudo ip link set myvrf up
sudo ip link set enp0s8 vrf myvrf

sudo ip addr add 192.168.210.2/24 dev enp0s8 broadcast 192.168.210.255
sudo ip link set enp0s8 up
sudo ip route add 192.168.200.0/24 nexthop via 192.168.210.3 dev enp0s8

That said, the above works for the wrong reason -- it is not really
doing VRF based routing. For that to happen, the static route should be
added to the vrf table:

sudo ip route add vrf myvrf 192.168.200.0/24 nexthop via 192.168.210.3
dev enp0s8

And ...

> sudo ip tunnel add jtun mode sit remote 192.168.200.1 local 192.168.210.2

you need to specify the link on the tunnel create:

sudo ip tunnel add jtun mode sit remote 192.168.200.1 local
192.168.210.2 dev enp0s8.

And ...

The tunnel lookup needs to account for the VRF device switch:

(whitespace damaged on paste)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index a799f5258614..cf0512054fa7 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -632,11 +632,18 @@ static bool packet_is_spoofed(struct sk_buff *skb,
 static int ipip6_rcv(struct sk_buff *skb)
 {
        const struct iphdr *iph = ip_hdr(skb);
+       struct net_device *dev = skb->dev;
+       struct net *net = dev_net(dev);
        struct ip_tunnel *tunnel;
        int err;

-       tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
-                                    iph->saddr, iph->daddr);
+       if (netif_is_l3_master(dev)) {
+               dev = dev_get_by_index_rcu(net, IPCB(skb)->iif);
+               if (!dev)
+                       goto out;
+       }
+
+       tunnel = ipip6_tunnel_lookup(net, dev, iph->saddr, iph->daddr);
        if (tunnel) {
                struct pcpu_sw_netstats *tstats;

  reply	other threads:[~2017-10-26 17:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25 20:45 v6/sit tunnels and VRFs Jeff Barnhill
2017-10-25 21:31 ` David Ahern
2017-10-26  3:28   ` Jeff Barnhill
2017-10-26 17:24     ` David Ahern [this message]
2017-10-27  5:19       ` Jeff Barnhill
2017-10-27 16:25         ` David Ahern
2017-10-27 20:59           ` Jeff Barnhill
2017-10-27 22:53             ` David Ahern
2017-10-28  2:43               ` Jeff Barnhill
2017-10-29 15:48                 ` David Ahern
2017-10-31 22:20                   ` Jeff Barnhill
2017-10-31 22:36                     ` David Ahern
2017-10-31 22:42                     ` David Ahern
2018-04-12 16:54                   ` Jeff Barnhill
2018-04-13  2:25                     ` David Ahern
2018-04-13 20:23                       ` Jeff Barnhill
2018-04-13 20:31                         ` David Ahern
2018-04-14 22:07                           ` Jeff Barnhill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9cade21c-5d92-d435-386f-6d854e6b6d55@gmail.com \
    --to=dsahern@gmail.com \
    --cc=0xeffeff@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).