datapath: Account for "vxlan: add x-netns support"
authorThomas Graf <tgraf@noironetworks.com>
Tue, 3 Feb 2015 20:53:35 +0000 (21:53 +0100)
committerThomas Graf <tgraf@noironetworks.com>
Tue, 3 Feb 2015 20:56:41 +0000 (21:56 +0100)
Upstream commit:
    vxlan: add x-netns support

    This patch allows to switch the netns when packet is encapsulated or
    decapsulated.
    The vxlan socket is openned into the i/o netns, ie into the netns where
    encapsulated packets are received. The socket lookup is done into this netns to
    find the corresponding vxlan tunnel. After decapsulation, the packet is
    injecting into the corresponding interface which may stand to another netns.

    When one of the two netns is removed, the tunnel is destroyed.

    Configuration example:
    ip netns add netns1
    ip netns exec netns1 ip link set lo up
    ip link add vxlan10 type vxlan id 10 group 239.0.0.10 dev eth0 dstport 0
    ip link set vxlan10 netns netns1
    ip netns exec netns1 ip addr add 192.168.0.249/24 broadcast 192.168.0.255 dev vxlan10
    ip netns exec netns1 ip link set vxlan10 up

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: f01ec1c017de ("vxlan: add x-netns support")
Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
datapath/linux/compat/include/net/vxlan.h
datapath/linux/compat/vxlan.c
datapath/vport-vxlan.c

index 4f3e3b7..643f837 100644 (file)
@@ -82,7 +82,7 @@ static inline int rpl_vxlan_xmit_skb(struct vxlan_sock *vs,
                    struct rtable *rt, struct sk_buff *skb,
                    __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
                    __be16 src_port, __be16 dst_port,
-                  struct vxlan_metadata *md)
+                  struct vxlan_metadata *md, bool xnet)
 {
        if (skb_is_gso(skb) && skb_is_encapsulated(skb)) {
                kfree_skb(skb);
@@ -90,7 +90,7 @@ static inline int rpl_vxlan_xmit_skb(struct vxlan_sock *vs,
        }
 
        return vxlan_xmit_skb(vs, rt, skb, src, dst, tos, ttl, df,
-                             src_port, dst_port, md, false);
+                             src_port, dst_port, md, xnet);
 }
 
 #define vxlan_xmit_skb rpl_vxlan_xmit_skb
@@ -132,7 +132,7 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
                   struct rtable *rt, struct sk_buff *skb,
                   __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
                   __be16 src_port, __be16 dst_port,
-                  struct vxlan_metadata *md);
+                  struct vxlan_metadata *md, bool xnet);
 
 #define vxlan_src_port rpl_vxlan_src_port
 __be16 vxlan_src_port(__u16 port_min, __u16 port_max, struct sk_buff *skb);
index 969e32c..dbccd3c 100644 (file)
@@ -227,7 +227,7 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
                   struct rtable *rt, struct sk_buff *skb,
                   __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
                   __be16 src_port, __be16 dst_port,
-                  struct vxlan_metadata *md)
+                  struct vxlan_metadata *md, bool xnet)
 {
        struct vxlanhdr *vxh;
        struct udphdr *uh;
@@ -280,7 +280,7 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
                return PTR_ERR(skb);
 
        return iptunnel_xmit(vs->sock->sk, rt, skb, src, dst, IPPROTO_UDP,
-                            tos, ttl, df, false);
+                            tos, ttl, df, xnet);
 }
 
 static void rcu_free_vs(struct rcu_head *rcu)
index c4b4b99..45ea911 100644 (file)
@@ -181,7 +181,7 @@ static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb)
                             tun_key->ipv4_tos,
                             tun_key->ipv4_ttl, df,
                             src_port, dst_port,
-                            &md);
+                            &md, false);
        if (err < 0)
                ip_rt_put(rt);
        return err;