summaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 21:47:49 +0900
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-26 04:39:53 +0900
commitc346dca10840a874240c78efe3f39acf4312a1f2 (patch)
treec04cff20124eba5cc337cc5ec260ad2513eeb065 /include/linux/netdevice.h
parent7cbca67c073263c179f605bdbbdc565ab29d801d (diff)
downloadkernel-crypto-c346dca10840a874240c78efe3f39acf4312a1f2.tar.gz
kernel-crypto-c346dca10840a874240c78efe3f39acf4312a1f2.tar.xz
kernel-crypto-c346dca10840a874240c78efe3f39acf4312a1f2.zip
[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 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ced61f87660..d146be40f46 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -708,8 +708,10 @@ struct net_device
void (*poll_controller)(struct net_device *dev);
#endif
+#ifdef CONFIG_NET_NS
/* Network namespace this network device is inside */
struct net *nd_net;
+#endif
/* bridge stuff */
struct net_bridge_port *br_port;
@@ -737,6 +739,27 @@ struct net_device
#define NETDEV_ALIGN 32
#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
+/*
+ * Net namespace inlines
+ */
+static inline
+struct net *dev_net(const struct net_device *dev)
+{
+#ifdef CONFIG_NET_NS
+ return dev->nd_net;
+#else
+ return &init_net;
+#endif
+}
+
+static inline
+void dev_net_set(struct net_device *dev, const struct net *net)
+{
+#ifdef CONFIG_NET_NS
+ dev->nd_dev = net;
+#endif
+}
+
/**
* netdev_priv - access network device private data
* @dev: network device
@@ -813,7 +836,7 @@ static inline struct net_device *next_net_device(struct net_device *dev)
struct list_head *lh;
struct net *net;
- net = dev->nd_net;
+ net = dev_net(dev);
lh = dev->dev_list.next;
return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
}