Commit e5b13cb1 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NETNS]: Process devinet ioctl in the correct namespace.

Add namespace parameter to devinet_ioctl and locate device inside it for
state changes.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 73b38711
...@@ -129,7 +129,7 @@ extern int unregister_inetaddr_notifier(struct notifier_block *nb); ...@@ -129,7 +129,7 @@ extern int unregister_inetaddr_notifier(struct notifier_block *nb);
extern struct net_device *ip_dev_find(struct net *net, __be32 addr); extern struct net_device *ip_dev_find(struct net *net, __be32 addr);
extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b); extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b);
extern int devinet_ioctl(unsigned int cmd, void __user *); extern int devinet_ioctl(struct net *net, unsigned int cmd, void __user *);
extern void devinet_init(void); extern void devinet_init(void);
extern struct in_device *inetdev_by_index(struct net *, int); extern struct in_device *inetdev_by_index(struct net *, int);
extern __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope); extern __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope);
......
...@@ -784,6 +784,7 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -784,6 +784,7 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
int err = 0; int err = 0;
struct net *net = sk->sk_net;
switch (cmd) { switch (cmd) {
case SIOCGSTAMP: case SIOCGSTAMP:
...@@ -795,12 +796,12 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -795,12 +796,12 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case SIOCADDRT: case SIOCADDRT:
case SIOCDELRT: case SIOCDELRT:
case SIOCRTMSG: case SIOCRTMSG:
err = ip_rt_ioctl(sk->sk_net, cmd, (void __user *)arg); err = ip_rt_ioctl(net, cmd, (void __user *)arg);
break; break;
case SIOCDARP: case SIOCDARP:
case SIOCGARP: case SIOCGARP:
case SIOCSARP: case SIOCSARP:
err = arp_ioctl(sk->sk_net, cmd, (void __user *)arg); err = arp_ioctl(net, cmd, (void __user *)arg);
break; break;
case SIOCGIFADDR: case SIOCGIFADDR:
case SIOCSIFADDR: case SIOCSIFADDR:
...@@ -813,7 +814,7 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -813,7 +814,7 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case SIOCSIFPFLAGS: case SIOCSIFPFLAGS:
case SIOCGIFPFLAGS: case SIOCGIFPFLAGS:
case SIOCSIFFLAGS: case SIOCSIFFLAGS:
err = devinet_ioctl(cmd, (void __user *)arg); err = devinet_ioctl(net, cmd, (void __user *)arg);
break; break;
default: default:
if (sk->sk_prot->ioctl) if (sk->sk_prot->ioctl)
......
...@@ -595,7 +595,7 @@ static __inline__ int inet_abc_len(__be32 addr) ...@@ -595,7 +595,7 @@ static __inline__ int inet_abc_len(__be32 addr)
} }
int devinet_ioctl(unsigned int cmd, void __user *arg) int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
{ {
struct ifreq ifr; struct ifreq ifr;
struct sockaddr_in sin_orig; struct sockaddr_in sin_orig;
...@@ -624,7 +624,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg) ...@@ -624,7 +624,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
*colon = 0; *colon = 0;
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
dev_load(&init_net, ifr.ifr_name); dev_load(net, ifr.ifr_name);
#endif #endif
switch (cmd) { switch (cmd) {
...@@ -665,7 +665,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg) ...@@ -665,7 +665,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
rtnl_lock(); rtnl_lock();
ret = -ENODEV; ret = -ENODEV;
if ((dev = __dev_get_by_name(&init_net, ifr.ifr_name)) == NULL) if ((dev = __dev_get_by_name(net, ifr.ifr_name)) == NULL)
goto done; goto done;
if (colon) if (colon)
......
...@@ -291,7 +291,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg) ...@@ -291,7 +291,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
mm_segment_t oldfs = get_fs(); mm_segment_t oldfs = get_fs();
set_fs(get_ds()); set_fs(get_ds());
res = devinet_ioctl(cmd, (struct ifreq __user *) arg); res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
set_fs(oldfs); set_fs(oldfs);
return res; return res;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment