Commit 889ce937 authored by Sabrina Dubroca's avatar Sabrina Dubroca Committed by David S. Miller

vxlan: correctly set vxlan->net when creating the device in a netns

Commit a985343b ("vxlan: refactor verification and application of
configuration") modified vxlan device creation, and replaced the
assignment of vxlan->net to src_net with dev_net(netdev) in ->setup().

But dev_net(netdev) is not the same as src_net. At the time ->setup()
is called, dev_net hasn't been set yet, so we end up creating the
socket for the vxlan device in init_net.

Fix this by bringing back the assignment of vxlan->net during device
creation.

Fixes: a985343b ("vxlan: refactor verification and application of configuration")
Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
Reviewed-by: default avatarMatthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c3b99db8
...@@ -2656,7 +2656,6 @@ static void vxlan_setup(struct net_device *dev) ...@@ -2656,7 +2656,6 @@ static void vxlan_setup(struct net_device *dev)
vxlan->age_timer.data = (unsigned long) vxlan; vxlan->age_timer.data = (unsigned long) vxlan;
vxlan->dev = dev; vxlan->dev = dev;
vxlan->net = dev_net(dev);
gro_cells_init(&vxlan->gro_cells, dev); gro_cells_init(&vxlan->gro_cells, dev);
...@@ -3028,7 +3027,9 @@ static int vxlan_config_validate(struct net *src_net, struct vxlan_config *conf, ...@@ -3028,7 +3027,9 @@ static int vxlan_config_validate(struct net *src_net, struct vxlan_config *conf,
static void vxlan_config_apply(struct net_device *dev, static void vxlan_config_apply(struct net_device *dev,
struct vxlan_config *conf, struct vxlan_config *conf,
struct net_device *lowerdev, bool changelink) struct net_device *lowerdev,
struct net *src_net,
bool changelink)
{ {
struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_dev *vxlan = netdev_priv(dev);
struct vxlan_rdst *dst = &vxlan->default_dst; struct vxlan_rdst *dst = &vxlan->default_dst;
...@@ -3044,6 +3045,8 @@ static void vxlan_config_apply(struct net_device *dev, ...@@ -3044,6 +3045,8 @@ static void vxlan_config_apply(struct net_device *dev,
if (conf->mtu) if (conf->mtu)
dev->mtu = conf->mtu; dev->mtu = conf->mtu;
vxlan->net = src_net;
} }
dst->remote_vni = conf->vni; dst->remote_vni = conf->vni;
...@@ -3086,7 +3089,7 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, ...@@ -3086,7 +3089,7 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
if (ret) if (ret)
return ret; return ret;
vxlan_config_apply(dev, conf, lowerdev, changelink); vxlan_config_apply(dev, conf, lowerdev, src_net, changelink);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment