diff options
Diffstat (limited to 'net/ipv4/devinet.c')
-rw-r--r-- | net/ipv4/devinet.c | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 87490f7bb0f7..6848e4760f34 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -165,7 +165,7 @@ static struct in_device *inetdev_init(struct net_device *dev) | |||
165 | if (!in_dev) | 165 | if (!in_dev) |
166 | goto out; | 166 | goto out; |
167 | INIT_RCU_HEAD(&in_dev->rcu_head); | 167 | INIT_RCU_HEAD(&in_dev->rcu_head); |
168 | memcpy(&in_dev->cnf, dev->nd_net->ipv4.devconf_dflt, | 168 | memcpy(&in_dev->cnf, dev_net(dev)->ipv4.devconf_dflt, |
169 | sizeof(in_dev->cnf)); | 169 | sizeof(in_dev->cnf)); |
170 | in_dev->cnf.sysctl = NULL; | 170 | in_dev->cnf.sysctl = NULL; |
171 | in_dev->dev = dev; | 171 | in_dev->dev = dev; |
@@ -437,7 +437,7 @@ struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix, | |||
437 | 437 | ||
438 | static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 438 | static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
439 | { | 439 | { |
440 | struct net *net = skb->sk->sk_net; | 440 | struct net *net = sock_net(skb->sk); |
441 | struct nlattr *tb[IFA_MAX+1]; | 441 | struct nlattr *tb[IFA_MAX+1]; |
442 | struct in_device *in_dev; | 442 | struct in_device *in_dev; |
443 | struct ifaddrmsg *ifm; | 443 | struct ifaddrmsg *ifm; |
@@ -446,9 +446,6 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg | |||
446 | 446 | ||
447 | ASSERT_RTNL(); | 447 | ASSERT_RTNL(); |
448 | 448 | ||
449 | if (net != &init_net) | ||
450 | return -EINVAL; | ||
451 | |||
452 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv4_policy); | 449 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv4_policy); |
453 | if (err < 0) | 450 | if (err < 0) |
454 | goto errout; | 451 | goto errout; |
@@ -555,14 +552,11 @@ errout: | |||
555 | 552 | ||
556 | static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 553 | static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
557 | { | 554 | { |
558 | struct net *net = skb->sk->sk_net; | 555 | struct net *net = sock_net(skb->sk); |
559 | struct in_ifaddr *ifa; | 556 | struct in_ifaddr *ifa; |
560 | 557 | ||
561 | ASSERT_RTNL(); | 558 | ASSERT_RTNL(); |
562 | 559 | ||
563 | if (net != &init_net) | ||
564 | return -EINVAL; | ||
565 | |||
566 | ifa = rtm_to_ifaddr(net, nlh); | 560 | ifa = rtm_to_ifaddr(net, nlh); |
567 | if (IS_ERR(ifa)) | 561 | if (IS_ERR(ifa)) |
568 | return PTR_ERR(ifa); | 562 | return PTR_ERR(ifa); |
@@ -595,7 +589,7 @@ static __inline__ int inet_abc_len(__be32 addr) | |||
595 | } | 589 | } |
596 | 590 | ||
597 | 591 | ||
598 | int devinet_ioctl(unsigned int cmd, void __user *arg) | 592 | int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg) |
599 | { | 593 | { |
600 | struct ifreq ifr; | 594 | struct ifreq ifr; |
601 | struct sockaddr_in sin_orig; | 595 | struct sockaddr_in sin_orig; |
@@ -624,7 +618,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg) | |||
624 | *colon = 0; | 618 | *colon = 0; |
625 | 619 | ||
626 | #ifdef CONFIG_KMOD | 620 | #ifdef CONFIG_KMOD |
627 | dev_load(&init_net, ifr.ifr_name); | 621 | dev_load(net, ifr.ifr_name); |
628 | #endif | 622 | #endif |
629 | 623 | ||
630 | switch (cmd) { | 624 | switch (cmd) { |
@@ -665,7 +659,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg) | |||
665 | rtnl_lock(); | 659 | rtnl_lock(); |
666 | 660 | ||
667 | ret = -ENODEV; | 661 | ret = -ENODEV; |
668 | if ((dev = __dev_get_by_name(&init_net, ifr.ifr_name)) == NULL) | 662 | if ((dev = __dev_get_by_name(net, ifr.ifr_name)) == NULL) |
669 | goto done; | 663 | goto done; |
670 | 664 | ||
671 | if (colon) | 665 | if (colon) |
@@ -878,6 +872,7 @@ __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope) | |||
878 | { | 872 | { |
879 | __be32 addr = 0; | 873 | __be32 addr = 0; |
880 | struct in_device *in_dev; | 874 | struct in_device *in_dev; |
875 | struct net *net = dev_net(dev); | ||
881 | 876 | ||
882 | rcu_read_lock(); | 877 | rcu_read_lock(); |
883 | in_dev = __in_dev_get_rcu(dev); | 878 | in_dev = __in_dev_get_rcu(dev); |
@@ -906,7 +901,7 @@ no_in_dev: | |||
906 | */ | 901 | */ |
907 | read_lock(&dev_base_lock); | 902 | read_lock(&dev_base_lock); |
908 | rcu_read_lock(); | 903 | rcu_read_lock(); |
909 | for_each_netdev(&init_net, dev) { | 904 | for_each_netdev(net, dev) { |
910 | if ((in_dev = __in_dev_get_rcu(dev)) == NULL) | 905 | if ((in_dev = __in_dev_get_rcu(dev)) == NULL) |
911 | continue; | 906 | continue; |
912 | 907 | ||
@@ -979,7 +974,7 @@ __be32 inet_confirm_addr(struct in_device *in_dev, | |||
979 | if (scope != RT_SCOPE_LINK) | 974 | if (scope != RT_SCOPE_LINK) |
980 | return confirm_addr_indev(in_dev, dst, local, scope); | 975 | return confirm_addr_indev(in_dev, dst, local, scope); |
981 | 976 | ||
982 | net = in_dev->dev->nd_net; | 977 | net = dev_net(in_dev->dev); |
983 | read_lock(&dev_base_lock); | 978 | read_lock(&dev_base_lock); |
984 | rcu_read_lock(); | 979 | rcu_read_lock(); |
985 | for_each_netdev(net, dev) { | 980 | for_each_netdev(net, dev) { |
@@ -1045,9 +1040,6 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1045 | struct net_device *dev = ptr; | 1040 | struct net_device *dev = ptr; |
1046 | struct in_device *in_dev = __in_dev_get_rtnl(dev); | 1041 | struct in_device *in_dev = __in_dev_get_rtnl(dev); |
1047 | 1042 | ||
1048 | if (dev->nd_net != &init_net) | ||
1049 | return NOTIFY_DONE; | ||
1050 | |||
1051 | ASSERT_RTNL(); | 1043 | ASSERT_RTNL(); |
1052 | 1044 | ||
1053 | if (!in_dev) { | 1045 | if (!in_dev) { |
@@ -1166,16 +1158,13 @@ nla_put_failure: | |||
1166 | 1158 | ||
1167 | static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) | 1159 | static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) |
1168 | { | 1160 | { |
1169 | struct net *net = skb->sk->sk_net; | 1161 | struct net *net = sock_net(skb->sk); |
1170 | int idx, ip_idx; | 1162 | int idx, ip_idx; |
1171 | struct net_device *dev; | 1163 | struct net_device *dev; |
1172 | struct in_device *in_dev; | 1164 | struct in_device *in_dev; |
1173 | struct in_ifaddr *ifa; | 1165 | struct in_ifaddr *ifa; |
1174 | int s_ip_idx, s_idx = cb->args[0]; | 1166 | int s_ip_idx, s_idx = cb->args[0]; |
1175 | 1167 | ||
1176 | if (net != &init_net) | ||
1177 | return 0; | ||
1178 | |||
1179 | s_ip_idx = ip_idx = cb->args[1]; | 1168 | s_ip_idx = ip_idx = cb->args[1]; |
1180 | idx = 0; | 1169 | idx = 0; |
1181 | for_each_netdev(net, dev) { | 1170 | for_each_netdev(net, dev) { |
@@ -1214,7 +1203,7 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh, | |||
1214 | int err = -ENOBUFS; | 1203 | int err = -ENOBUFS; |
1215 | struct net *net; | 1204 | struct net *net; |
1216 | 1205 | ||
1217 | net = ifa->ifa_dev->dev->nd_net; | 1206 | net = dev_net(ifa->ifa_dev->dev); |
1218 | skb = nlmsg_new(inet_nlmsg_size(), GFP_KERNEL); | 1207 | skb = nlmsg_new(inet_nlmsg_size(), GFP_KERNEL); |
1219 | if (skb == NULL) | 1208 | if (skb == NULL) |
1220 | goto errout; | 1209 | goto errout; |
@@ -1528,7 +1517,7 @@ static void devinet_sysctl_register(struct in_device *idev) | |||
1528 | { | 1517 | { |
1529 | neigh_sysctl_register(idev->dev, idev->arp_parms, NET_IPV4, | 1518 | neigh_sysctl_register(idev->dev, idev->arp_parms, NET_IPV4, |
1530 | NET_IPV4_NEIGH, "ipv4", NULL, NULL); | 1519 | NET_IPV4_NEIGH, "ipv4", NULL, NULL); |
1531 | __devinet_sysctl_register(idev->dev->nd_net, idev->dev->name, | 1520 | __devinet_sysctl_register(dev_net(idev->dev), idev->dev->name, |
1532 | idev->dev->ifindex, &idev->cnf); | 1521 | idev->dev->ifindex, &idev->cnf); |
1533 | } | 1522 | } |
1534 | 1523 | ||