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.dich...@6wind.com> Signed-off-by: David S. Miller <da...@davemloft.net> Upstream: f01ec1c017de ("vxlan: add x-netns support") Signed-off-by: Thomas Graf <tg...@noironetworks.com> --- datapath/linux/compat/include/net/vxlan.h | 6 +++--- datapath/linux/compat/vxlan.c | 4 ++-- datapath/vport-vxlan.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/datapath/linux/compat/include/net/vxlan.h b/datapath/linux/compat/include/net/vxlan.h index 4f3e3b7..643f837 100644 --- a/datapath/linux/compat/include/net/vxlan.h +++ b/datapath/linux/compat/include/net/vxlan.h @@ -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); diff --git a/datapath/linux/compat/vxlan.c b/datapath/linux/compat/vxlan.c index 969e32c..dbccd3c 100644 --- a/datapath/linux/compat/vxlan.c +++ b/datapath/linux/compat/vxlan.c @@ -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) diff --git a/datapath/vport-vxlan.c b/datapath/vport-vxlan.c index c4b4b99..45ea911 100644 --- a/datapath/vport-vxlan.c +++ b/datapath/vport-vxlan.c @@ -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; -- 1.9.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev