Skip to contentSkip to conversation

ipv6: Avoid unnecessary temporary addresses being generated

PATCH Superseded Heiner Kallweit 2 participants 3 messages Mar 12, 2014

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: Avoid unnecessary temporary addresses being generated

tmp_prefered_lft is an offset to ifp->tstamp, not now. Therefore age needs to be added to the condition.

Age calculation in ipv6_create_tempaddr is different from the one in addrconf_verify and doesn't consider ADDRCONF_TIMER_FUZZ_MINUS. This can cause age in ipv6_create_tempaddr to be less than the one in addrconf_verify and therefore unnecessary temporary address to be generated.
Use age calculation as in addrconf_modify to avoid this.

---
 net/ipv6/addrconf.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv6/addrconf.c +4 -1
index fdbfeca..bd64dbe 100644
@@ -1103,8 +1103,11 @@ retry:
 	 * Lifetime is greater than REGEN_ADVANCE time units.  In particular,
 	 * an implementation must not create a temporary address with a zero
 	 * Preferred Lifetime.
+	 * Use age calculation as in addrconf_verify to avoid unnecessary
+	 * temporary addresses being generated.
 	 */
-	if (tmp_prefered_lft <= regen_advance) {
+	age = (now - ifp->tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
+	if (tmp_prefered_lft <= regen_advance + age) {
 		in6_ifa_put(ifp);
 		in6_dev_put(idev);
 		ret = -1;
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

From: Heiner Kallweit <[email protected]>
Date: Wed, 12 Mar 2014 20:53:48 +0100

net/ipv6/addrconf.c retry: · line 1110

Quoted 10 lines
net/ipv6/addrconf.c +4 -1
@@ -1103,8 +1103,11 @@ retry:
 	 * Lifetime is greater than REGEN_ADVANCE time units.  In particular,
 	 * an implementation must not create a temporary address with a zero
 	 * Preferred Lifetime.
+	 * Use age calculation as in addrconf_verify to avoid unnecessary
+	 * temporary addresses being generated.
 	 */
-	if (tmp_prefered_lft <= regen_advance) {
+	age = (now - ifp->tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
+	if (tmp_prefered_lft <= regen_advance + age) {

I think you must use tmp_tstamp here, we snapshot all of the values above into local variables while holding the lock so that we calculate a consistent set of values and tests.

#2 lore raw

You're right. Fixed it and submitted v2 of patch.

Quoted 17 lines

From: Heiner Kallweit <[email protected]>
Date: Wed, 12 Mar 2014 20:53:48 +0100

net/ipv6/addrconf.c retry: · line 1110

Quoted 10 lines
net/ipv6/addrconf.c +4 -1
@@ -1103,8 +1103,11 @@ retry:
 	 * Lifetime is greater than REGEN_ADVANCE time units.  In particular,
 	 * an implementation must not create a temporary address with a zero
 	 * Preferred Lifetime.
+	 * Use age calculation as in addrconf_verify to avoid unnecessary
+	 * temporary addresses being generated.
 	 */
-	if (tmp_prefered_lft <= regen_advance) {
+	age = (now - ifp->tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
+	if (tmp_prefered_lft <= regen_advance + age) {

I think you must use tmp_tstamp here, we snapshot all of the values above into local variables while holding the lock so that we calculate a consistent set of values and tests.