netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ipv6: Avoid unnecessary temporary addresses being generated
@ 2014-03-12 21:13 Heiner Kallweit
  2014-03-13 19:49 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Heiner Kallweit @ 2014-03-12 21:13 UTC (permalink / raw)
  To: netdev

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.

Signed-off-by: Heiner Kallweit <heiner.kallweit@web.de>
---
 net/ipv6/addrconf.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index fdbfeca..bd64dbe 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -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 - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
+	if (tmp_prefered_lft <= regen_advance + age) {
 		in6_ifa_put(ifp);
 		in6_dev_put(idev);
 		ret = -1;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ipv6: Avoid unnecessary temporary addresses being generated
  2014-03-12 21:13 [PATCH v2] ipv6: Avoid unnecessary temporary addresses being generated Heiner Kallweit
@ 2014-03-13 19:49 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-03-13 19:49 UTC (permalink / raw)
  To: heiner.kallweit; +Cc: netdev

From: Heiner Kallweit <heiner.kallweit@web.de>
Date: Wed, 12 Mar 2014 22:13:19 +0100

> 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.
> 
> Signed-off-by: Heiner Kallweit <heiner.kallweit@web.de>

Looks good, applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-13 19:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-12 21:13 [PATCH v2] ipv6: Avoid unnecessary temporary addresses being generated Heiner Kallweit
2014-03-13 19:49 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).