From: Eric Dumazet <dada1@cosmosbay.com>
To: David Miller <davem@davemloft.net>
Cc: adobriyan@gmail.com, netdev@vger.kernel.org
Subject: [PATCH] nets: Introduce read_pnet() and write_pnet() helpers
Date: Wed, 12 Nov 2008 07:20:46 +0100 [thread overview]
Message-ID: <491A75BE.1010907@cosmosbay.com> (raw)
In-Reply-To: <20081111.164554.143409564.davem@davemloft.net>
[-- Attachment #1: Type: text/plain, Size: 743 bytes --]
So in this version I splited the patches to make them clear
I removed the DECLARE_PNET since it was apparently using too
many capital letters :)
Thanks
[PATCH] nets: Introduce read_pnet() and write_pnet() helpers
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>
---
include/net/net_namespace.h | 18 ++++++++++++++++++
1 files changed, 18 insertions(+)
[-- Attachment #2: pnet.patch --]
[-- Type: text/plain, Size: 657 bytes --]
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 700c53a..3195577 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -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)
next prev parent reply other threads:[~2008-11-12 6:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-07 15:44 [PATCH] net: introduce read_pnet() and write_pnet() functions Eric Dumazet
2008-11-07 17:41 ` Alexey Dobriyan
2008-11-07 17:49 ` Eric Dumazet
2008-11-07 18:07 ` Alexey Dobriyan
2008-11-11 0:44 ` David Miller
2008-11-11 11:08 ` [PATCH] net: #ifdef inet_bind_bucket::ib_net Alexey Dobriyan
2008-11-11 11:19 ` [PATCH v2] " Alexey Dobriyan
2008-11-12 0:45 ` David Miller
2008-11-12 6:20 ` Eric Dumazet [this message]
2008-11-12 6:31 ` [PATCH] net: Cleanup of neighbour code Eric Dumazet
2008-11-12 8:55 ` David Miller
2008-11-12 8:53 ` [PATCH] nets: Introduce read_pnet() and write_pnet() helpers David Miller
2008-11-12 6:21 ` [PATCH] net: ib_net pointer should depends on CONFIG_NET_NS Eric Dumazet
2008-11-12 8:54 ` David Miller
2008-11-12 10:44 ` [PATCH v2] net: #ifdef inet_bind_bucket::ib_net Alexey Dobriyan
2008-11-12 10:50 ` Eric Dumazet
2008-11-12 12:24 ` [PATCH v3] " Alexey Dobriyan
2008-11-12 12:24 ` David Miller
2008-11-12 10:55 ` [PATCH v2] " Eric Dumazet
2008-11-12 11:16 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=491A75BE.1010907@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=adobriyan@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).