aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
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}