diff mbox series

net: vxlan: disallow removing to other namespace

Message ID 1558147343-93724-1-git-send-email-xiangxia.m.yue@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series net: vxlan: disallow removing to other namespace | expand

Commit Message

Tonghao Zhang May 18, 2019, 2:42 a.m. UTC
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

Don't allow to remove the vxlan device to other namesapce,
because we maintain the data of vxlan net device on original
net-namespace.

    $ ip netns add ns100
    $ ip link add vxlan100 type vxlan dstport 4789 external
    $ ip link set dev vxlan100 netns ns100
    $ ip netns exec ns100 ip link add vxlan200 type vxlan dstport 4789 external
    $ ip netns exec ns100 ip link
    ...
    vxlan200: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    vxlan100: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000

And we should create it on new net-namespace, so disallow removing it.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 drivers/net/vxlan.c | 1 +
 1 file changed, 1 insertion(+)

Comments

David Miller May 20, 2019, 11:53 p.m. UTC | #1
From: xiangxia.m.yue@gmail.com
Date: Fri, 17 May 2019 19:42:23 -0700

> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> Don't allow to remove the vxlan device to other namesapce,
> because we maintain the data of vxlan net device on original
> net-namespace.
> 
>     $ ip netns add ns100
>     $ ip link add vxlan100 type vxlan dstport 4789 external
>     $ ip link set dev vxlan100 netns ns100
>     $ ip netns exec ns100 ip link add vxlan200 type vxlan dstport 4789 external
>     $ ip netns exec ns100 ip link
>     ...
>     vxlan200: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
>     vxlan100: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
> 
> And we should create it on new net-namespace, so disallow removing it.
> 
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>

I don't understand this change at all.

You keep saying "Remove" but I think you might mean simply "Move" because
the NETNS_LOCAL flag prevents moving not removing.

And why is it bad to allow vxlan devices to be moved between network
namespaces?  What problem would it cause and can you guarantee that
you are not breaking an existing user?

I'm not applying this as-is.
Tonghao Zhang May 21, 2019, 5:53 a.m. UTC | #2
On Tue, May 21, 2019 at 7:53 AM David Miller <davem@davemloft.net> wrote:
>
> From: xiangxia.m.yue@gmail.com
> Date: Fri, 17 May 2019 19:42:23 -0700
>
> > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > Don't allow to remove the vxlan device to other namesapce,
> > because we maintain the data of vxlan net device on original
> > net-namespace.
> >
> >     $ ip netns add ns100
> >     $ ip link add vxlan100 type vxlan dstport 4789 external
> >     $ ip link set dev vxlan100 netns ns100
> >     $ ip netns exec ns100 ip link add vxlan200 type vxlan dstport 4789 external
> >     $ ip netns exec ns100 ip link
> >     ...
> >     vxlan200: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
> >     vxlan100: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
> >
> > And we should create it on new net-namespace, so disallow removing it.
> >
> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> I don't understand this change at all.
>
> You keep saying "Remove" but I think you might mean simply "Move" because
> the NETNS_LOCAL flag prevents moving not removing.
Yes, should change "remove" to "move".

> And why is it bad to allow vxlan devices to be moved between network
> namespaces?  What problem would it cause and can you guarantee that
> you are not breaking an existing user?

The problem is that we create one vxlan netdevice(e.g dstport 4789 and
external), and move it to
one net-namespace, and then we hope create one again(dstport 4789 and
external) and move it to other net-namespace, but we can't create it.

$ ip netns add ns100
$ ip link add vxlan100 type vxlan dstport 4789 external
$ ip link set dev vxlan100 netns ns100
$ ip link add vxlan200 type vxlan dstport 4789 external
RTNETLINK answers: File exists

The better way is that we should create directly it in the
net-namespace. To avoid confuse user, disallow moving it to other
net-namespace.

> I'm not applying this as-is.
Nicolas Dichtel May 21, 2019, 9:28 a.m. UTC | #3
Le 21/05/2019 à 07:53, Tonghao Zhang a écrit :
[snip]
> The problem is that we create one vxlan netdevice(e.g dstport 4789 and
> external), and move it to
> one net-namespace, and then we hope create one again(dstport 4789 and
> external) and move it to other net-namespace, but we can't create it.
> 
> $ ip netns add ns100
> $ ip link add vxlan100 type vxlan dstport 4789 external
> $ ip link set dev vxlan100 netns ns100
> $ ip link add vxlan200 type vxlan dstport 4789 external
> RTNETLINK answers: File exists
Why is this a problem? This error is correct, the interface already exists.

> 
> The better way is that we should create directly it in the
> net-namespace. To avoid confuse user, disallow moving it to other
> net-namespace.
There is no confusion, this is a feature. This link part of the vxlan is in
another namespace:

$ ip -d -n ns100 link ls vxlan100
15: vxlan100: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT
group default qlen 1000
    link/ether d6:54:ea:b4:46:a5 brd ff:ff:ff:ff:ff:ff link-netnsid 0
promiscuity 0 minmtu 68 maxmtu 65535
    vxlan externaladdrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size
65536 gso_max_segs 65535

=> "link-netnsid 0" means that the link part is in the nsid 0, ie init_net in my
case.


Regards,
Nicolas
Tonghao Zhang May 21, 2019, 11:08 a.m. UTC | #4
On Tue, May 21, 2019 at 5:28 PM Nicolas Dichtel
<nicolas.dichtel@6wind.com> wrote:
>
> Le 21/05/2019 à 07:53, Tonghao Zhang a écrit :
> [snip]
> > The problem is that we create one vxlan netdevice(e.g dstport 4789 and
> > external), and move it to
> > one net-namespace, and then we hope create one again(dstport 4789 and
> > external) and move it to other net-namespace, but we can't create it.
> >
> > $ ip netns add ns100
> > $ ip link add vxlan100 type vxlan dstport 4789 external
> > $ ip link set dev vxlan100 netns ns100
> > $ ip link add vxlan200 type vxlan dstport 4789 external
> > RTNETLINK answers: File exists
> Why is this a problem? This error is correct, the interface already exists.
>
> >
> > The better way is that we should create directly it in the
> > net-namespace. To avoid confuse user, disallow moving it to other
> > net-namespace.
> There is no confusion, this is a feature. This link part of the vxlan is in
> another namespace:
>
> $ ip -d -n ns100 link ls vxlan100
> 15: vxlan100: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT
> group default qlen 1000
>     link/ether d6:54:ea:b4:46:a5 brd ff:ff:ff:ff:ff:ff link-netnsid 0
> promiscuity 0 minmtu 68 maxmtu 65535
>     vxlan externaladdrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size
> 65536 gso_max_segs 65535
>
> => "link-netnsid 0" means that the link part is in the nsid 0, ie init_net in my
> case.
I got it, thanks
>
> Regards,
> Nicolas
diff mbox series

Patch

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 5994d54..63add28 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2998,6 +2998,7 @@  static void vxlan_setup(struct net_device *dev)
 	dev->needs_free_netdev = true;
 	SET_NETDEV_DEVTYPE(dev, &vxlan_type);
 
+	dev->features	|= NETIF_F_NETNS_LOCAL;
 	dev->features	|= NETIF_F_LLTX;
 	dev->features	|= NETIF_F_SG | NETIF_F_HW_CSUM;
 	dev->features   |= NETIF_F_RXCSUM;