diff options
author | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2008-03-25 08:47:49 -0400 |
---|---|---|
committer | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2008-03-25 15:39:53 -0400 |
commit | c346dca10840a874240c78efe3f39acf4312a1f2 (patch) | |
tree | c04cff20124eba5cc337cc5ec260ad2513eeb065 /net/core | |
parent | 7cbca67c073263c179f605bdbbdc565ab29d801d (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/core')
-rw-r--r-- | net/core/dev.c | 22 | ||||
-rw-r--r-- | net/core/dst.c | 2 | ||||
-rw-r--r-- | net/core/fib_rules.c | 2 | ||||
-rw-r--r-- | net/core/neighbour.c | 12 | ||||
-rw-r--r-- | net/core/pktgen.c | 2 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 4 |
6 files changed, 22 insertions, 22 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index aebd08606040..812534828914 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -216,7 +216,7 @@ static inline struct hlist_head *dev_index_hash(struct net *net, int ifindex) | |||
216 | /* Device list insertion */ | 216 | /* Device list insertion */ |
217 | static int list_netdevice(struct net_device *dev) | 217 | static int list_netdevice(struct net_device *dev) |
218 | { | 218 | { |
219 | struct net *net = dev->nd_net; | 219 | struct net *net = dev_net(dev); |
220 | 220 | ||
221 | ASSERT_RTNL(); | 221 | ASSERT_RTNL(); |
222 | 222 | ||
@@ -852,8 +852,8 @@ int dev_alloc_name(struct net_device *dev, const char *name) | |||
852 | struct net *net; | 852 | struct net *net; |
853 | int ret; | 853 | int ret; |
854 | 854 | ||
855 | BUG_ON(!dev->nd_net); | 855 | BUG_ON(!dev_net(dev)); |
856 | net = dev->nd_net; | 856 | net = dev_net(dev); |
857 | ret = __dev_alloc_name(net, name, buf); | 857 | ret = __dev_alloc_name(net, name, buf); |
858 | if (ret >= 0) | 858 | if (ret >= 0) |
859 | strlcpy(dev->name, buf, IFNAMSIZ); | 859 | strlcpy(dev->name, buf, IFNAMSIZ); |
@@ -877,9 +877,9 @@ int dev_change_name(struct net_device *dev, char *newname) | |||
877 | struct net *net; | 877 | struct net *net; |
878 | 878 | ||
879 | ASSERT_RTNL(); | 879 | ASSERT_RTNL(); |
880 | BUG_ON(!dev->nd_net); | 880 | BUG_ON(!dev_net(dev)); |
881 | 881 | ||
882 | net = dev->nd_net; | 882 | net = dev_net(dev); |
883 | if (dev->flags & IFF_UP) | 883 | if (dev->flags & IFF_UP) |
884 | return -EBUSY; | 884 | return -EBUSY; |
885 | 885 | ||
@@ -2615,7 +2615,7 @@ static int ptype_seq_show(struct seq_file *seq, void *v) | |||
2615 | 2615 | ||
2616 | if (v == SEQ_START_TOKEN) | 2616 | if (v == SEQ_START_TOKEN) |
2617 | seq_puts(seq, "Type Device Function\n"); | 2617 | seq_puts(seq, "Type Device Function\n"); |
2618 | else if (pt->dev == NULL || pt->dev->nd_net == seq_file_net(seq)) { | 2618 | else if (pt->dev == NULL || dev_net(pt->dev) == seq_file_net(seq)) { |
2619 | if (pt->type == htons(ETH_P_ALL)) | 2619 | if (pt->type == htons(ETH_P_ALL)) |
2620 | seq_puts(seq, "ALL "); | 2620 | seq_puts(seq, "ALL "); |
2621 | else | 2621 | else |
@@ -3689,8 +3689,8 @@ int register_netdevice(struct net_device *dev) | |||
3689 | 3689 | ||
3690 | /* When net_device's are persistent, this will be fatal. */ | 3690 | /* When net_device's are persistent, this will be fatal. */ |
3691 | BUG_ON(dev->reg_state != NETREG_UNINITIALIZED); | 3691 | BUG_ON(dev->reg_state != NETREG_UNINITIALIZED); |
3692 | BUG_ON(!dev->nd_net); | 3692 | BUG_ON(!dev_net(dev)); |
3693 | net = dev->nd_net; | 3693 | net = dev_net(dev); |
3694 | 3694 | ||
3695 | spin_lock_init(&dev->queue_lock); | 3695 | spin_lock_init(&dev->queue_lock); |
3696 | spin_lock_init(&dev->_xmit_lock); | 3696 | spin_lock_init(&dev->_xmit_lock); |
@@ -4011,7 +4011,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, | |||
4011 | dev = (struct net_device *) | 4011 | dev = (struct net_device *) |
4012 | (((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST); | 4012 | (((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST); |
4013 | dev->padded = (char *)dev - (char *)p; | 4013 | dev->padded = (char *)dev - (char *)p; |
4014 | dev->nd_net = &init_net; | 4014 | dev_net_set(dev, &init_net); |
4015 | 4015 | ||
4016 | if (sizeof_priv) { | 4016 | if (sizeof_priv) { |
4017 | dev->priv = ((char *)dev + | 4017 | dev->priv = ((char *)dev + |
@@ -4136,7 +4136,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char | |||
4136 | 4136 | ||
4137 | /* Get out if there is nothing todo */ | 4137 | /* Get out if there is nothing todo */ |
4138 | err = 0; | 4138 | err = 0; |
4139 | if (dev->nd_net == net) | 4139 | if (dev_net(dev) == net) |
4140 | goto out; | 4140 | goto out; |
4141 | 4141 | ||
4142 | /* Pick the destination device name, and ensure | 4142 | /* Pick the destination device name, and ensure |
@@ -4187,7 +4187,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char | |||
4187 | dev_addr_discard(dev); | 4187 | dev_addr_discard(dev); |
4188 | 4188 | ||
4189 | /* Actually switch the network namespace */ | 4189 | /* Actually switch the network namespace */ |
4190 | dev->nd_net = net; | 4190 | dev_net_set(dev, net); |
4191 | 4191 | ||
4192 | /* Assign the new device name */ | 4192 | /* Assign the new device name */ |
4193 | if (destname != dev->name) | 4193 | if (destname != dev->name) |
diff --git a/net/core/dst.c b/net/core/dst.c index 3a01a819ba47..694cd2a3f6d2 100644 --- a/net/core/dst.c +++ b/net/core/dst.c | |||
@@ -279,7 +279,7 @@ static inline void dst_ifdown(struct dst_entry *dst, struct net_device *dev, | |||
279 | if (!unregister) { | 279 | if (!unregister) { |
280 | dst->input = dst->output = dst_discard; | 280 | dst->input = dst->output = dst_discard; |
281 | } else { | 281 | } else { |
282 | dst->dev = dst->dev->nd_net->loopback_dev; | 282 | dst->dev = dev_net(dst->dev)->loopback_dev; |
283 | dev_hold(dst->dev); | 283 | dev_hold(dst->dev); |
284 | dev_put(dev); | 284 | dev_put(dev); |
285 | if (dst->neighbour && dst->neighbour->dev == dev) { | 285 | if (dst->neighbour && dst->neighbour->dev == dev) { |
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 42ccaf5b8509..942be93a2eb0 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c | |||
@@ -618,7 +618,7 @@ static int fib_rules_event(struct notifier_block *this, unsigned long event, | |||
618 | void *ptr) | 618 | void *ptr) |
619 | { | 619 | { |
620 | struct net_device *dev = ptr; | 620 | struct net_device *dev = ptr; |
621 | struct net *net = dev->nd_net; | 621 | struct net *net = dev_net(dev); |
622 | struct fib_rules_ops *ops; | 622 | struct fib_rules_ops *ops; |
623 | 623 | ||
624 | ASSERT_RTNL(); | 624 | ASSERT_RTNL(); |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 23c0a10c0c37..c978bd1cd659 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -388,7 +388,7 @@ struct neighbour *neigh_lookup_nodev(struct neigh_table *tbl, struct net *net, | |||
388 | hash_val = tbl->hash(pkey, NULL); | 388 | hash_val = tbl->hash(pkey, NULL); |
389 | for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) { | 389 | for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) { |
390 | if (!memcmp(n->primary_key, pkey, key_len) && | 390 | if (!memcmp(n->primary_key, pkey, key_len) && |
391 | (net == n->dev->nd_net)) { | 391 | dev_net(n->dev) == net) { |
392 | neigh_hold(n); | 392 | neigh_hold(n); |
393 | NEIGH_CACHE_STAT_INC(tbl, hits); | 393 | NEIGH_CACHE_STAT_INC(tbl, hits); |
394 | break; | 394 | break; |
@@ -1298,7 +1298,7 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev, | |||
1298 | struct neigh_parms *p, *ref; | 1298 | struct neigh_parms *p, *ref; |
1299 | struct net *net; | 1299 | struct net *net; |
1300 | 1300 | ||
1301 | net = dev->nd_net; | 1301 | net = dev_net(dev); |
1302 | ref = lookup_neigh_params(tbl, net, 0); | 1302 | ref = lookup_neigh_params(tbl, net, 0); |
1303 | if (!ref) | 1303 | if (!ref) |
1304 | return NULL; | 1304 | return NULL; |
@@ -2050,7 +2050,7 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, | |||
2050 | s_idx = 0; | 2050 | s_idx = 0; |
2051 | for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) { | 2051 | for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) { |
2052 | int lidx; | 2052 | int lidx; |
2053 | if (n->dev->nd_net != net) | 2053 | if (dev_net(n->dev) != net) |
2054 | continue; | 2054 | continue; |
2055 | lidx = idx++; | 2055 | lidx = idx++; |
2056 | if (lidx < s_idx) | 2056 | if (lidx < s_idx) |
@@ -2155,7 +2155,7 @@ static struct neighbour *neigh_get_first(struct seq_file *seq) | |||
2155 | n = tbl->hash_buckets[bucket]; | 2155 | n = tbl->hash_buckets[bucket]; |
2156 | 2156 | ||
2157 | while (n) { | 2157 | while (n) { |
2158 | if (n->dev->nd_net != net) | 2158 | if (dev_net(n->dev) != net) |
2159 | goto next; | 2159 | goto next; |
2160 | if (state->neigh_sub_iter) { | 2160 | if (state->neigh_sub_iter) { |
2161 | loff_t fakep = 0; | 2161 | loff_t fakep = 0; |
@@ -2198,7 +2198,7 @@ static struct neighbour *neigh_get_next(struct seq_file *seq, | |||
2198 | 2198 | ||
2199 | while (1) { | 2199 | while (1) { |
2200 | while (n) { | 2200 | while (n) { |
2201 | if (n->dev->nd_net != net) | 2201 | if (dev_net(n->dev) != net) |
2202 | goto next; | 2202 | goto next; |
2203 | if (state->neigh_sub_iter) { | 2203 | if (state->neigh_sub_iter) { |
2204 | void *v = state->neigh_sub_iter(state, n, pos); | 2204 | void *v = state->neigh_sub_iter(state, n, pos); |
@@ -2482,7 +2482,7 @@ static inline size_t neigh_nlmsg_size(void) | |||
2482 | 2482 | ||
2483 | static void __neigh_notify(struct neighbour *n, int type, int flags) | 2483 | static void __neigh_notify(struct neighbour *n, int type, int flags) |
2484 | { | 2484 | { |
2485 | struct net *net = n->dev->nd_net; | 2485 | struct net *net = dev_net(n->dev); |
2486 | struct sk_buff *skb; | 2486 | struct sk_buff *skb; |
2487 | int err = -ENOBUFS; | 2487 | int err = -ENOBUFS; |
2488 | 2488 | ||
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 20e63b302ba6..a803b442234c 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -1874,7 +1874,7 @@ static int pktgen_device_event(struct notifier_block *unused, | |||
1874 | { | 1874 | { |
1875 | struct net_device *dev = ptr; | 1875 | struct net_device *dev = ptr; |
1876 | 1876 | ||
1877 | if (dev->nd_net != &init_net) | 1877 | if (dev_net(dev) != &init_net) |
1878 | return NOTIFY_DONE; | 1878 | return NOTIFY_DONE; |
1879 | 1879 | ||
1880 | /* It is OK that we do not hold the group lock right now, | 1880 | /* It is OK that we do not hold the group lock right now, |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 2bd9c5f7627d..09250a0800f6 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -972,7 +972,7 @@ struct net_device *rtnl_create_link(struct net *net, char *ifname, | |||
972 | goto err_free; | 972 | goto err_free; |
973 | } | 973 | } |
974 | 974 | ||
975 | dev->nd_net = net; | 975 | dev_net_set(dev, net); |
976 | dev->rtnl_link_ops = ops; | 976 | dev->rtnl_link_ops = ops; |
977 | 977 | ||
978 | if (tb[IFLA_MTU]) | 978 | if (tb[IFLA_MTU]) |
@@ -1198,7 +1198,7 @@ static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb) | |||
1198 | 1198 | ||
1199 | void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change) | 1199 | void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change) |
1200 | { | 1200 | { |
1201 | struct net *net = dev->nd_net; | 1201 | struct net *net = dev_net(dev); |
1202 | struct sk_buff *skb; | 1202 | struct sk_buff *skb; |
1203 | int err = -ENOBUFS; | 1203 | int err = -ENOBUFS; |
1204 | 1204 | ||