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

[NETNS]: Add netns parameter to inetdev_by_index.

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent da0e28cb
...@@ -133,7 +133,7 @@ extern struct net_device *ip_dev_find(__be32 addr); ...@@ -133,7 +133,7 @@ extern struct net_device *ip_dev_find(__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(unsigned int cmd, void __user *);
extern void devinet_init(void); extern void devinet_init(void);
extern struct in_device *inetdev_by_index(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);
extern __be32 inet_confirm_addr(struct in_device *in_dev, __be32 dst, __be32 local, int scope); extern __be32 inet_confirm_addr(struct in_device *in_dev, __be32 dst, __be32 local, int scope);
extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix, __be32 mask); extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix, __be32 mask);
......
...@@ -409,12 +409,12 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa) ...@@ -409,12 +409,12 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
return inet_insert_ifa(ifa); return inet_insert_ifa(ifa);
} }
struct in_device *inetdev_by_index(int ifindex) struct in_device *inetdev_by_index(struct net *net, int ifindex)
{ {
struct net_device *dev; struct net_device *dev;
struct in_device *in_dev = NULL; struct in_device *in_dev = NULL;
read_lock(&dev_base_lock); read_lock(&dev_base_lock);
dev = __dev_get_by_index(&init_net, ifindex); dev = __dev_get_by_index(net, ifindex);
if (dev) if (dev)
in_dev = in_dev_get(dev); in_dev = in_dev_get(dev);
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
...@@ -454,7 +454,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg ...@@ -454,7 +454,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
goto errout; goto errout;
ifm = nlmsg_data(nlh); ifm = nlmsg_data(nlh);
in_dev = inetdev_by_index(ifm->ifa_index); in_dev = inetdev_by_index(net, ifm->ifa_index);
if (in_dev == NULL) { if (in_dev == NULL) {
err = -ENODEV; err = -ENODEV;
goto errout; goto errout;
......
...@@ -583,7 +583,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, ...@@ -583,7 +583,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
if (nh->nh_flags&(RTNH_F_PERVASIVE|RTNH_F_ONLINK)) if (nh->nh_flags&(RTNH_F_PERVASIVE|RTNH_F_ONLINK))
return -EINVAL; return -EINVAL;
in_dev = inetdev_by_index(nh->nh_oif); in_dev = inetdev_by_index(&init_net, nh->nh_oif);
if (in_dev == NULL) if (in_dev == NULL)
return -ENODEV; return -ENODEV;
if (!(in_dev->dev->flags&IFF_UP)) { if (!(in_dev->dev->flags&IFF_UP)) {
......
...@@ -1389,7 +1389,7 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr) ...@@ -1389,7 +1389,7 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr)
struct in_device *idev = NULL; struct in_device *idev = NULL;
if (imr->imr_ifindex) { if (imr->imr_ifindex) {
idev = inetdev_by_index(imr->imr_ifindex); idev = inetdev_by_index(&init_net, imr->imr_ifindex);
if (idev) if (idev)
__in_dev_put(idev); __in_dev_put(idev);
return idev; return idev;
...@@ -2222,7 +2222,7 @@ void ip_mc_drop_socket(struct sock *sk) ...@@ -2222,7 +2222,7 @@ void ip_mc_drop_socket(struct sock *sk)
struct in_device *in_dev; struct in_device *in_dev;
inet->mc_list = iml->next; inet->mc_list = iml->next;
in_dev = inetdev_by_index(iml->multi.imr_ifindex); in_dev = inetdev_by_index(&init_net, iml->multi.imr_ifindex);
(void) ip_mc_leave_src(sk, iml, in_dev); (void) ip_mc_leave_src(sk, iml, in_dev);
if (in_dev != NULL) { if (in_dev != NULL) {
ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr); ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr);
......
...@@ -1193,7 +1193,8 @@ static int ipgre_close(struct net_device *dev) ...@@ -1193,7 +1193,8 @@ static int ipgre_close(struct net_device *dev)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) { if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) {
struct in_device *in_dev = inetdev_by_index(t->mlink); struct in_device *in_dev;
in_dev = inetdev_by_index(dev->nd_net, t->mlink);
if (in_dev) { if (in_dev) {
ip_mc_dec_group(in_dev, t->parms.iph.daddr); ip_mc_dec_group(in_dev, t->parms.iph.daddr);
in_dev_put(in_dev); in_dev_put(in_dev);
......
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