The RFC states that if the preferred lifetime is less than
REGEN_ADVANCE, no temporary address should be created.
Signed-off-by: Benoit Boissinot <redacted>
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 101e0e7..5d0e404 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -776,6 +776,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *i
struct inet6_dev *idev = ifp->idev;
struct in6_addr addr, *tmpaddr;
unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_cstamp, tmp_tstamp;
+ unsigned long regen_advance;
int tmp_plen;
int ret = 0;
int max_addresses; @@ -838,6 +839,22 @@ retry:
write_unlock(&idev->lock);
+ regen_advance = ifp->idev->cnf.regen_max_retry *
+ ifp->idev->cnf.dad_transmits *
+ ifp->idev->nd_parms->retrans_time / HZ;
+
+ /* A temporary address is created only if this calculated Preferred
+ * Lifetime is greater than REGEN_ADVANCE time units. In particular,
+ * an implementation must not create a temporary address with a zero
+ * Preferred Lifetime.
+ */
+ if (tmp_prefered_lft <= regen_advance) {
+ in6_ifa_put(ifp);
+ in6_dev_put(idev);
+ ret = -1;
+ goto out;
+ }
+
addr_flags = IFA_F_TEMPORARY;
/* set in addrconf_prefix_rcv() */
if (ifp->flags & IFA_F_OPTIMISTIC)
--
:wq
Convert addrconf_verify to mod_timer
Signed-off-by: Benoit Boissinot <redacted>
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 101e0e7..5d0e404 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2922,8 +2943,6 @@ static void addrconf_verify(unsigned long foo)
now = jiffies;
next = now + ADDR_CHECK_FREQUENCY;
- del_timer(&addr_chk_timer);
-
for (i=0; i < IN6_ADDR_HSIZE; i++) {
restart:@@ -3013,8 +3032,7 @@ restart:
read_unlock(&addrconf_hash_lock);
}
- addr_chk_timer.expires = time_before(next, jiffies + HZ) ? jiffies + HZ : next;
- add_timer(&addr_chk_timer);
+ mod_timer(&addr_chk_timer, time_before(next, jiffies + HZ) ? jiffies + HZ : next);
spin_unlock_bh(&addrconf_verify_lock);
}
--
:wq
On Tue, Mar 18, 2008 at 01:42:35PM +0100, Benoit Boissinot wrote:
Convert addrconf_verify to mod_timer
after some reflexion, this patch is probably wrong, since
addrconf_verify is called from outside the timer too.
sorry,
Benoit
quoted hunk
Signed-off-by: Benoit Boissinot <redacted>
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 101e0e7..5d0e404 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2922,8 +2943,6 @@ static void addrconf_verify(unsigned long foo)
now = jiffies;
next = now + ADDR_CHECK_FREQUENCY;
- del_timer(&addr_chk_timer);
-
for (i=0; i < IN6_ADDR_HSIZE; i++) {
restart:@@ -3013,8 +3032,7 @@ restart:
read_unlock(&addrconf_hash_lock);
}
- addr_chk_timer.expires = time_before(next, jiffies + HZ) ? jiffies + HZ : next;
- add_timer(&addr_chk_timer);
+ mod_timer(&addr_chk_timer, time_before(next, jiffies + HZ) ? jiffies + HZ : next);
spin_unlock_bh(&addrconf_verify_lock);
}
--
:wq
--
:wq