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>
This commit is contained in:
Eric Dumazet 2010-06-01 06:51:19 +00:00 committed by David S. Miller
parent c6b20d941b
commit c2d9ba9bce
7 changed files with 11 additions and 55 deletions

View File

@ -1087,11 +1087,7 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev,
static inline static inline
struct net *dev_net(const struct net_device *dev) struct net *dev_net(const struct net_device *dev)
{ {
#ifdef CONFIG_NET_NS return read_pnet(&dev->nd_net);
return dev->nd_net;
#else
return &init_net;
#endif
} }
static inline static inline

View File

@ -1330,26 +1330,15 @@ struct wiphy {
char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
}; };
#ifdef CONFIG_NET_NS
static inline struct net *wiphy_net(struct wiphy *wiphy) static inline struct net *wiphy_net(struct wiphy *wiphy)
{ {
return wiphy->_net; return read_pnet(&wiphy->_net);
} }
static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net) static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
{ {
wiphy->_net = net; write_pnet(&wiphy->_net, net);
} }
#else
static inline struct net *wiphy_net(struct wiphy *wiphy)
{
return &init_net;
}
static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
{
}
#endif
/** /**
* wiphy_priv - return priv from wiphy * wiphy_priv - return priv from wiphy

View File

@ -68,26 +68,15 @@ struct genl_info {
#endif #endif
}; };
#ifdef CONFIG_NET_NS
static inline struct net *genl_info_net(struct genl_info *info) static inline struct net *genl_info_net(struct genl_info *info)
{ {
return info->_net; return read_pnet(&info->_net);
} }
static inline void genl_info_net_set(struct genl_info *info, struct net *net) static inline void genl_info_net_set(struct genl_info *info, struct net *net)
{ {
info->_net = net; write_pnet(&info->_net, net);
} }
#else
static inline struct net *genl_info_net(struct genl_info *info)
{
return &init_net;
}
static inline void genl_info_net_set(struct genl_info *info, struct net *net)
{
}
#endif
/** /**
* struct genl_ops - generic netlink operations * struct genl_ops - generic netlink operations

View File

@ -152,11 +152,7 @@ extern struct net init_net;
static inline struct net *nf_ct_net(const struct nf_conn *ct) static inline struct net *nf_ct_net(const struct nf_conn *ct)
{ {
#ifdef CONFIG_NET_NS return read_pnet(&ct->ct_net);
return ct->ct_net;
#else
return &init_net;
#endif
} }
/* Alter reply tuple (maybe alter helper). */ /* Alter reply tuple (maybe alter helper). */

View File

@ -1724,19 +1724,13 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_e
static inline static inline
struct net *sock_net(const struct sock *sk) struct net *sock_net(const struct sock *sk)
{ {
#ifdef CONFIG_NET_NS return read_pnet(&sk->sk_net);
return sk->sk_net;
#else
return &init_net;
#endif
} }
static inline static inline
void sock_net_set(struct sock *sk, struct net *net) void sock_net_set(struct sock *sk, struct net *net)
{ {
#ifdef CONFIG_NET_NS write_pnet(&sk->sk_net, net);
sk->sk_net = net;
#endif
} }
/* /*

View File

@ -53,11 +53,7 @@ static struct ip6addrlbl_table
static inline static inline
struct net *ip6addrlbl_net(const struct ip6addrlbl_entry *lbl) struct net *ip6addrlbl_net(const struct ip6addrlbl_entry *lbl)
{ {
#ifdef CONFIG_NET_NS return read_pnet(&lbl->lbl_net);
return lbl->lbl_net;
#else
return &init_net;
#endif
} }
/* /*

View File

@ -619,9 +619,7 @@ struct nf_conn *nf_conntrack_alloc(struct net *net, u16 zone,
ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev = NULL; ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev = NULL;
/* Don't set timer yet: wait for confirmation */ /* Don't set timer yet: wait for confirmation */
setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct); setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct);
#ifdef CONFIG_NET_NS write_pnet(&ct->ct_net, net);
ct->ct_net = net;
#endif
#ifdef CONFIG_NF_CONNTRACK_ZONES #ifdef CONFIG_NF_CONNTRACK_ZONES
if (zone) { if (zone) {
struct nf_conntrack_zone *nf_ct_zone; struct nf_conntrack_zone *nf_ct_zone;
@ -1363,9 +1361,7 @@ static int nf_conntrack_init_init_net(void)
goto err_extend; goto err_extend;
#endif #endif
/* Set up fake conntrack: to never be deleted, not in any hashes */ /* Set up fake conntrack: to never be deleted, not in any hashes */
#ifdef CONFIG_NET_NS write_pnet(&nf_conntrack_untracked.ct_net, &init_net);
nf_conntrack_untracked.ct_net = &init_net;
#endif
atomic_set(&nf_conntrack_untracked.ct_general.use, 1); atomic_set(&nf_conntrack_untracked.ct_general.use, 1);
/* - and look it like as a confirmed connection */ /* - and look it like as a confirmed connection */
set_bit(IPS_CONFIRMED_BIT, &nf_conntrack_untracked.status); set_bit(IPS_CONFIRMED_BIT, &nf_conntrack_untracked.status);