struct netpoll_info __rcu *npinfo;
#endif
-#ifdef CONFIG_NET_NS
- struct net *nd_net;
-#endif
+ possible_net_t nd_net;
/* mid-layer private */
union {
static inline
void dev_net_set(struct net_device *dev, struct net *net)
{
-#ifdef CONFIG_NET_NS
- dev->nd_net = net;
-#endif
+ write_pnet(&dev->nd_net, net);
}
static inline bool netdev_uses_dsa(struct net_device *dev)
const struct ieee80211_ht_cap *ht_capa_mod_mask;
const struct ieee80211_vht_cap *vht_capa_mod_mask;
-#ifdef CONFIG_NET_NS
/* the network namespace this phy lives in currently */
- struct net *_net;
-#endif
+ possible_net_t _net;
#ifdef CONFIG_CFG80211_WEXT
const struct iw_handler_def *wext;
struct genlmsghdr * genlhdr;
void * userhdr;
struct nlattr ** attrs;
-#ifdef CONFIG_NET_NS
- struct net * _net;
-#endif
+ possible_net_t _net;
void * user_ptr[2];
struct sock * dst_sk;
};
* ports are created in O(1) time? I thought so. ;-) -DaveM
*/
struct inet_bind_bucket {
-#ifdef CONFIG_NET_NS
- struct net *ib_net;
-#endif
+ possible_net_t ib_net;
unsigned short port;
signed char fastreuse;
signed char fastreuseport;
* Start with the most likely hit
* End with BUG
*/
- if (likely(skb->dev && skb->dev->nd_net))
+ if (likely(skb->dev && dev_net(skb->dev)))
return dev_net(skb->dev);
if (skb_dst(skb) && skb_dst(skb)->dev)
return dev_net(skb_dst(skb)->dev);
WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n",
__func__, __LINE__);
- if (likely(skb->sk && skb->sk->sk_net))
+ if (likely(skb->sk && sock_net(skb->sk)))
return sock_net(skb->sk);
pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
__func__, __LINE__);
#ifdef CONFIG_NET_NS
#ifdef CONFIG_IP_VS_DEBUG
/* Start with the most likely hit */
- if (likely(skb->sk && skb->sk->sk_net))
+ if (likely(skb->sk && sock_net(skb->sk)))
return sock_net(skb->sk);
WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n",
__func__, __LINE__);
- if (likely(skb->dev && skb->dev->nd_net))
+ if (likely(skb->dev && dev_net(skb->dev)))
return dev_net(skb->dev);
pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
__func__, __LINE__);
};
struct neigh_parms {
-#ifdef CONFIG_NET_NS
- struct net *net;
-#endif
+ possible_net_t net;
struct net_device *dev;
struct list_head list;
int (*neigh_setup)(struct neighbour *);
struct pneigh_entry {
struct pneigh_entry *next;
-#ifdef CONFIG_NET_NS
- struct net *net;
-#endif
+ possible_net_t net;
struct net_device *dev;
u8 flags;
u8 key[0];
#endif
+typedef struct {
#ifdef CONFIG_NET_NS
+ struct net *net;
+#endif
+} possible_net_t;
-static inline void write_pnet(struct net **pnet, struct net *net)
+static inline void write_pnet(possible_net_t *pnet, struct net *net)
{
- *pnet = net;
+#ifdef CONFIG_NET_NS
+ pnet->net = net;
+#endif
}
-static inline struct net *read_pnet(struct net * const *pnet)
+static inline struct net *read_pnet(const possible_net_t *pnet)
{
- return *pnet;
-}
-
+#ifdef CONFIG_NET_NS
+ return pnet->net;
#else
-
-#define write_pnet(pnet, net) do { (void)(net);} while (0)
-#define read_pnet(pnet) (&init_net)
-
+ return &init_net;
#endif
+}
#define for_each_net(VAR) \
list_for_each_entry(VAR, &net_namespace_list, list)
/* Timer function; drops refcnt when it goes off. */
struct timer_list timeout;
-#ifdef CONFIG_NET_NS
- struct net *ct_net;
-#endif
+ possible_net_t ct_net;
+
/* all members below initialized via memset */
u8 __nfct_init_offset[0];
struct hlist_nulls_node skc_portaddr_node;
};
struct proto *skc_prot;
-#ifdef CONFIG_NET_NS
- struct net *skc_net;
-#endif
+ possible_net_t skc_net;
#if IS_ENABLED(CONFIG_IPV6)
struct in6_addr skc_v6_daddr;
/* Full description of state of transformer. */
struct xfrm_state {
-#ifdef CONFIG_NET_NS
- struct net *xs_net;
-#endif
+ possible_net_t xs_net;
union {
struct hlist_node gclist;
struct hlist_node bydst;
};
struct xfrm_policy {
-#ifdef CONFIG_NET_NS
- struct net *xp_net;
-#endif
+ possible_net_t xp_net;
struct hlist_node bydst;
struct hlist_node byidx;
sin_server.sin_family = AF_INET;
sin_server.sin_addr.s_addr = in_aton(addr);
sin_server.sin_port = htons(opts.port);
- err = __sock_create(read_pnet(¤t->nsproxy->net_ns), PF_INET,
+ err = __sock_create(current->nsproxy->net_ns, PF_INET,
SOCK_STREAM, IPPROTO_TCP, &csocket, 1);
if (err) {
pr_err("%s (%d): problem creating socket\n",
sun_server.sun_family = PF_UNIX;
strcpy(sun_server.sun_path, addr);
- err = __sock_create(read_pnet(¤t->nsproxy->net_ns), PF_UNIX,
+ err = __sock_create(current->nsproxy->net_ns, PF_UNIX,
SOCK_STREAM, 0, &csocket, 1);
if (err < 0) {
pr_err("%s (%d): problem creating socket\n",
struct mr_table {
struct list_head list;
-#ifdef CONFIG_NET_NS
- struct net *net;
-#endif
+ possible_net_t net;
u32 id;
struct sock __rcu *mroute_sk;
struct timer_list ipmr_expire_timer;
* Policy Table
*/
struct ip6addrlbl_entry {
-#ifdef CONFIG_NET_NS
- struct net *lbl_net;
-#endif
+ possible_net_t lbl_net;
struct in6_addr prefix;
int prefixlen;
int ifindex;
newp->addrtype = addrtype;
newp->label = label;
INIT_HLIST_NODE(&newp->list);
-#ifdef CONFIG_NET_NS
- newp->lbl_net = net;
-#endif
+ write_pnet(&newp->lbl_net, net);
atomic_set(&newp->refcnt, 1);
return newp;
}
struct mr6_table {
struct list_head list;
-#ifdef CONFIG_NET_NS
- struct net *net;
-#endif
+ possible_net_t net;
u32 id;
struct sock *mroute6_sk;
struct timer_list ipmr_expire_timer;
/* Stats. */
struct dp_stats_percpu __percpu *stats_percpu;
-#ifdef CONFIG_NET_NS
/* Network namespace ref. */
- struct net *net;
-#endif
+ possible_net_t net;
u32 user_features;
};
#define PACKET_FANOUT_MAX 256
struct packet_fanout {
-#ifdef CONFIG_NET_NS
- struct net *net;
-#endif
+ possible_net_t net;
unsigned int num_members;
u16 id;
u8 type;