Skip to content

Commit

Permalink
net: Introduce read_pnet() and write_pnet() helpers
Browse files Browse the repository at this point in the history
This patch introduces two helpers that deal with reading and writing
struct net pointers in various network structures.

Their implementation depends on CONFIG_NET_NS

For symmetry, both functions work with "struct net **pnet".

Their usage should reduce the number of #ifdef CONFIG_NET_NS,
without adding many helpers for each network structure
that hold a "struct net *pointer"

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 12, 2008
1 parent 9eca0a4 commit 8f424b5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/net/net_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,24 @@ static inline void release_net(struct net *net)
}
#endif

#ifdef CONFIG_NET_NS

static inline void write_pnet(struct net **pnet, struct net *net)
{
*pnet = net;
}

static inline struct net *read_pnet(struct net * const *pnet)
{
return *pnet;
}

#else

#define write_pnet(pnet, net) do { (void)(net);} while (0)
#define read_pnet(pnet) (&init_net)

#endif

#define for_each_net(VAR) \
list_for_each_entry(VAR, &net_namespace_list, list)
Expand Down

0 comments on commit 8f424b5

Please sign in to comment.