aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrconf.c
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 08:47:49 -0400
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 15:39:53 -0400
commitc346dca10840a874240c78efe3f39acf4312a1f2 (patch)
treec04cff20124eba5cc337cc5ec260ad2513eeb065 /net/ipv6/addrconf.c
parent7cbca67c073263c179f605bdbbdc565ab29d801d (diff)
[NET] NETNS: Omit net_device->nd_net without CONFIG_NET_NS.
Introduce per-net_device inlines: dev_net(), dev_net_set(). Without CONFIG_NET_NS, no namespace other than &init_net exists. Let's explicitly define them to help compiler optimizations. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r--net/ipv6/addrconf.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 89954885dee1..d1de9ec74261 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -335,7 +335,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
335 335
336 rwlock_init(&ndev->lock); 336 rwlock_init(&ndev->lock);
337 ndev->dev = dev; 337 ndev->dev = dev;
338 memcpy(&ndev->cnf, dev->nd_net->ipv6.devconf_dflt, sizeof(ndev->cnf)); 338 memcpy(&ndev->cnf, dev_net(dev)->ipv6.devconf_dflt, sizeof(ndev->cnf));
339 ndev->cnf.mtu6 = dev->mtu; 339 ndev->cnf.mtu6 = dev->mtu;
340 ndev->cnf.sysctl = NULL; 340 ndev->cnf.sysctl = NULL;
341 ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl); 341 ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl);
@@ -561,7 +561,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
561 write_lock(&addrconf_hash_lock); 561 write_lock(&addrconf_hash_lock);
562 562
563 /* Ignore adding duplicate addresses on an interface */ 563 /* Ignore adding duplicate addresses on an interface */
564 if (ipv6_chk_same_addr(idev->dev->nd_net, addr, idev->dev)) { 564 if (ipv6_chk_same_addr(dev_net(idev->dev), addr, idev->dev)) {
565 ADBG(("ipv6_add_addr: already assigned\n")); 565 ADBG(("ipv6_add_addr: already assigned\n"));
566 err = -EEXIST; 566 err = -EEXIST;
567 goto out; 567 goto out;
@@ -751,7 +751,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
751 if ((ifp->flags & IFA_F_PERMANENT) && onlink < 1) { 751 if ((ifp->flags & IFA_F_PERMANENT) && onlink < 1) {
752 struct in6_addr prefix; 752 struct in6_addr prefix;
753 struct rt6_info *rt; 753 struct rt6_info *rt;
754 struct net *net = ifp->idev->dev->nd_net; 754 struct net *net = dev_net(ifp->idev->dev);
755 ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len); 755 ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len);
756 rt = rt6_lookup(net, &prefix, NULL, ifp->idev->dev->ifindex, 1); 756 rt = rt6_lookup(net, &prefix, NULL, ifp->idev->dev->ifindex, 1);
757 757
@@ -1044,7 +1044,7 @@ int ipv6_dev_get_saddr(struct net_device *dst_dev,
1044{ 1044{
1045 struct ipv6_saddr_score scores[2], 1045 struct ipv6_saddr_score scores[2],
1046 *score = &scores[0], *hiscore = &scores[1]; 1046 *score = &scores[0], *hiscore = &scores[1];
1047 struct net *net = dst_dev->nd_net; 1047 struct net *net = dev_net(dst_dev);
1048 struct ipv6_saddr_dst dst; 1048 struct ipv6_saddr_dst dst;
1049 struct net_device *dev; 1049 struct net_device *dev;
1050 int dst_type; 1050 int dst_type;
@@ -1217,7 +1217,7 @@ int ipv6_chk_addr(struct net *net, struct in6_addr *addr,
1217 1217
1218 read_lock_bh(&addrconf_hash_lock); 1218 read_lock_bh(&addrconf_hash_lock);
1219 for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) { 1219 for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
1220 if (ifp->idev->dev->nd_net != net) 1220 if (dev_net(ifp->idev->dev) != net)
1221 continue; 1221 continue;
1222 if (ipv6_addr_equal(&ifp->addr, addr) && 1222 if (ipv6_addr_equal(&ifp->addr, addr) &&
1223 !(ifp->flags&IFA_F_TENTATIVE)) { 1223 !(ifp->flags&IFA_F_TENTATIVE)) {
@@ -1239,7 +1239,7 @@ int ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
1239 u8 hash = ipv6_addr_hash(addr); 1239 u8 hash = ipv6_addr_hash(addr);
1240 1240
1241 for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) { 1241 for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
1242 if (ifp->idev->dev->nd_net != net) 1242 if (dev_net(ifp->idev->dev) != net)
1243 continue; 1243 continue;
1244 if (ipv6_addr_equal(&ifp->addr, addr)) { 1244 if (ipv6_addr_equal(&ifp->addr, addr)) {
1245 if (dev == NULL || ifp->idev->dev == dev) 1245 if (dev == NULL || ifp->idev->dev == dev)
@@ -1257,7 +1257,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, struct in6_addr *addr,
1257 1257
1258 read_lock_bh(&addrconf_hash_lock); 1258 read_lock_bh(&addrconf_hash_lock);
1259 for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) { 1259 for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
1260 if (ifp->idev->dev->nd_net != net) 1260 if (dev_net(ifp->idev->dev) != net)
1261 continue; 1261 continue;
1262 if (ipv6_addr_equal(&ifp->addr, addr)) { 1262 if (ipv6_addr_equal(&ifp->addr, addr)) {
1263 if (dev == NULL || ifp->idev->dev == dev || 1263 if (dev == NULL || ifp->idev->dev == dev ||
@@ -1559,7 +1559,7 @@ addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev,
1559 .fc_expires = expires, 1559 .fc_expires = expires,
1560 .fc_dst_len = plen, 1560 .fc_dst_len = plen,
1561 .fc_flags = RTF_UP | flags, 1561 .fc_flags = RTF_UP | flags,
1562 .fc_nlinfo.nl_net = dev->nd_net, 1562 .fc_nlinfo.nl_net = dev_net(dev),
1563 }; 1563 };
1564 1564
1565 ipv6_addr_copy(&cfg.fc_dst, pfx); 1565 ipv6_addr_copy(&cfg.fc_dst, pfx);
@@ -1586,7 +1586,7 @@ static void addrconf_add_mroute(struct net_device *dev)
1586 .fc_ifindex = dev->ifindex, 1586 .fc_ifindex = dev->ifindex,
1587 .fc_dst_len = 8, 1587 .fc_dst_len = 8,
1588 .fc_flags = RTF_UP, 1588 .fc_flags = RTF_UP,
1589 .fc_nlinfo.nl_net = dev->nd_net, 1589 .fc_nlinfo.nl_net = dev_net(dev),
1590 }; 1590 };
1591 1591
1592 ipv6_addr_set(&cfg.fc_dst, htonl(0xFF000000), 0, 0, 0); 1592 ipv6_addr_set(&cfg.fc_dst, htonl(0xFF000000), 0, 0, 0);
@@ -1603,7 +1603,7 @@ static void sit_route_add(struct net_device *dev)
1603 .fc_ifindex = dev->ifindex, 1603 .fc_ifindex = dev->ifindex,
1604 .fc_dst_len = 96, 1604 .fc_dst_len = 96,
1605 .fc_flags = RTF_UP | RTF_NONEXTHOP, 1605 .fc_flags = RTF_UP | RTF_NONEXTHOP,
1606 .fc_nlinfo.nl_net = dev->nd_net, 1606 .fc_nlinfo.nl_net = dev_net(dev),
1607 }; 1607 };
1608 1608
1609 /* prefix length - 96 bits "::d.d.d.d" */ 1609 /* prefix length - 96 bits "::d.d.d.d" */
@@ -1704,7 +1704,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
1704 1704
1705 if (pinfo->onlink) { 1705 if (pinfo->onlink) {
1706 struct rt6_info *rt; 1706 struct rt6_info *rt;
1707 rt = rt6_lookup(dev->nd_net, &pinfo->prefix, NULL, 1707 rt = rt6_lookup(dev_net(dev), &pinfo->prefix, NULL,
1708 dev->ifindex, 1); 1708 dev->ifindex, 1);
1709 1709
1710 if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) { 1710 if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) {
@@ -1748,7 +1748,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
1748 1748
1749ok: 1749ok:
1750 1750
1751 ifp = ipv6_get_ifaddr(dev->nd_net, &addr, dev, 1); 1751 ifp = ipv6_get_ifaddr(dev_net(dev), &addr, dev, 1);
1752 1752
1753 if (ifp == NULL && valid_lft) { 1753 if (ifp == NULL && valid_lft) {
1754 int max_addresses = in6_dev->cnf.max_addresses; 1754 int max_addresses = in6_dev->cnf.max_addresses;
@@ -2071,7 +2071,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2071 struct inet6_ifaddr * ifp; 2071 struct inet6_ifaddr * ifp;
2072 struct in6_addr addr; 2072 struct in6_addr addr;
2073 struct net_device *dev; 2073 struct net_device *dev;
2074 struct net *net = idev->dev->nd_net; 2074 struct net *net = dev_net(idev->dev);
2075 int scope; 2075 int scope;
2076 2076
2077 ASSERT_RTNL(); 2077 ASSERT_RTNL();
@@ -2261,7 +2261,7 @@ ipv6_inherit_linklocal(struct inet6_dev *idev, struct net_device *link_dev)
2261static void ip6_tnl_add_linklocal(struct inet6_dev *idev) 2261static void ip6_tnl_add_linklocal(struct inet6_dev *idev)
2262{ 2262{
2263 struct net_device *link_dev; 2263 struct net_device *link_dev;
2264 struct net *net = idev->dev->nd_net; 2264 struct net *net = dev_net(idev->dev);
2265 2265
2266 /* first try to inherit the link-local address from the link device */ 2266 /* first try to inherit the link-local address from the link device */
2267 if (idev->dev->iflink && 2267 if (idev->dev->iflink &&
@@ -2442,7 +2442,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2442{ 2442{
2443 struct inet6_dev *idev; 2443 struct inet6_dev *idev;
2444 struct inet6_ifaddr *ifa, **bifa; 2444 struct inet6_ifaddr *ifa, **bifa;
2445 struct net *net = dev->nd_net; 2445 struct net *net = dev_net(dev);
2446 int i; 2446 int i;
2447 2447
2448 ASSERT_RTNL(); 2448 ASSERT_RTNL();
@@ -2771,7 +2771,7 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq)
2771 for (state->bucket = 0; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) { 2771 for (state->bucket = 0; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) {
2772 ifa = inet6_addr_lst[state->bucket]; 2772 ifa = inet6_addr_lst[state->bucket];
2773 2773
2774 while (ifa && ifa->idev->dev->nd_net != net) 2774 while (ifa && dev_net(ifa->idev->dev) != net)
2775 ifa = ifa->lst_next; 2775 ifa = ifa->lst_next;
2776 if (ifa) 2776 if (ifa)
2777 break; 2777 break;
@@ -2787,7 +2787,7 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq, struct inet6_ifad
2787 ifa = ifa->lst_next; 2787 ifa = ifa->lst_next;
2788try_again: 2788try_again:
2789 if (ifa) { 2789 if (ifa) {
2790 if (ifa->idev->dev->nd_net != net) { 2790 if (dev_net(ifa->idev->dev) != net) {
2791 ifa = ifa->lst_next; 2791 ifa = ifa->lst_next;
2792 goto try_again; 2792 goto try_again;
2793 } 2793 }
@@ -2905,7 +2905,7 @@ int ipv6_chk_home_addr(struct net *net, struct in6_addr *addr)
2905 u8 hash = ipv6_addr_hash(addr); 2905 u8 hash = ipv6_addr_hash(addr);
2906 read_lock_bh(&addrconf_hash_lock); 2906 read_lock_bh(&addrconf_hash_lock);
2907 for (ifp = inet6_addr_lst[hash]; ifp; ifp = ifp->lst_next) { 2907 for (ifp = inet6_addr_lst[hash]; ifp; ifp = ifp->lst_next) {
2908 if (ifp->idev->dev->nd_net != net) 2908 if (dev_net(ifp->idev->dev) != net)
2909 continue; 2909 continue;
2910 if (ipv6_addr_cmp(&ifp->addr, addr) == 0 && 2910 if (ipv6_addr_cmp(&ifp->addr, addr) == 0 &&
2911 (ifp->flags & IFA_F_HOMEADDRESS)) { 2911 (ifp->flags & IFA_F_HOMEADDRESS)) {
@@ -3469,7 +3469,7 @@ errout:
3469static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa) 3469static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
3470{ 3470{
3471 struct sk_buff *skb; 3471 struct sk_buff *skb;
3472 struct net *net = ifa->idev->dev->nd_net; 3472 struct net *net = dev_net(ifa->idev->dev);
3473 int err = -ENOBUFS; 3473 int err = -ENOBUFS;
3474 3474
3475 skb = nlmsg_new(inet6_ifaddr_msgsize(), GFP_ATOMIC); 3475 skb = nlmsg_new(inet6_ifaddr_msgsize(), GFP_ATOMIC);
@@ -3675,7 +3675,7 @@ cont:
3675void inet6_ifinfo_notify(int event, struct inet6_dev *idev) 3675void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
3676{ 3676{
3677 struct sk_buff *skb; 3677 struct sk_buff *skb;
3678 struct net *net = idev->dev->nd_net; 3678 struct net *net = dev_net(idev->dev);
3679 int err = -ENOBUFS; 3679 int err = -ENOBUFS;
3680 3680
3681 skb = nlmsg_new(inet6_if_nlmsg_size(), GFP_ATOMIC); 3681 skb = nlmsg_new(inet6_if_nlmsg_size(), GFP_ATOMIC);
@@ -3745,7 +3745,7 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
3745 struct prefix_info *pinfo) 3745 struct prefix_info *pinfo)
3746{ 3746{
3747 struct sk_buff *skb; 3747 struct sk_buff *skb;
3748 struct net *net = idev->dev->nd_net; 3748 struct net *net = dev_net(idev->dev);
3749 int err = -ENOBUFS; 3749 int err = -ENOBUFS;
3750 3750
3751 skb = nlmsg_new(inet6_prefix_nlmsg_size(), GFP_ATOMIC); 3751 skb = nlmsg_new(inet6_prefix_nlmsg_size(), GFP_ATOMIC);
@@ -4157,7 +4157,7 @@ static void addrconf_sysctl_register(struct inet6_dev *idev)
4157 NET_IPV6_NEIGH, "ipv6", 4157 NET_IPV6_NEIGH, "ipv6",
4158 &ndisc_ifinfo_sysctl_change, 4158 &ndisc_ifinfo_sysctl_change,
4159 NULL); 4159 NULL);
4160 __addrconf_sysctl_register(idev->dev->nd_net, idev->dev->name, 4160 __addrconf_sysctl_register(dev_net(idev->dev), idev->dev->name,
4161 idev->dev->ifindex, idev, &idev->cnf); 4161 idev->dev->ifindex, idev, &idev->cnf);
4162} 4162}
4163 4163