diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/inetdevice.h | 6 | ||||
| -rw-r--r-- | include/linux/netdevice.h | 25 |
2 files changed, 27 insertions, 4 deletions
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index da05ab47ff2f..7009b0cdd06f 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h | |||
| @@ -70,13 +70,13 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev) | |||
| 70 | ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val)) | 70 | ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val)) |
| 71 | 71 | ||
| 72 | #define IN_DEV_ANDCONF(in_dev, attr) \ | 72 | #define IN_DEV_ANDCONF(in_dev, attr) \ |
| 73 | (IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr) && \ | 73 | (IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr) && \ |
| 74 | IN_DEV_CONF_GET((in_dev), attr)) | 74 | IN_DEV_CONF_GET((in_dev), attr)) |
| 75 | #define IN_DEV_ORCONF(in_dev, attr) \ | 75 | #define IN_DEV_ORCONF(in_dev, attr) \ |
| 76 | (IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr) || \ | 76 | (IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr) || \ |
| 77 | IN_DEV_CONF_GET((in_dev), attr)) | 77 | IN_DEV_CONF_GET((in_dev), attr)) |
| 78 | #define IN_DEV_MAXCONF(in_dev, attr) \ | 78 | #define IN_DEV_MAXCONF(in_dev, attr) \ |
| 79 | (max(IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr), \ | 79 | (max(IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr), \ |
| 80 | IN_DEV_CONF_GET((in_dev), attr))) | 80 | IN_DEV_CONF_GET((in_dev), attr))) |
| 81 | 81 | ||
| 82 | #define IN_DEV_FORWARD(in_dev) IN_DEV_CONF_GET((in_dev), FORWARDING) | 82 | #define IN_DEV_FORWARD(in_dev) IN_DEV_CONF_GET((in_dev), FORWARDING) |
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 | */ | ||
| 745 | static inline | ||
| 746 | struct 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 | |||
| 755 | static inline | ||
| 756 | void 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 | } |
