* [PATCH net 1/3] ip_tunnel: use the right netns in ioctl handler
@ 2014-04-16 9:19 Nicolas Dichtel
2014-04-16 9:19 ` [PATCH net 2/3] sit: " Nicolas Dichtel
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Nicolas Dichtel @ 2014-04-16 9:19 UTC (permalink / raw)
To: davem; +Cc: netdev, Nicolas Dichtel
Because the netdevice may be in another netns than the i/o netns, we should
use the i/o netns instead of dev_net(dev).
The variable 'tunnel' was used only to get 'itn', hence to simplify code I
remove it and use 't' instead.
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
net/ipv4/ip_tunnel.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 484d0ce27ef7..fa5b7519765f 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -722,19 +722,18 @@ static void ip_tunnel_update(struct ip_tunnel_net *itn,
int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd)
{
int err = 0;
- struct ip_tunnel *t;
- struct net *net = dev_net(dev);
- struct ip_tunnel *tunnel = netdev_priv(dev);
- struct ip_tunnel_net *itn = net_generic(net, tunnel->ip_tnl_net_id);
+ struct ip_tunnel *t = netdev_priv(dev);
+ struct net *net = t->net;
+ struct ip_tunnel_net *itn = net_generic(net, t->ip_tnl_net_id);
BUG_ON(!itn->fb_tunnel_dev);
switch (cmd) {
case SIOCGETTUNNEL:
- t = NULL;
- if (dev == itn->fb_tunnel_dev)
+ if (dev == itn->fb_tunnel_dev) {
t = ip_tunnel_find(itn, p, itn->fb_tunnel_dev->type);
- if (t == NULL)
- t = netdev_priv(dev);
+ if (t == NULL)
+ t = netdev_priv(dev);
+ }
memcpy(p, &t->parms, sizeof(*p));
break;
--
1.9.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH net 2/3] sit: use the right netns in ioctl handler 2014-04-16 9:19 [PATCH net 1/3] ip_tunnel: use the right netns in ioctl handler Nicolas Dichtel @ 2014-04-16 9:19 ` Nicolas Dichtel 2014-04-16 19:16 ` David Miller 2014-04-16 9:19 ` [PATCH net 3/3] ip6_tunnel: " Nicolas Dichtel 2014-04-16 19:16 ` [PATCH net 1/3] ip_tunnel: " David Miller 2 siblings, 1 reply; 6+ messages in thread From: Nicolas Dichtel @ 2014-04-16 9:19 UTC (permalink / raw) To: davem; +Cc: netdev, Nicolas Dichtel Because the netdevice may be in another netns than the i/o netns, we should use the i/o netns instead of dev_net(dev). Note that netdev_priv(dev) cannot bu NULL, hence we can remove these useless checks. Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> --- net/ipv6/sit.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 8da8268d65f8..e5a453ca302e 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -1127,8 +1127,8 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) int err = 0; struct ip_tunnel_parm p; struct ip_tunnel_prl prl; - struct ip_tunnel *t; - struct net *net = dev_net(dev); + struct ip_tunnel *t = netdev_priv(dev); + struct net *net = t->net; struct sit_net *sitn = net_generic(net, sit_net_id); #ifdef CONFIG_IPV6_SIT_6RD struct ip_tunnel_6rd ip6rd; @@ -1139,16 +1139,15 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) #ifdef CONFIG_IPV6_SIT_6RD case SIOCGET6RD: #endif - t = NULL; if (dev == sitn->fb_tunnel_dev) { if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) { err = -EFAULT; break; } t = ipip6_tunnel_locate(net, &p, 0); + if (t == NULL) + t = netdev_priv(dev); } - if (t == NULL) - t = netdev_priv(dev); err = -EFAULT; if (cmd == SIOCGETTUNNEL) { @@ -1244,9 +1243,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) err = -EINVAL; if (dev == sitn->fb_tunnel_dev) goto done; - err = -ENOENT; - if (!(t = netdev_priv(dev))) - goto done; err = ipip6_tunnel_get_prl(t, ifr->ifr_ifru.ifru_data); break; @@ -1262,9 +1258,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) err = -EFAULT; if (copy_from_user(&prl, ifr->ifr_ifru.ifru_data, sizeof(prl))) goto done; - err = -ENOENT; - if (!(t = netdev_priv(dev))) - goto done; switch (cmd) { case SIOCDELPRL: @@ -1292,8 +1285,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) sizeof(ip6rd))) goto done; - t = netdev_priv(dev); - if (cmd != SIOCDEL6RD) { err = ipip6_tunnel_update_6rd(t, &ip6rd); if (err < 0) -- 1.9.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net 2/3] sit: use the right netns in ioctl handler 2014-04-16 9:19 ` [PATCH net 2/3] sit: " Nicolas Dichtel @ 2014-04-16 19:16 ` David Miller 0 siblings, 0 replies; 6+ messages in thread From: David Miller @ 2014-04-16 19:16 UTC (permalink / raw) To: nicolas.dichtel; +Cc: netdev From: Nicolas Dichtel <nicolas.dichtel@6wind.com> Date: Wed, 16 Apr 2014 11:19:33 +0200 > Because the netdevice may be in another netns than the i/o netns, we should > use the i/o netns instead of dev_net(dev). > > Note that netdev_priv(dev) cannot bu NULL, hence we can remove these useless > checks. > > Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Applied. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net 3/3] ip6_tunnel: use the right netns in ioctl handler 2014-04-16 9:19 [PATCH net 1/3] ip_tunnel: use the right netns in ioctl handler Nicolas Dichtel 2014-04-16 9:19 ` [PATCH net 2/3] sit: " Nicolas Dichtel @ 2014-04-16 9:19 ` Nicolas Dichtel 2014-04-16 19:16 ` David Miller 2014-04-16 19:16 ` [PATCH net 1/3] ip_tunnel: " David Miller 2 siblings, 1 reply; 6+ messages in thread From: Nicolas Dichtel @ 2014-04-16 9:19 UTC (permalink / raw) To: davem; +Cc: netdev, Nicolas Dichtel Because the netdevice may be in another netns than the i/o netns, we should use the i/o netns instead of dev_net(dev). Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> --- net/ipv6/ip6_tunnel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index e1df691d78be..b05b609f69d1 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -1340,8 +1340,8 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) int err = 0; struct ip6_tnl_parm p; struct __ip6_tnl_parm p1; - struct ip6_tnl *t = NULL; - struct net *net = dev_net(dev); + struct ip6_tnl *t = netdev_priv(dev); + struct net *net = t->net; struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); switch (cmd) { @@ -1353,11 +1353,11 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) } ip6_tnl_parm_from_user(&p1, &p); t = ip6_tnl_locate(net, &p1, 0); + if (t == NULL) + t = netdev_priv(dev); } else { memset(&p, 0, sizeof(p)); } - if (t == NULL) - t = netdev_priv(dev); ip6_tnl_parm_to_user(&p, &t->parms); if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof (p))) { err = -EFAULT; -- 1.9.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net 3/3] ip6_tunnel: use the right netns in ioctl handler 2014-04-16 9:19 ` [PATCH net 3/3] ip6_tunnel: " Nicolas Dichtel @ 2014-04-16 19:16 ` David Miller 0 siblings, 0 replies; 6+ messages in thread From: David Miller @ 2014-04-16 19:16 UTC (permalink / raw) To: nicolas.dichtel; +Cc: netdev From: Nicolas Dichtel <nicolas.dichtel@6wind.com> Date: Wed, 16 Apr 2014 11:19:34 +0200 > Because the netdevice may be in another netns than the i/o netns, we should > use the i/o netns instead of dev_net(dev). > > Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Applied. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net 1/3] ip_tunnel: use the right netns in ioctl handler 2014-04-16 9:19 [PATCH net 1/3] ip_tunnel: use the right netns in ioctl handler Nicolas Dichtel 2014-04-16 9:19 ` [PATCH net 2/3] sit: " Nicolas Dichtel 2014-04-16 9:19 ` [PATCH net 3/3] ip6_tunnel: " Nicolas Dichtel @ 2014-04-16 19:16 ` David Miller 2 siblings, 0 replies; 6+ messages in thread From: David Miller @ 2014-04-16 19:16 UTC (permalink / raw) To: nicolas.dichtel; +Cc: netdev From: Nicolas Dichtel <nicolas.dichtel@6wind.com> Date: Wed, 16 Apr 2014 11:19:32 +0200 > Because the netdevice may be in another netns than the i/o netns, we should > use the i/o netns instead of dev_net(dev). > > The variable 'tunnel' was used only to get 'itn', hence to simplify code I > remove it and use 't' instead. > > Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Applied. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-04-16 19:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-04-16 9:19 [PATCH net 1/3] ip_tunnel: use the right netns in ioctl handler Nicolas Dichtel 2014-04-16 9:19 ` [PATCH net 2/3] sit: " Nicolas Dichtel 2014-04-16 19:16 ` David Miller 2014-04-16 9:19 ` [PATCH net 3/3] ip6_tunnel: " Nicolas Dichtel 2014-04-16 19:16 ` David Miller 2014-04-16 19:16 ` [PATCH net 1/3] ip_tunnel: " 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).