aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.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/core/dev.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/core/dev.c')
-rw-r--r--net/core/dev.c22
1 files changed, 11 insertions, 11 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 */
217static int list_netdevice(struct net_device *dev) 217static 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)