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>
This commit is contained in:
parent
8c923ce219
commit
9aad77c3b5
@ -1127,8 +1127,8 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
struct ip_tunnel_parm p;
|
struct ip_tunnel_parm p;
|
||||||
struct ip_tunnel_prl prl;
|
struct ip_tunnel_prl prl;
|
||||||
struct ip_tunnel *t;
|
struct ip_tunnel *t = netdev_priv(dev);
|
||||||
struct net *net = dev_net(dev);
|
struct net *net = t->net;
|
||||||
struct sit_net *sitn = net_generic(net, sit_net_id);
|
struct sit_net *sitn = net_generic(net, sit_net_id);
|
||||||
#ifdef CONFIG_IPV6_SIT_6RD
|
#ifdef CONFIG_IPV6_SIT_6RD
|
||||||
struct ip_tunnel_6rd ip6rd;
|
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
|
#ifdef CONFIG_IPV6_SIT_6RD
|
||||||
case SIOCGET6RD:
|
case SIOCGET6RD:
|
||||||
#endif
|
#endif
|
||||||
t = NULL;
|
|
||||||
if (dev == sitn->fb_tunnel_dev) {
|
if (dev == sitn->fb_tunnel_dev) {
|
||||||
if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) {
|
if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) {
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
t = ipip6_tunnel_locate(net, &p, 0);
|
t = ipip6_tunnel_locate(net, &p, 0);
|
||||||
|
if (t == NULL)
|
||||||
|
t = netdev_priv(dev);
|
||||||
}
|
}
|
||||||
if (t == NULL)
|
|
||||||
t = netdev_priv(dev);
|
|
||||||
|
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
if (cmd == SIOCGETTUNNEL) {
|
if (cmd == SIOCGETTUNNEL) {
|
||||||
@ -1244,9 +1243,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
|
|||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
if (dev == sitn->fb_tunnel_dev)
|
if (dev == sitn->fb_tunnel_dev)
|
||||||
goto done;
|
goto done;
|
||||||
err = -ENOENT;
|
|
||||||
if (!(t = netdev_priv(dev)))
|
|
||||||
goto done;
|
|
||||||
err = ipip6_tunnel_get_prl(t, ifr->ifr_ifru.ifru_data);
|
err = ipip6_tunnel_get_prl(t, ifr->ifr_ifru.ifru_data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1262,9 +1258,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
|
|||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
if (copy_from_user(&prl, ifr->ifr_ifru.ifru_data, sizeof(prl)))
|
if (copy_from_user(&prl, ifr->ifr_ifru.ifru_data, sizeof(prl)))
|
||||||
goto done;
|
goto done;
|
||||||
err = -ENOENT;
|
|
||||||
if (!(t = netdev_priv(dev)))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SIOCDELPRL:
|
case SIOCDELPRL:
|
||||||
@ -1292,8 +1285,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
|
|||||||
sizeof(ip6rd)))
|
sizeof(ip6rd)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
t = netdev_priv(dev);
|
|
||||||
|
|
||||||
if (cmd != SIOCDEL6RD) {
|
if (cmd != SIOCDEL6RD) {
|
||||||
err = ipip6_tunnel_update_6rd(t, &ip6rd);
|
err = ipip6_tunnel_update_6rd(t, &ip6rd);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user