All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@davemloft.net>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: shemminger@osdl.org, netdev@oss.sgi.com
Subject: Re: neigh_create/inetdev_destroy race?
Date: Wed, 1 Sep 2004 22:21:18 -0700	[thread overview]
Message-ID: <20040901222118.0ce4bcc6.davem@davemloft.net> (raw)
In-Reply-To: <20040831104139.GA2124@gondor.apana.org.au>

On Tue, 31 Aug 2004 20:41:39 +1000
Herbert Xu <herbert@gondor.apana.org.au> wrote:

> > I think we can clear this by putting neigh_parms_release() into an
> > RCU handler.  It can't be in in_dev_rcu_put.
> 
> Yes that should go a long way in resolving this problem.

So here's the first step.  No rcu_read_lock()'s are needed
since the tbl->lock needs to be held as a write when
traversing these things anyways for other reasons.

Can you work on the next bit you mentioned, making
sure the corresponding idev is still alive when we add
a neighbour with its neigh_parms to the hash table?

Thanks.

===== include/net/neighbour.h 1.8 vs edited =====
--- 1.8/include/net/neighbour.h	2004-08-16 14:10:51 -07:00
+++ edited/include/net/neighbour.h	2004-09-01 21:57:37 -07:00
@@ -46,6 +46,7 @@
 #include <asm/atomic.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
+#include <linux/rcupdate.h>
 
 #include <linux/err.h>
 #include <linux/sysctl.h>
@@ -65,6 +66,8 @@
 	void	*priv;
 
 	void	*sysctl_table;
+
+	struct rcu_head rcu_head;
 
 	int	base_reachable_time;
 	int	retrans_time;
===== net/core/neighbour.c 1.28 vs edited =====
--- 1.28/net/core/neighbour.c	2004-04-29 16:26:35 -07:00
+++ edited/net/core/neighbour.c	2004-09-01 22:00:59 -07:00
@@ -1120,6 +1120,7 @@
 	if (p) {
 		memcpy(p, &tbl->parms, sizeof(*p));
 		p->tbl		  = tbl;
+		INIT_RCU_HEAD(&p->rcu_head);
 		p->reachable_time =
 				neigh_rand_reach_time(p->base_reachable_time);
 		if (dev && dev->neigh_setup && dev->neigh_setup(dev, p)) {
@@ -1135,6 +1136,14 @@
 	return p;
 }
 
+static void neigh_rcu_free_parms(struct rcu_head *head)
+{
+	struct neigh_parms *parms =
+		container_of(head, struct neigh_parms, rcu_head);
+
+	kfree(parms);
+}
+
 void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms)
 {
 	struct neigh_parms **p;
@@ -1146,7 +1155,7 @@
 		if (*p == parms) {
 			*p = parms->next;
 			write_unlock_bh(&tbl->lock);
-			kfree(parms);
+			call_rcu(&parms->rcu_head, neigh_rcu_free_parms);
 			return;
 		}
 	}
@@ -1159,6 +1168,7 @@
 {
 	unsigned long now = jiffies;
 
+	INIT_RCU_HEAD(&tbl->parms.rcu_head);
 	tbl->parms.reachable_time =
 			  neigh_rand_reach_time(tbl->parms.base_reachable_time);
 

  reply	other threads:[~2004-09-02  5:21 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-12 23:59 [PATCH] Move inetdev/ifa over to RCU David S. Miller
2004-08-13  2:20 ` James Morris
2004-08-13 10:02 ` Herbert Xu
2004-08-13 16:03 ` Stephen Hemminger
2004-08-13 16:38   ` David S. Miller
2004-08-13 21:56     ` Herbert Xu
2004-08-13 22:19       ` David S. Miller
2004-08-14  0:34         ` Herbert Xu
2004-08-14  0:39           ` David S. Miller
2004-08-14  0:54             ` Herbert Xu
2004-08-14  1:25               ` Herbert Xu
2004-08-14  1:30                 ` Herbert Xu
2004-08-14  5:08                   ` Herbert Xu
2004-08-14  6:27                     ` neigh_create/inetdev_destroy race? Herbert Xu
2004-08-16  2:14                       ` David S. Miller
2004-08-16 10:51                         ` Herbert Xu
2004-08-29  6:42                           ` David S. Miller
2004-08-29  6:50                             ` Herbert Xu
2004-08-31  6:08                               ` David S. Miller
2004-08-31 10:41                                 ` Herbert Xu
2004-09-02  5:21                                   ` David S. Miller [this message]
2004-09-02 13:06                                     ` Herbert Xu
2004-09-03 13:36                                       ` Herbert Xu
2004-09-03 16:00                                         ` Stephen Hemminger
2004-09-03 23:49                                           ` Herbert Xu
2004-09-07 20:50                                             ` David S. Miller
2004-09-03 16:18                                         ` David S. Miller
2004-08-16  2:08                     ` [PATCH] Move inetdev/ifa over to RCU David S. Miller
2004-08-16  2:43                       ` Herbert Xu
2004-08-16  3:08                         ` David S. Miller
2004-08-16  3:14                           ` Herbert Xu
2004-08-16  6:23                             ` David S. Miller
2004-08-14  6:31                   ` Herbert Xu
2004-08-14  6:32                     ` Herbert Xu
2004-08-16  3:01                   ` David S. Miller
2004-08-14  1:40                 ` Herbert Xu
2004-08-16  3:03                   ` David S. Miller
2004-08-16  3:23                     ` Herbert Xu
2004-08-16  6:24                       ` David S. Miller
2004-08-14  4:30                 ` Stephen Hemminger
2004-08-14  4:36                   ` Herbert Xu
2004-08-16  2:59               ` David S. Miller
2004-08-16  2:58           ` David S. Miller
2004-08-16  3:08             ` Herbert Xu
2004-08-16  6:21               ` David S. Miller
2004-08-16  8:13                 ` Herbert Xu

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=20040901222118.0ce4bcc6.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@oss.sgi.com \
    --cc=shemminger@osdl.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.