diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2014-04-16 05:19:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-04-16 15:16:02 -0400 |
commit | 8c923ce219b775cc659a31616590afee239a84e5 (patch) | |
tree | a45ff5baecbf227b312cf57a53497facf19b49f1 /net/ipv4 | |
parent | b7c0ddf5f270b2a3c0af326cb300eb17175d58e3 (diff) |
ip_tunnel: use the right netns in ioctl handler
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/ip_tunnel.c | 15 |
1 files 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, | |||
722 | int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) | 722 | int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) |
723 | { | 723 | { |
724 | int err = 0; | 724 | int err = 0; |
725 | struct ip_tunnel *t; | 725 | struct ip_tunnel *t = netdev_priv(dev); |
726 | struct net *net = dev_net(dev); | 726 | struct net *net = t->net; |
727 | struct ip_tunnel *tunnel = netdev_priv(dev); | 727 | struct ip_tunnel_net *itn = net_generic(net, t->ip_tnl_net_id); |
728 | struct ip_tunnel_net *itn = net_generic(net, tunnel->ip_tnl_net_id); | ||
729 | 728 | ||
730 | BUG_ON(!itn->fb_tunnel_dev); | 729 | BUG_ON(!itn->fb_tunnel_dev); |
731 | switch (cmd) { | 730 | switch (cmd) { |
732 | case SIOCGETTUNNEL: | 731 | case SIOCGETTUNNEL: |
733 | t = NULL; | 732 | if (dev == itn->fb_tunnel_dev) { |
734 | if (dev == itn->fb_tunnel_dev) | ||
735 | t = ip_tunnel_find(itn, p, itn->fb_tunnel_dev->type); | 733 | t = ip_tunnel_find(itn, p, itn->fb_tunnel_dev->type); |
736 | if (t == NULL) | 734 | if (t == NULL) |
737 | t = netdev_priv(dev); | 735 | t = netdev_priv(dev); |
736 | } | ||
738 | memcpy(p, &t->parms, sizeof(*p)); | 737 | memcpy(p, &t->parms, sizeof(*p)); |
739 | break; | 738 | break; |
740 | 739 | ||