* [PATCH net-next] vxlan: correctly set vxlan->net when creating the device in a netns
@ 2017-06-30 13:50 Sabrina Dubroca
2017-07-03 8:13 ` Matthias Schiffer
2017-07-03 9:05 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Sabrina Dubroca @ 2017-06-30 13:50 UTC (permalink / raw)
To: netdev; +Cc: Sabrina Dubroca, Matthias Schiffer
Commit a985343ba906 ("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: a985343ba906 ("vxlan: refactor verification and application of configuration")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
drivers/net/vxlan.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index fd0ff97e3d81..47d6e65851aa 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2656,7 +2656,6 @@ static void vxlan_setup(struct net_device *dev)
vxlan->age_timer.data = (unsigned long) vxlan;
vxlan->dev = dev;
- vxlan->net = dev_net(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,
static void vxlan_config_apply(struct net_device *dev,
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_rdst *dst = &vxlan->default_dst;
@@ -3044,6 +3045,8 @@ static void vxlan_config_apply(struct net_device *dev,
if (conf->mtu)
dev->mtu = conf->mtu;
+
+ vxlan->net = src_net;
}
dst->remote_vni = conf->vni;
@@ -3086,7 +3089,7 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
if (ret)
return ret;
- vxlan_config_apply(dev, conf, lowerdev, changelink);
+ vxlan_config_apply(dev, conf, lowerdev, src_net, changelink);
return 0;
}
--
2.13.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vxlan: correctly set vxlan->net when creating the device in a netns
2017-06-30 13:50 [PATCH net-next] vxlan: correctly set vxlan->net when creating the device in a netns Sabrina Dubroca
@ 2017-07-03 8:13 ` Matthias Schiffer
2017-07-03 9:05 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Matthias Schiffer @ 2017-07-03 8:13 UTC (permalink / raw)
To: Sabrina Dubroca, netdev
[-- Attachment #1.1: Type: text/plain, Size: 2364 bytes --]
On 06/30/2017 03:50 PM, Sabrina Dubroca wrote:
> Commit a985343ba906 ("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: a985343ba906 ("vxlan: refactor verification and application of configuration")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Thanks for fixing this up, I really didn't expect dev_net() not to return
the correct net in setup().
Reviewed-by: Matthias Schiffer <mschiffer@universe-factory.net>
> ---
> drivers/net/vxlan.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
> index fd0ff97e3d81..47d6e65851aa 100644
> --- a/drivers/net/vxlan.c
> +++ b/drivers/net/vxlan.c
> @@ -2656,7 +2656,6 @@ static void vxlan_setup(struct net_device *dev)
> vxlan->age_timer.data = (unsigned long) vxlan;
>
> vxlan->dev = dev;
> - vxlan->net = dev_net(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,
>
> static void vxlan_config_apply(struct net_device *dev,
> 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_rdst *dst = &vxlan->default_dst;
> @@ -3044,6 +3045,8 @@ static void vxlan_config_apply(struct net_device *dev,
>
> if (conf->mtu)
> dev->mtu = conf->mtu;
> +
> + vxlan->net = src_net;
> }
>
> dst->remote_vni = conf->vni;
> @@ -3086,7 +3089,7 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
> if (ret)
> return ret;
>
> - vxlan_config_apply(dev, conf, lowerdev, changelink);
> + vxlan_config_apply(dev, conf, lowerdev, src_net, changelink);
>
> return 0;
> }
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vxlan: correctly set vxlan->net when creating the device in a netns
2017-06-30 13:50 [PATCH net-next] vxlan: correctly set vxlan->net when creating the device in a netns Sabrina Dubroca
2017-07-03 8:13 ` Matthias Schiffer
@ 2017-07-03 9:05 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-07-03 9:05 UTC (permalink / raw)
To: sd; +Cc: netdev, mschiffer
From: Sabrina Dubroca <sd@queasysnail.net>
Date: Fri, 30 Jun 2017 15:50:00 +0200
> Commit a985343ba906 ("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: a985343ba906 ("vxlan: refactor verification and application of configuration")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-03 9:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-30 13:50 [PATCH net-next] vxlan: correctly set vxlan->net when creating the device in a netns Sabrina Dubroca
2017-07-03 8:13 ` Matthias Schiffer
2017-07-03 9:05 ` David Miller
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).