aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
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 /include/linux/netdevice.h
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 '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 ced61f87660e..d146be40f46c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -708,8 +708,10 @@ struct net_device
708 void (*poll_controller)(struct net_device *dev); 708 void (*poll_controller)(struct net_device *dev);
709#endif 709#endif
710 710
711#ifdef CONFIG_NET_NS
711 /* Network namespace this network device is inside */ 712 /* Network namespace this network device is inside */
712 struct net *nd_net; 713 struct net *nd_net;
714#endif
713 715
714 /* bridge stuff */ 716 /* bridge stuff */
715 struct net_bridge_port *br_port; 717 struct net_bridge_port *br_port;
@@ -737,6 +739,27 @@ struct net_device
737#define NETDEV_ALIGN 32 739#define NETDEV_ALIGN 32
738#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) 740#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
739 741
742/*
743 * Net namespace inlines
744 */
745static inline
746struct net *dev_net(const struct net_device *dev)
747{
748#ifdef CONFIG_NET_NS
749 return dev->nd_net;
750#else
751 return &init_net;
752#endif
753}
754
755static inline
756void dev_net_set(struct net_device *dev, const struct net *net)
757{
758#ifdef CONFIG_NET_NS
759 dev->nd_dev = net;
760#endif
761}
762
740/** 763/**
741 * netdev_priv - access network device private data 764 * netdev_priv - access network device private data
742 * @dev: network device 765 * @dev: network device
@@ -813,7 +836,7 @@ static inline struct net_device *next_net_device(struct net_device *dev)
813 struct list_head *lh; 836 struct list_head *lh;
814 struct net *net; 837 struct net *net;
815 838
816 net = dev->nd_net; 839 net = dev_net(dev);
817 lh = dev->dev_list.next; 840 lh = dev->dev_list.next;
818 return lh == &net->dev_base_head ? NULL : net_device_entry(lh); 841 return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
819} 842}