diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-06-01 02:51:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-02 08:16:23 -0400 |
commit | c2d9ba9bce8d7323ca96f239e1f505c14d6244fb (patch) | |
tree | 7a184eefa2e48e6aa15cdf3aefb6ccf2fb834320 | |
parent | c6b20d941b08941bece53bc3d857beb1fb25fffc (diff) |
net: CONFIG_NET_NS reduction
Use read_pnet() and write_pnet() to reduce number of ifdef CONFIG_NET_NS
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/netdevice.h | 6 | ||||
-rw-r--r-- | include/net/cfg80211.h | 15 | ||||
-rw-r--r-- | include/net/genetlink.h | 15 | ||||
-rw-r--r-- | include/net/netfilter/nf_conntrack.h | 6 | ||||
-rw-r--r-- | include/net/sock.h | 10 | ||||
-rw-r--r-- | net/ipv6/addrlabel.c | 6 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_core.c | 8 |
7 files changed, 11 insertions, 55 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a24916156f4e..bd6b75317d5f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1087,11 +1087,7 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev, | |||
1087 | static inline | 1087 | static inline |
1088 | struct net *dev_net(const struct net_device *dev) | 1088 | struct net *dev_net(const struct net_device *dev) |
1089 | { | 1089 | { |
1090 | #ifdef CONFIG_NET_NS | 1090 | return read_pnet(&dev->nd_net); |
1091 | return dev->nd_net; | ||
1092 | #else | ||
1093 | return &init_net; | ||
1094 | #endif | ||
1095 | } | 1091 | } |
1096 | 1092 | ||
1097 | static inline | 1093 | static inline |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index b44a2e5321a3..e7ebeb8bdf71 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -1330,26 +1330,15 @@ struct wiphy { | |||
1330 | char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); | 1330 | char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); |
1331 | }; | 1331 | }; |
1332 | 1332 | ||
1333 | #ifdef CONFIG_NET_NS | ||
1334 | static inline struct net *wiphy_net(struct wiphy *wiphy) | ||
1335 | { | ||
1336 | return wiphy->_net; | ||
1337 | } | ||
1338 | |||
1339 | static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net) | ||
1340 | { | ||
1341 | wiphy->_net = net; | ||
1342 | } | ||
1343 | #else | ||
1344 | static inline struct net *wiphy_net(struct wiphy *wiphy) | 1333 | static inline struct net *wiphy_net(struct wiphy *wiphy) |
1345 | { | 1334 | { |
1346 | return &init_net; | 1335 | return read_pnet(&wiphy->_net); |
1347 | } | 1336 | } |
1348 | 1337 | ||
1349 | static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net) | 1338 | static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net) |
1350 | { | 1339 | { |
1340 | write_pnet(&wiphy->_net, net); | ||
1351 | } | 1341 | } |
1352 | #endif | ||
1353 | 1342 | ||
1354 | /** | 1343 | /** |
1355 | * wiphy_priv - return priv from wiphy | 1344 | * wiphy_priv - return priv from wiphy |
diff --git a/include/net/genetlink.h b/include/net/genetlink.h index eb551baafc04..f7dcd2c70412 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h | |||
@@ -68,26 +68,15 @@ struct genl_info { | |||
68 | #endif | 68 | #endif |
69 | }; | 69 | }; |
70 | 70 | ||
71 | #ifdef CONFIG_NET_NS | ||
72 | static inline struct net *genl_info_net(struct genl_info *info) | 71 | static inline struct net *genl_info_net(struct genl_info *info) |
73 | { | 72 | { |
74 | return info->_net; | 73 | return read_pnet(&info->_net); |
75 | } | 74 | } |
76 | 75 | ||
77 | static inline void genl_info_net_set(struct genl_info *info, struct net *net) | 76 | static inline void genl_info_net_set(struct genl_info *info, struct net *net) |
78 | { | 77 | { |
79 | info->_net = net; | 78 | write_pnet(&info->_net, net); |
80 | } | 79 | } |
81 | #else | ||
82 | static inline struct net *genl_info_net(struct genl_info *info) | ||
83 | { | ||
84 | return &init_net; | ||
85 | } | ||
86 | |||
87 | static inline void genl_info_net_set(struct genl_info *info, struct net *net) | ||
88 | { | ||
89 | } | ||
90 | #endif | ||
91 | 80 | ||
92 | /** | 81 | /** |
93 | * struct genl_ops - generic netlink operations | 82 | * struct genl_ops - generic netlink operations |
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index bde095f7e845..bbfdd9453087 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -152,11 +152,7 @@ extern struct net init_net; | |||
152 | 152 | ||
153 | static inline struct net *nf_ct_net(const struct nf_conn *ct) | 153 | static inline struct net *nf_ct_net(const struct nf_conn *ct) |
154 | { | 154 | { |
155 | #ifdef CONFIG_NET_NS | 155 | return read_pnet(&ct->ct_net); |
156 | return ct->ct_net; | ||
157 | #else | ||
158 | return &init_net; | ||
159 | #endif | ||
160 | } | 156 | } |
161 | 157 | ||
162 | /* Alter reply tuple (maybe alter helper). */ | 158 | /* Alter reply tuple (maybe alter helper). */ |
diff --git a/include/net/sock.h b/include/net/sock.h index ca241ea14875..3461e5d1e9ad 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -1724,19 +1724,13 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_e | |||
1724 | static inline | 1724 | static inline |
1725 | struct net *sock_net(const struct sock *sk) | 1725 | struct net *sock_net(const struct sock *sk) |
1726 | { | 1726 | { |
1727 | #ifdef CONFIG_NET_NS | 1727 | return read_pnet(&sk->sk_net); |
1728 | return sk->sk_net; | ||
1729 | #else | ||
1730 | return &init_net; | ||
1731 | #endif | ||
1732 | } | 1728 | } |
1733 | 1729 | ||
1734 | static inline | 1730 | static inline |
1735 | void sock_net_set(struct sock *sk, struct net *net) | 1731 | void sock_net_set(struct sock *sk, struct net *net) |
1736 | { | 1732 | { |
1737 | #ifdef CONFIG_NET_NS | 1733 | write_pnet(&sk->sk_net, net); |
1738 | sk->sk_net = net; | ||
1739 | #endif | ||
1740 | } | 1734 | } |
1741 | 1735 | ||
1742 | /* | 1736 | /* |
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c index 8c4348cb1950..f0e774cea386 100644 --- a/net/ipv6/addrlabel.c +++ b/net/ipv6/addrlabel.c | |||
@@ -53,11 +53,7 @@ static struct ip6addrlbl_table | |||
53 | static inline | 53 | static inline |
54 | struct net *ip6addrlbl_net(const struct ip6addrlbl_entry *lbl) | 54 | struct net *ip6addrlbl_net(const struct ip6addrlbl_entry *lbl) |
55 | { | 55 | { |
56 | #ifdef CONFIG_NET_NS | 56 | return read_pnet(&lbl->lbl_net); |
57 | return lbl->lbl_net; | ||
58 | #else | ||
59 | return &init_net; | ||
60 | #endif | ||
61 | } | 57 | } |
62 | 58 | ||
63 | /* | 59 | /* |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index eeeb8bc73982..77288980fae0 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -619,9 +619,7 @@ struct nf_conn *nf_conntrack_alloc(struct net *net, u16 zone, | |||
619 | ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev = NULL; | 619 | ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev = NULL; |
620 | /* Don't set timer yet: wait for confirmation */ | 620 | /* Don't set timer yet: wait for confirmation */ |
621 | setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct); | 621 | setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct); |
622 | #ifdef CONFIG_NET_NS | 622 | write_pnet(&ct->ct_net, net); |
623 | ct->ct_net = net; | ||
624 | #endif | ||
625 | #ifdef CONFIG_NF_CONNTRACK_ZONES | 623 | #ifdef CONFIG_NF_CONNTRACK_ZONES |
626 | if (zone) { | 624 | if (zone) { |
627 | struct nf_conntrack_zone *nf_ct_zone; | 625 | struct nf_conntrack_zone *nf_ct_zone; |
@@ -1363,9 +1361,7 @@ static int nf_conntrack_init_init_net(void) | |||
1363 | goto err_extend; | 1361 | goto err_extend; |
1364 | #endif | 1362 | #endif |
1365 | /* Set up fake conntrack: to never be deleted, not in any hashes */ | 1363 | /* Set up fake conntrack: to never be deleted, not in any hashes */ |
1366 | #ifdef CONFIG_NET_NS | 1364 | write_pnet(&nf_conntrack_untracked.ct_net, &init_net); |
1367 | nf_conntrack_untracked.ct_net = &init_net; | ||
1368 | #endif | ||
1369 | atomic_set(&nf_conntrack_untracked.ct_general.use, 1); | 1365 | atomic_set(&nf_conntrack_untracked.ct_general.use, 1); |
1370 | /* - and look it like as a confirmed connection */ | 1366 | /* - and look it like as a confirmed connection */ |
1371 | set_bit(IPS_CONFIRMED_BIT, &nf_conntrack_untracked.status); | 1367 | set_bit(IPS_CONFIRMED_BIT, &nf_conntrack_untracked.status); |