Re: [PATCH linux-2.6.17-rc1] net: fix neigh_delete to handle mult. tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In article <[email protected]> (at Fri, 21 Apr 2006 12:55:43 +0900 (JST)), YOSHIFUJI Hideaki <[email protected]> says:

> In article <[email protected]> (at Thu, 20 Apr 2006 23:31:24 -0400), Don Law <[email protected]> says:
> 
> > One side effect of this change is that neigh_lookup is now called while
> > a read lock is held on neigh_tbl_lock.  neigh_lookup does take read
> > locks on the tbl->lock set.  However, this does not introduce any new lock
> > order dependencies, since we already have that precedent set in the
> > neightbl_set function.
> 
> I don't think this is good change.
> 
> What you need to fix your problem is to remove the last
> "goto out_dev_put;" isn't it?

Hmm, okay, I notice we need to hold lock for pneigh_delete().
How about this?  Also handles proxy neighbors.

Signed-off-by: YOSHIFUJI Hideaki <[email protected]>

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 4cf878e..fa3227a 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1430,6 +1430,8 @@ int neigh_delete(struct sk_buff *skb, st
 	    (dev = dev_get_by_index(ndm->ndm_ifindex)) == NULL)
 		goto out;
 
+	err = -EADDRNOTAVAIL;
+
 	read_lock(&neigh_tbl_lock);
 	for (tbl = neigh_tables; tbl; tbl = tbl->next) {
 		struct rtattr *dst_attr = nda[NDA_DST - 1];
@@ -1437,32 +1439,33 @@ int neigh_delete(struct sk_buff *skb, st
 
 		if (tbl->family != ndm->ndm_family)
 			continue;
-		read_unlock(&neigh_tbl_lock);
 
-		err = -EINVAL;
-		if (!dst_attr || RTA_PAYLOAD(dst_attr) < tbl->key_len)
-			goto out_dev_put;
+		if (!dst_attr || RTA_PAYLOAD(dst_attr) < tbl->key_len) {
+			err = -EINVAL;
+			break;
+		}
 
 		if (ndm->ndm_flags & NTF_PROXY) {
-			err = pneigh_delete(tbl, RTA_DATA(dst_attr), dev);
-			goto out_dev_put;
+			if (!pneigh_delete(tbl, RTA_DATA(dst_attr), dev)) {
+				read_unlock(&neigh_tbl_lock);
+				break;
+			}
 		}
 
 		if (!dev)
-			goto out;
+			continue;
 
 		n = neigh_lookup(tbl, RTA_DATA(dst_attr), dev);
 		if (n) {
+			read_unlock(&neigh_tbl_lock);
 			err = neigh_update(n, NULL, NUD_FAILED, 
 					   NEIGH_UPDATE_F_OVERRIDE|
 					   NEIGH_UPDATE_F_ADMIN);
 			neigh_release(n);
+			break;
 		}
-		goto out_dev_put;
 	}
 	read_unlock(&neigh_tbl_lock);
-	err = -EADDRNOTAVAIL;
-out_dev_put:
 	if (dev)
 		dev_put(dev);
 out:

-- 
YOSHIFUJI Hideaki @ USAGI Project  <[email protected]>
GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux