diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2014-04-16 05:19:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-04-16 15:16:02 -0400 |
commit | 9aad77c3b5cc9151d356b66ee8533e85ca7da192 (patch) | |
tree | efdceac253e1ac01e825f10cb3b1660047a76d15 /net | |
parent | 8c923ce219b775cc659a31616590afee239a84e5 (diff) |
sit: 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).
Note that netdev_priv(dev) cannot bu NULL, hence we can remove these useless
checks.
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv6/sit.c | 17 |
1 files 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) | |||
1127 | int err = 0; | 1127 | int err = 0; |
1128 | struct ip_tunnel_parm p; | 1128 | struct ip_tunnel_parm p; |
1129 | struct ip_tunnel_prl prl; | 1129 | struct ip_tunnel_prl prl; |
1130 | struct ip_tunnel *t; | 1130 | struct ip_tunnel *t = netdev_priv(dev); |
1131 | struct net *net = dev_net(dev); | 1131 | struct net *net = t->net; |
1132 | struct sit_net *sitn = net_generic(net, sit_net_id); | 1132 | struct sit_net *sitn = net_generic(net, sit_net_id); |
1133 | #ifdef CONFIG_IPV6_SIT_6RD | 1133 | #ifdef CONFIG_IPV6_SIT_6RD |
1134 | struct ip_tunnel_6rd ip6rd; | 1134 | struct ip_tunnel_6rd ip6rd; |
@@ -1139,16 +1139,15 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1139 | #ifdef CONFIG_IPV6_SIT_6RD | 1139 | #ifdef CONFIG_IPV6_SIT_6RD |
1140 | case SIOCGET6RD: | 1140 | case SIOCGET6RD: |
1141 | #endif | 1141 | #endif |
1142 | t = NULL; | ||
1143 | if (dev == sitn->fb_tunnel_dev) { | 1142 | if (dev == sitn->fb_tunnel_dev) { |
1144 | if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) { | 1143 | if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) { |
1145 | err = -EFAULT; | 1144 | err = -EFAULT; |
1146 | break; | 1145 | break; |
1147 | } | 1146 | } |
1148 | t = ipip6_tunnel_locate(net, &p, 0); | 1147 | t = ipip6_tunnel_locate(net, &p, 0); |
1148 | if (t == NULL) | ||
1149 | t = netdev_priv(dev); | ||
1149 | } | 1150 | } |
1150 | if (t == NULL) | ||
1151 | t = netdev_priv(dev); | ||
1152 | 1151 | ||
1153 | err = -EFAULT; | 1152 | err = -EFAULT; |
1154 | if (cmd == SIOCGETTUNNEL) { | 1153 | if (cmd == SIOCGETTUNNEL) { |
@@ -1244,9 +1243,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1244 | err = -EINVAL; | 1243 | err = -EINVAL; |
1245 | if (dev == sitn->fb_tunnel_dev) | 1244 | if (dev == sitn->fb_tunnel_dev) |
1246 | goto done; | 1245 | goto done; |
1247 | err = -ENOENT; | ||
1248 | if (!(t = netdev_priv(dev))) | ||
1249 | goto done; | ||
1250 | err = ipip6_tunnel_get_prl(t, ifr->ifr_ifru.ifru_data); | 1246 | err = ipip6_tunnel_get_prl(t, ifr->ifr_ifru.ifru_data); |
1251 | break; | 1247 | break; |
1252 | 1248 | ||
@@ -1262,9 +1258,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1262 | err = -EFAULT; | 1258 | err = -EFAULT; |
1263 | if (copy_from_user(&prl, ifr->ifr_ifru.ifru_data, sizeof(prl))) | 1259 | if (copy_from_user(&prl, ifr->ifr_ifru.ifru_data, sizeof(prl))) |
1264 | goto done; | 1260 | goto done; |
1265 | err = -ENOENT; | ||
1266 | if (!(t = netdev_priv(dev))) | ||
1267 | goto done; | ||
1268 | 1261 | ||
1269 | switch (cmd) { | 1262 | switch (cmd) { |
1270 | case SIOCDELPRL: | 1263 | case SIOCDELPRL: |
@@ -1292,8 +1285,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1292 | sizeof(ip6rd))) | 1285 | sizeof(ip6rd))) |
1293 | goto done; | 1286 | goto done; |
1294 | 1287 | ||
1295 | t = netdev_priv(dev); | ||
1296 | |||
1297 | if (cmd != SIOCDEL6RD) { | 1288 | if (cmd != SIOCDEL6RD) { |
1298 | err = ipip6_tunnel_update_6rd(t, &ip6rd); | 1289 | err = ipip6_tunnel_update_6rd(t, &ip6rd); |
1299 | if (err < 0) | 1290 | if (err < 0) |