All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: David Miller <davem@davemloft.net>
Cc: adobriyan@gmail.com, netdev@vger.kernel.org
Subject: [PATCH] net: Cleanup of neighbour code
Date: Wed, 12 Nov 2008 07:31:58 +0100	[thread overview]
Message-ID: <491A785E.5060903@cosmosbay.com> (raw)
In-Reply-To: <491A75BE.1010907@cosmosbay.com>

[-- Attachment #1: Type: text/plain, Size: 276 bytes --]

Using read_pnet() and write_pnet() in neighbour code ease the reading of code.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
---
 include/net/neighbour.h |   12 ++----------
 net/core/neighbour.c    |   12 +++---------
 2 files changed, 5 insertions(+), 19 deletions(-)


[-- Attachment #2: neigh.patch --]
[-- Type: text/plain, Size: 1938 bytes --]

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 365b5e2..d8d790e 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -220,11 +220,7 @@ extern void			neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *p
 static inline
 struct net			*neigh_parms_net(const struct neigh_parms *parms)
 {
-#ifdef CONFIG_NET_NS
-	return parms->net;
-#else
-	return &init_net;
-#endif
+	return read_pnet(&parms->net);
 }
 
 extern unsigned long		neigh_rand_reach_time(unsigned long base);
@@ -241,11 +237,7 @@ extern int			pneigh_delete(struct neigh_table *tbl, struct net *net, const void
 static inline
 struct net			*pneigh_net(const struct pneigh_entry *pneigh)
 {
-#ifdef CONFIG_NET_NS
-	return pneigh->net;
-#else
-	return &init_net;
-#endif
+	return read_pnet(&pneigh->net);
 }
 
 extern void neigh_app_ns(struct neighbour *n);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 500c243..cca6a55 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -531,9 +531,7 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
 	if (!n)
 		goto out;
 
-#ifdef CONFIG_NET_NS
-	n->net = hold_net(net);
-#endif
+	write_pnet(&n->net, hold_net(net));
 	memcpy(n->key, pkey, key_len);
 	n->dev = dev;
 	if (dev)
@@ -1350,9 +1348,7 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
 
 		dev_hold(dev);
 		p->dev = dev;
-#ifdef CONFIG_NET_NS
-		p->net = hold_net(net);
-#endif
+		write_pnet(&p->net, hold_net(net));
 		p->sysctl_table = NULL;
 		write_lock_bh(&tbl->lock);
 		p->next		= tbl->parms.next;
@@ -1407,9 +1403,7 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
 	unsigned long now = jiffies;
 	unsigned long phsize;
 
-#ifdef CONFIG_NET_NS
-	tbl->parms.net = &init_net;
-#endif
+	write_pnet(&tbl->parms.net, &init_net);
 	atomic_set(&tbl->parms.refcnt, 1);
 	tbl->parms.reachable_time =
 			  neigh_rand_reach_time(tbl->parms.base_reachable_time);

  reply	other threads:[~2008-11-12  6:32 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               ` [PATCH] nets: Introduce read_pnet() and write_pnet() helpers Eric Dumazet
2008-11-12  6:31                 ` Eric Dumazet [this message]
2008-11-12  8:55                   ` [PATCH] net: Cleanup of neighbour code 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=491A785E.5060903@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.