[ds6-devel] Multiple IPv6 addresses?
Simone Piunno
pioppo at ferrara.linux.it
Wed Mar 26 22:02:49 CET 2003
On Wed, Mar 26, 2003 at 10:07:50AM +0100, Simone Piunno wrote:
> Before submitting this patch I'd like to:
>
> 1. have confirmation (e.g. from you) that this is really a bug
> instead of a feature :) Maybe there's an obscure reason for
> duplicating one address?
>
> 2. have at least one works-for-me (e.g. from Chad)
>
> 3. check the problem is not fixed yet in -usagi and -2.5.66
> I'll do it this evening.
checked, it's not fixed.
> 4. double check the locking scheme (e.g. being sure there's no
> other code path to add an address). I'll do it this evening.
double checked, it's not full safe, e.g. the same address could be
configured automatically by router advertising while we're doing it
manually. In this case we will end up with more than one instance
of the same address on the same interface, but:
- this is very unlikely
- we don't care that much, because this is what happens now already.
Anyway, this is the new patch:
--- net/ipv6/addrconf.c.orig 2003-03-25 21:33:55.000000000 +0100
+++ net/ipv6/addrconf.c 2003-03-26 21:59:41.000000000 +0100
@@ -88,6 +88,7 @@
*/
static struct inet6_ifaddr *inet6_addr_lst[IN6_ADDR_HSIZE];
static rwlock_t addrconf_hash_lock = RW_LOCK_UNLOCKED;
+static rwlock_t addrconf_add_lock = RW_LOCK_UNLOCKED;
/* Protects inet6 devices */
rwlock_t addrconf_lock = RW_LOCK_UNLOCKED;
@@ -908,7 +909,7 @@
return;
ok:
-
+ read_lock_bh(&addrconf_add_lock);
ifp = ipv6_get_ifaddr(&addr, dev);
if (ifp == NULL && valid_lft) {
@@ -920,12 +921,14 @@
addr_type&IPV6_ADDR_SCOPE_MASK, 0);
if (ifp == NULL) {
+ read_unlock_bh(&addrconf_add_lock);
in6_dev_put(in6_dev);
return;
}
addrconf_dad_start(ifp);
}
+ read_unlock_bh(&addrconf_add_lock);
if (ifp && valid_lft == 0) {
ipv6_del_addr(ifp);
@@ -1032,12 +1035,20 @@
return -ENOBUFS;
scope = ipv6_addr_scope(pfx);
+
+ read_lock_bh(&addrconf_add_lock);
+ if (!ipv6_chk_addr(pfx, dev)) {
+ read_unlock_bh(&addrconf_add_lock);
+ return -EEXIST;
+ }
if ((ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT)) != NULL) {
+ read_unlock_bh(&addrconf_add_lock);
addrconf_dad_start(ifp);
in6_ifa_put(ifp);
return 0;
}
+ read_unlock_bh(&addrconf_add_lock);
return -ENOBUFS;
}
So now I'm waiting for your OK to submit the patch.
--
Simone Piunno -- http://members.ferrara.linux.it/pioppo
.------- Adde parvum parvo magnus acervus erit -------.
Ferrara Linux Users Group - http://www.ferrara.linux.it
Deep Space 6, IPv6 on Linux - http://www.deepspace6.net
GNU Mailman, Mailing List Manager - http://www.list.org
`-------------------------------------------------------'
More information about the ds6-devel
mailing list