ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
Subsystems (3)
PATCH 1/1 ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
from: Yasushi Asano <[email protected]>
There is a problem when setting the lifetime of an IPv6 address.
When I set preferred_lft to a value not zero or infinity, while valid_lft is infinity(0xffffffff) preferred lifetime is set to forever and does not update.
Therefore preferred lifetime never becomes deprecated.
I think valid lifetime and preferred lifetime should be set independently,
even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
I made a patch for 3.12 stable to solve the problem.
< console log before patching >
using the ip addr command to verify the problem
------------------------------------------------------------------------------------------------------------
# # ip addr add 2002:100:10:1::100/64 dev eth1 valid_lft 0xffffffff preferred_lft 20 # # ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:04:9f:02:00:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.0.101/24 brd 192.168.0.255 scope global eth1
inet6 2002:100:10:1::100/64 scope global <----- The address doesn't become deprecated after 20seconds.valid_lft forever preferred_lft forever <----- preferred_lft becomes forever instead of 20seconds.
inet6 fe80::204:9fff:fe02:5e/64 scope link Therefore lifetime(preferred_lft) is not updating.valid_lft forever preferred_lft forever
------------------------------------------------------------------------------------------------------------
< console log after patching >
using the ip addr command to verify it runs correctly
------------------------------------------------------------------------------------------------------------
# ifconfig eth1 192.168.0.101 netmask 255.255.255.0
# ip addr add 2002:100:10:1::100/64 dev eth1 valid_lft 0xffffffff preferred_lft 20
# ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:04:9f:02:00:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.0.101/24 brd 192.168.0.255 scope global eth1
inet6 2002:100:10:1::100/64 scope global dynamic <------------- "global dynamic"
valid_lft forever preferred_lft 16sec <--------------it begins counting down from 20seconds
inet6 fe80::204:9fff:fe02:5e/64 scope link
valid_lft forever preferred_lft forever
# ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:04:9f:02:00:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.0.101/24 brd 192.168.0.255 scope global eth1
inet6 2002:100:10:1::100/64 scope global dynamic <------------ "global dynamic"
valid_lft forever preferred_lft 11sec <------------ it continues counting down.
inet6 fe80::204:9fff:fe02:5e/64 scope link
valid_lft forever preferred_lft forever
# ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:04:9f:02:00:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.0.101/24 brd 192.168.0.255 scope global eth1
inet6 2002:100:10:1::100/64 scope global deprecated dynamic <- "deprecated dynamic"
valid_lft forever preferred_lft 0sec <----------- it expired because it became zero seconds and it changed to "deprecated".
inet6 fe80::204:9fff:fe02:5e/64 scope link
valid_lft forever preferred_lft forever
#------------------------------------------------------------------------------------------------------------net/ipv6/addrconf.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
net/ipv6/addrconf.c +5 -3
@@ -755,6 +755,7 @@ static void ipv6_del_addr(struct inet6_iif (!onlink) onlink =-1 ; +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) {spin_lock (&ifa->lock); lifetime =addrconf_timeout_fixup (ifa->valid_lft,HZ );
@@ -771,6 +772,7 @@ static void ipv6_del_addr(struct inet6_i } } } + }write_unlock_bh (&idev->lock);addrconf_del_timer (ifp);
@@ -2137,7 +2139,6 @@ static int inet6_addr_add(struct net *ne }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ; } timeout =addrconf_timeout_fixup (prefered_lft,HZ );
@@ -3177,9 +3178,11 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } + +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) {if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) next = ifp->tstamp + ifp->valid_lft *HZ ; - + }spin_unlock (&ifp->lock);if (deprecate) {
@@ -3309,7 +3312,6 @@ static int inet6_addr_modify(struct inet }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ; } timeout =addrconf_timeout_fixup (prefered_lft,HZ );
Quoted 11 lines · Yasushi
from: Yasushi Asano <[email protected]>
There is a problem when setting the lifetime of an IPv6 address.
When I setpreferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff) preferred lifetime is set to forever and does not update.
Therefore preferred lifetime never becomes deprecated.I think valid lifetime and preferred lifetime should be set independently,
even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)I made a patch for 3.12 stable to solve the problem.
This indeed could be improved. Thanks for the patch. But you should base it on net-next so it can be applied and please clean up the warnings and errors if you run the patch through ./scripts/checkpatch --strict.
Thank you,
Hannes
Quoted 25 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hannes Frederic Sowa
Sent: Tuesday, December 10, 2013 8:47 AM
To: Asano, Yasushi
Cc: [email protected]
Subject: Re: [PATCH 1/1] ipv6 addrconf:fix preferred lifetime state-changing behavior whilevalid_lftis infinity
Importance: HighQuoted 4 lines · Yasushi
from: Yasushi Asano <[email protected]>
There is a problem when setting the lifetime of an IPv6 address. When I set
preferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff)
Quoted 5 lines
preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated.
I think valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire
correctly (meaning it must eventually become deprecated)
Quoted 2 lines
I made a patch for 3.12 stable to solve the problem.
Quoted 8 lines
This indeed could be improved. Thanks for the patch. But you should base it on net-next so it can be applied and please clean up the warnings and errors if you run the patch through
./scripts/checkpatch--strict.Thank you,
Hannes
I made a patch based on net-next and emailed ML using git send-email last night.
Subject: [PATCH 1/1] ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
Date: Wed, 11 Dec 2013 19:57:32 +0900
Message-ID: <[email protected]>
X-Mailer: git-send-email 1.7.12.4
Thank you for your time and assistance regarding this matter. Yasushi
Quoted 35 lines · Yasushi
Quoted 25 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hannes Frederic Sowa
Sent: Tuesday, December 10, 2013 8:47 AM
To: Asano, Yasushi
Cc: [email protected]
Subject: Re: [PATCH 1/1] ipv6 addrconf:fix preferred lifetime state-changing behavior whilevalid_lftis infinity
Importance: HighQuoted 4 lines · Yasushi
from: Yasushi Asano <[email protected]>
There is a problem when setting the lifetime of an IPv6 address. When I set
preferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff)
Quoted 5 lines
preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated.
I think valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire
correctly (meaning it must eventually become deprecated)
Quoted 2 lines
I made a patch for 3.12 stable to solve the problem.
Quoted 8 lines
This indeed could be improved. Thanks for the patch. But you should base it on net-next so it can be applied and please clean up the warnings and errors if you run the patch through
./scripts/checkpatch--strict.Thank you,
Hannes
I made a patch based on net-next and emailed ML using git send-email last night.
Quoted 7 lines
Subject: [PATCH 1/1] ipv6 addrconf:fix preferred lifetime state-changing behavior while
valid_lftis infinity
Date: Wed, 11 Dec 2013 19:57:32 +0900
Message-ID: <[email protected]>
X-Mailer: git-send-email 1.7.12.4Thank you for your time and assistance regarding this matter. Yasushi
Huch? I have not seen anything nor has patchworks:
http://patchwork.ozlabs.org/project/netdev/list/
Greetings,
Hannes
PATCH 1/1 ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
From: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting preferred_lft to a value not zero or infinity, while valid_lft is infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
--- net/ipv6/addrconf.c | 34 ++++++++++++++++++++-------------- 1 files changed, 20 insertions(+), 14 deletions(-)
net/ipv6/addrconf.c +22 -16
@@ -948,18 +948,22 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)if (!onlink) onlink =-1 ; -spin_lock (&ifa->lock); - - lifetime =addrconf_timeout_fixup (ifa->valid_lft,HZ ); -/* -* Note: Because this address is -* not permanent, lifetime < -* LONG_MAX / HZ here. -*/ -if (time_before (expires, - ifa->tstamp + lifetime *HZ )) - expires = ifa->tstamp + lifetime *HZ ; -spin_unlock (&ifa->lock); +if (ifp->valid_lft != +INFINITY_LIFE_TIME ) { +spin_lock (&ifa->lock); + + lifetime =addrconf_timeout_fixup ( + ifa->valid_lft,HZ ); +/* +* Note: Because this address is +* not permanent, lifetime < +* LONG_MAX / HZ here. +*/ +if (time_before (expires, + ifa->tstamp + lifetime *HZ )) + expires = ifa->tstamp + lifetime *HZ ; +spin_unlock (&ifa->lock); + } } } }
@@ -2415,7 +2419,6 @@ static int inet6_addr_add(struct net *net, int ifindex, }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ; } timeout =addrconf_timeout_fixup (prefered_lft,HZ );
@@ -3497,8 +3500,12 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } -if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) - next = ifp->tstamp + ifp->valid_lft *HZ ; +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) { +if (time_before (ifp->tstamp + + ifp->valid_lft *HZ , next)) + next = ifp->tstamp + + ifp->valid_lft *HZ ; + }spin_unlock (&ifp->lock);
@@ -3635,7 +3642,6 @@ static int inet6_addr_modify(struct inet6_ifaddr *ifp, u32 ifa_flags, }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ; } timeout =addrconf_timeout_fixup (prefered_lft,HZ );
David Miller
maintainerFrom: [email protected]
Date: Thu, 12 Dec 2013 19:01:40 +0900
Quoted 10 lines
From: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting
preferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
Please do not indent your entire commit message with a leading space.
PATCH 1/1 ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
In reply to Hannes Frederic SowaFrom: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting preferred_lft to a value not zero or infinity, while valid_lft is infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
--- net/ipv6/addrconf.c | 34 ++++++++++++++++++++-------------- 1 files changed, 20 insertions(+), 14 deletions(-)
net/ipv6/addrconf.c +22 -16
@@ -948,18 +948,22 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)if (!onlink) onlink =-1 ; -spin_lock (&ifa->lock); - - lifetime =addrconf_timeout_fixup (ifa->valid_lft,HZ ); -/* -* Note: Because this address is -* not permanent, lifetime < -* LONG_MAX / HZ here. -*/ -if (time_before (expires, - ifa->tstamp + lifetime *HZ )) - expires = ifa->tstamp + lifetime *HZ ; -spin_unlock (&ifa->lock); +if (ifp->valid_lft != +INFINITY_LIFE_TIME ) { +spin_lock (&ifa->lock); + + lifetime =addrconf_timeout_fixup ( + ifa->valid_lft,HZ ); +/* +* Note: Because this address is +* not permanent, lifetime < +* LONG_MAX / HZ here. +*/ +if (time_before (expires, + ifa->tstamp + lifetime *HZ )) + expires = ifa->tstamp + lifetime *HZ ; +spin_unlock (&ifa->lock); + } } } }
@@ -2415,7 +2419,6 @@ static int inet6_addr_add(struct net *net, int ifindex, }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ; } timeout =addrconf_timeout_fixup (prefered_lft,HZ );
@@ -3497,8 +3500,12 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } -if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) - next = ifp->tstamp + ifp->valid_lft *HZ ; +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) { +if (time_before (ifp->tstamp + + ifp->valid_lft *HZ , next)) + next = ifp->tstamp + + ifp->valid_lft *HZ ; + }spin_unlock (&ifp->lock);
@@ -3635,7 +3642,6 @@ static int inet6_addr_modify(struct inet6_ifaddr *ifp, u32 ifa_flags, }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ; } timeout =addrconf_timeout_fixup (prefered_lft,HZ );
Hello.
Quoted 22 lines · On 12-12-2013 14:15, [email protected] wrote:
From: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting
preferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)Signed-off-by Yasushi Asano <[email protected]>--- net/ipv6/addrconf.c | 34 ++++++++++++++++++++-------------- 1 files changed, 20 insertions(+), 14 deletions(-)net/ipv6/addrconf.c +0
-0@@ -948,18 +948,22 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
[...]
net/ipv6/addrconf.c static void ipv6_del_addr(struct inet6_ifaddr *ifp) · line 952
Quoted 2 lines
net/ipv6/addrconf.c +2
-0+if (ifp->valid_lft != +INFINITY_LIFE_TIME ) {
Please start the continuation line right under 'ifp', according to the
networking coding style -- this ways it's easier on the eyes and don't mix with the following block.
net/ipv6/addrconf.c static void ipv6_del_addr(struct inet6_ifaddr *ifp) · line 958
Quoted 6 lines
net/ipv6/addrconf.c +6
-0+spin_lock (&ifa->lock); + + lifetime =addrconf_timeout_fixup ( + ifa->valid_lft,HZ ); +/* +* Note: Because this address is
s/Because/because/, so that the grammar is correct.
net/ipv6/addrconf.c static void ipv6_del_addr(struct inet6_ifaddr *ifp) · line 961
Quoted 3 lines
net/ipv6/addrconf.c +3
-0+* not permanent, lifetime < +* LONG_MAX / HZ here. +*/
Networking code assumes slightly other style of multi-line comments:
/* bla
* bla
*/
WBR, Sergei
PATCH 1/1 ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
In reply to [email protected]From: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting preferred_lft to a value not zero or infinity, while valid_lft is infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
--- net/ipv6/addrconf.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-)
net/ipv6/addrconf.c +21 -16
@@ -948,18 +948,21 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)if (!onlink) onlink =-1 ; -spin_lock (&ifa->lock); - - lifetime =addrconf_timeout_fixup (ifa->valid_lft,HZ ); -/* -* Note: Because this address is -* not permanent, lifetime < -* LONG_MAX / HZ here. -*/ -if (time_before (expires, - ifa->tstamp + lifetime *HZ )) - expires = ifa->tstamp + lifetime *HZ ; -spin_unlock (&ifa->lock); +if (ifp->valid_lft != +INFINITY_LIFE_TIME ) { +spin_lock (&ifa->lock); + + lifetime =addrconf_timeout_fixup ( + ifa->valid_lft,HZ ); +/* Note: because this address is +* not permanent, lifetime < +* LONG_MAX / HZ here. +*/ +if (time_before (expires, + ifa->tstamp + lifetime *HZ )) + expires = ifa->tstamp + lifetime *HZ ; +spin_unlock (&ifa->lock); + } } } }
@@ -2415,7 +2418,6 @@ static int inet6_addr_add(struct net *net, int ifindex, }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ; } timeout =addrconf_timeout_fixup (prefered_lft,HZ );
@@ -3497,8 +3499,12 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } -if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) - next = ifp->tstamp + ifp->valid_lft *HZ ; +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) { +if (time_before (ifp->tstamp + + ifp->valid_lft *HZ , next)) + next = ifp->tstamp + + ifp->valid_lft *HZ ; + }spin_unlock (&ifp->lock);
@@ -3635,7 +3641,6 @@ static int inet6_addr_modify(struct inet6_ifaddr *ifp, u32 ifa_flags, }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ; } timeout =addrconf_timeout_fixup (prefered_lft,HZ );
Quoted 25 lines · On Sat, Dec 14, 2013 at 02:33:48AM +0900, [email protected] wrote:
net/ipv6/addrconf.c +5
-12@@ -948,18 +948,21 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)if (!onlink) onlink =-1 ; -spin_lock (&ifa->lock); - - lifetime =addrconf_timeout_fixup (ifa->valid_lft,HZ ); -/* -* Note: Because this address is -* not permanent, lifetime < -* LONG_MAX / HZ here. -*/ -if (time_before (expires, - ifa->tstamp + lifetime *HZ )) - expires = ifa->tstamp + lifetime *HZ ; -spin_unlock (&ifa->lock); +if (ifp->valid_lft != +INFINITY_LIFE_TIME ) { +spin_lock (&ifa->lock); + + lifetime = addrconf_timeout_fixup(
net/ipv6/addrconf.c static void ipv6_del_addr(struct inet6_ifaddr *ifp) · line 965
Quoted 10 lines
net/ipv6/addrconf.c +10
-0+ ifa->valid_lft, HZ); +/* Note: because this address is +* not permanent, lifetime < +* LONG_MAX / HZ here. +*/ +if (time_before (expires, + ifa->tstamp + lifetime *HZ )) + expires = ifa->tstamp + lifetime *HZ ; +spin_unlock (&ifa->lock); + }
Sorry, this does not make sense to me. Below you remove the IFA_F_PERMANENT expression and here you change code depending only on that flag. Is this meant as a shortcut? Please explain, maybe I am missing something.
net/ipv6/addrconf.c static int inet6_addr_add(struct net *net, int ifindex, · line 2418
Quoted 8 lines
net/ipv6/addrconf.c +0
-1} } }@@ -2415,7 +2418,6 @@ static int inet6_addr_add(struct net *net, int ifindex, }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ;
I find this very suspicious. IFA_F_PERMANENT may only be removed if valid_lft != inifinity and preferred_lft != infinity if at all (see below).
We have to be very careful here with interactions of prefix routes.
net/ipv6/addrconf.c restart: · line 3507
Quoted 13 lines
net/ipv6/addrconf.c +6
-2timeout =addrconf_timeout_fixup (prefered_lft,HZ );@@ -3497,8 +3499,12 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } -if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) - next = ifp->tstamp + ifp->valid_lft *HZ ; +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) { +if (time_before (ifp->tstamp + + ifp->valid_lft *HZ , next)) + next = ifp->tstamp + + ifp->valid_lft *HZ ; + }
You could reduce one level of indentation if you collapse those two conditions.
net/ipv6/addrconf.c static int inet6_addr_modify(struct inet6_ifaddr *ifp, u32 ifa_flags, · line 3644
Quoted 9 lines
net/ipv6/addrconf.c +0
-1spin_unlock (&ifp->lock);@@ -3635,7 +3641,6 @@ static int inet6_addr_modify(struct inet6_ifaddr *ifp, u32 ifa_flags, }else { expires =0 ; flags =0 ; - ifa_flags |=IFA_F_PERMANENT ; }
Ditto, I do think we cannot remove this flag unconditionally.
Actually, I don't think it is the correct way to remove the IFA_F_PERMANENT here at all. We break the interaction with prefix routes and won't remove them at the time of address deletion any more. This is definitely a no-go, sorry.
The prefix was added by hand and should get removed immediately if a user removes the address (well actually it is an error we set up a prefix route in the first place, but it is how things are now).
IMHO, the changes need to be made in addrconf_verify so that the route does get marked as deprecated. Please check the places where we mark an interface address as deprecated.
Thanks,
Hannes
Quoted 1 line · Hannes Frederic Sowa
IMHO, the changes need to be made in
addrconf_verifyso that the route does
^^^^
I actually meant address, sorry. The route must stay valid of course.
Quoted 2 lines
get marked as deprecated. Please check the places where we mark an interface address as deprecated.
Quoted 12 lines
Ditto, I do think we cannot remove this flag unconditionally.
Actually, I don't think it is the correct way to remove the
IFA_F_PERMANENThere at all. We break the interaction with prefix routes and won't remove them
at the time of address deletion any more. This is definitely a no-go, sorry.The prefix was added by hand and should get removed immediately if a user removes the address (well actually it is an error we set up a prefix route in
the first place, but it is how things are now).
Quoted 7 lines
IMHO, the changes need to be made in
addrconf_verifyso that the route does get marked as deprecated. Please check the places where we mark an interface address as deprecated.Thanks,
Hannes
Sorry about not getting back to you sooner.
I have been thinking and testing about the correct way of fixing the problem. I understand it's not the correct way to remove the IFA_F_PERMANENT.
I agree with you that the changes need to be made in addrconf_verify. and I think the changes also need to be made in inet6_fill_ifaddr
so that the "preferred" is set INFINITY_LIFE_TIME unconditionally while ifa->flags is IFA_F_PERMANENT.
It means, "preferred" is set to INFINITY_LIFE_TIME when I set preferred_lft a value not zero or infinity, while valid_lft is infinity(0xffffffff)
I am going to send a new patch soon.
Your kind consideration of this matter would be sincerely appreciated.
Yasushi
PATCH 1/1 ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
In reply to Hannes Frederic SowaFrom: Yasushi Asano <[email protected]>
--- net/ipv6/addrconf.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/ipv6/addrconf.c +10 -4
@@ -3479,7 +3479,8 @@ restart: &inet6_addr_lst[i], addr_lst) {unsigned long age; -if (ifp->flags &IFA_F_PERMANENT ) +if ((ifp->flags &IFA_F_PERMANENT ) && + (ifp->prefered_lft ==INFINITY_LIFE_TIME ))continue ;spin_lock (&ifp->lock);
@@ -3504,8 +3505,12 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } -if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) - next = ifp->tstamp + ifp->valid_lft *HZ ; +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) { +if (time_before (ifp->tstamp + + ifp->valid_lft *HZ , next)) + next = ifp->tstamp + + ifp->valid_lft *HZ ; + }spin_unlock (&ifp->lock);
@@ -3804,7 +3809,8 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,put_ifaddrmsg (nlh, ifa->prefix_len, ifa->flags,rt_scope (ifa->scope), ifa->idev->dev->ifindex); -if (!(ifa->flags&IFA_F_PERMANENT )) { +if (!((ifa->flags&IFA_F_PERMANENT ) && + (ifa->prefered_lft ==INFINITY_LIFE_TIME ))) { preferred = ifa->prefered_lft; valid = ifa->valid_lft;if (preferred !=INFINITY_LIFE_TIME ) {
Signature · 1 line
1.7.12.4
PATCH 1/1 ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
In reply to Hannes Frederic SowaFrom: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting preferred_lft to a value not zero or infinity, while valid_lft is infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
--- net/ipv6/addrconf.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/ipv6/addrconf.c +10 -4
@@ -3479,7 +3479,8 @@ restart: &inet6_addr_lst[i], addr_lst) {unsigned long age; -if (ifp->flags &IFA_F_PERMANENT ) +if ((ifp->flags &IFA_F_PERMANENT ) && + (ifp->prefered_lft ==INFINITY_LIFE_TIME ))continue ;spin_lock (&ifp->lock);
@@ -3504,8 +3505,12 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } -if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) - next = ifp->tstamp + ifp->valid_lft *HZ ; +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) { +if (time_before (ifp->tstamp + + ifp->valid_lft *HZ , next)) + next = ifp->tstamp + + ifp->valid_lft *HZ ; + }spin_unlock (&ifp->lock);
@@ -3804,7 +3809,8 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,put_ifaddrmsg (nlh, ifa->prefix_len, ifa->flags,rt_scope (ifa->scope), ifa->idev->dev->ifindex); -if (!(ifa->flags&IFA_F_PERMANENT )) { +if (!((ifa->flags&IFA_F_PERMANENT ) && + (ifa->prefered_lft ==INFINITY_LIFE_TIME ))) { preferred = ifa->prefered_lft; valid = ifa->valid_lft;if (preferred !=INFINITY_LIFE_TIME ) {
Signature · 1 line
1.7.12.4
Quoted 10 lines · On Sun, Dec 29, 2013 at 04:47:40PM +0900, [email protected] wrote:
From: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting
preferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
This looks much better. I'll give it a try and do a review today.
Quoted 10 lines
Signed-off-by Yasushi Asano <[email protected]>--- net/ipv6/addrconf.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)net/ipv6/addrconf.c +0
-0
net/ipv6/addrconf.c restart: · line 3484
Quoted 7 lines
net/ipv6/addrconf.c +2
-1@@ -3479,7 +3479,8 @@ restart: &inet6_addr_lst[i], addr_lst) {unsigned long age; -if (ifp->flags &IFA_F_PERMANENT ) +if ((ifp->flags &IFA_F_PERMANENT ) && + (ifp->prefered_lft ==INFINITY_LIFE_TIME ))continue ;
I would like to see a comment here why IFA_F_PERMANENT could have a non-infinity life time. Something like that we always handle manually set routes as IFA_F_PERMANENT but those routes could also have a prefered_lft of non-infinity, so we must check if those interface prefix needs to be deprecated.
Quoted 17 lines
net/ipv6/addrconf.c +6
-2spin_lock (&ifp->lock);@@ -3504,8 +3505,12 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } -if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) - next = ifp->tstamp + ifp->valid_lft *HZ ; +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) { +if (time_before (ifp->tstamp + + ifp->valid_lft *HZ , next)) + next = ifp->tstamp + + ifp->valid_lft *HZ ; + }spin_unlock (&ifp->lock);
net/ipv6/addrconf.c static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa, · line 3816
Quoted 9 lines
net/ipv6/addrconf.c +2
-1@@ -3804,7 +3809,8 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,put_ifaddrmsg (nlh, ifa->prefix_len, ifa->flags,rt_scope (ifa->scope), ifa->idev->dev->ifindex); -if (!(ifa->flags&IFA_F_PERMANENT )) { +if (!((ifa->flags&IFA_F_PERMANENT ) && + (ifa->prefered_lft ==INFINITY_LIFE_TIME ))) { preferred = ifa->prefered_lft; valid = ifa->valid_lft;if (preferred !=INFINITY_LIFE_TIME ) {
Thank you,
Hannes
On Sun, Dec 29, 2013 at 04:47:40PM +0900, [email protected] wrote:
Subject: Re: [PATCH] ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
Please a space between addrconf: and fix.
Quoted 20 lines
Fixed a problem with setting the lifetime of an IPv6 address. When setting
preferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)Signed-off-by Yasushi Asano <[email protected]>--- net/ipv6/addrconf.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)net/ipv6/addrconf.c +0
-0
net/ipv6/addrconf.c restart: · line 3484
Quoted 7 lines
net/ipv6/addrconf.c +2
-1@@ -3479,7 +3479,8 @@ restart: &inet6_addr_lst[i], addr_lst) {unsigned long age; -if (ifp->flags &IFA_F_PERMANENT ) +if ((ifp->flags &IFA_F_PERMANENT ) && + (ifp->prefered_lft ==INFINITY_LIFE_TIME ))continue ;
As in the first mail, a comment would be nice how permanent addresses where prefered_lft != INFINITY_LIFE_TIME could come from.
Maybe we could also add this to the header file where IFA_F_PERMANENT is declared. There was recently confusion about that with another patch.
net/ipv6/addrconf.c restart: · line 3513
Quoted 13 lines
net/ipv6/addrconf.c +6
-2spin_lock (&ifp->lock);@@ -3504,8 +3505,12 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } -if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) - next = ifp->tstamp + ifp->valid_lft *HZ ; +if (ifp->valid_lft !=INFINITY_LIFE_TIME ) { +if (time_before (ifp->tstamp + + ifp->valid_lft *HZ , next)) + next = ifp->tstamp + + ifp->valid_lft *HZ ; + }
Please combine the two if-tests here (with &&).
net/ipv6/addrconf.c static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa, · line 3816
Quoted 13 lines
net/ipv6/addrconf.c +2
-1spin_unlock (&ifp->lock);@@ -3804,7 +3809,8 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,put_ifaddrmsg (nlh, ifa->prefix_len, ifa->flags,rt_scope (ifa->scope), ifa->idev->dev->ifindex); -if (!(ifa->flags&IFA_F_PERMANENT )) { +if (!((ifa->flags&IFA_F_PERMANENT ) && + (ifa->prefered_lft ==INFINITY_LIFE_TIME ))) { preferred = ifa->prefered_lft; valid = ifa->valid_lft;if (preferred !=INFINITY_LIFE_TIME ) {
Otherwise the patch looks good and my testing showed no problems.
Thank you!
PATCH 1/1 ipv6 addrconf: fix preferred lifetime state-changing behavior while valid_lft is infinity
From: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting preferred_lft to a value not zero or infinity, while valid_lft is infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
--- net/ipv6/addrconf.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
net/ipv6/addrconf.c +10 -3
@@ -3479,7 +3479,12 @@ restart: &inet6_addr_lst[i], addr_lst) {unsigned long age; -if (ifp->flags &IFA_F_PERMANENT ) +/* When setting preferred_lft to a value not zero or +* infinity, while valid_lft is infinity +* IFA_F_PERMANENT has a non-infinity life time. +*/ +if ((ifp->flags &IFA_F_PERMANENT ) && + (ifp->prefered_lft ==INFINITY_LIFE_TIME ))continue ;spin_lock (&ifp->lock);
@@ -3504,7 +3509,8 @@ restart: ifp->flags |=IFA_F_DEPRECATED ; } -if (time_before (ifp->tstamp + ifp->valid_lft *HZ , next)) +if ((ifp->valid_lft !=INFINITY_LIFE_TIME ) && + (time_before (ifp->tstamp + ifp->valid_lft *HZ , next))) next = ifp->tstamp + ifp->valid_lft *HZ ;spin_unlock (&ifp->lock);
@@ -3804,7 +3810,8 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,put_ifaddrmsg (nlh, ifa->prefix_len, ifa->flags,rt_scope (ifa->scope), ifa->idev->dev->ifindex); -if (!(ifa->flags&IFA_F_PERMANENT )) { +if (!((ifa->flags&IFA_F_PERMANENT ) && + (ifa->prefered_lft ==INFINITY_LIFE_TIME ))) { preferred = ifa->prefered_lft; valid = ifa->valid_lft;if (preferred !=INFINITY_LIFE_TIME ) {
Signature · 1 line
1.7.7.6
Re: [PATCH] ipv6 addrconf: fix preferred lifetime state-changing behavior while valid_lft is infinity
Quoted 12 lines · Yasushi Asano
From: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting
preferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
Quoted 1 line
Signed-off-by Yasushi Asano <[email protected]>
Thanks!
Re: [PATCH] ipv6 addrconf: fix preferred lifetime state-changing behavior while valid_lft is infinity
In reply to Yasushi AsanoFrom: Yasushi Asano <[email protected]>
Date: Tue, 31 Dec 2013 12:04:19 +0900
Quoted 12 lines
From: Yasushi Asano <[email protected]>
Fixed a problem with setting the lifetime of an IPv6 address. When setting
preferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff) preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated. valid lifetime and preferred lifetime should be set independently, even if valid lifetime is infinity, preferred lifetime must expire correctly (meaning it must eventually become deprecated)
Quoted 1 line
Signed-off-by Yasushi Asano <[email protected]>
Applied.
Quoted 12 lines
Ditto, I do think we cannot remove this flag unconditionally.
Actually, I don't think it is the correct way to remove the
IFA_F_PERMANENThere at all. We break the interaction with prefix routes and won't remove them at the time of address deletion any more. This is definitely a no-go, sorry.The prefix was added by hand and should get removed immediately if a user removes the address (well actually it is an error we set up a prefix route in the first place, but it is how things are now).
Quoted 7 lines
IMHO, the changes need to be made in
addrconf_verifyso that the route does get marked as deprecated. Please check the places where we mark an interface address as deprecated.Thanks,
Hannes
Sorry about not getting back to you sooner.
I have been thinking and testing about the correct way of fixing the problem.
I understand it's not the correct way to remove the IFA_F_PERMANENT.
I agree with you that the changes need to be made in addrconf_verify.
and I think changes also need to be made in inet6_fill_ifaddr
so that the "preferred" is set INFINITY_LIFE_TIME unconditionally while ifa->flags is IFA_F_PERMANENT.
It means, "preferred" is set to INFINITY_LIFE_TIME when I set preferred_lft a value not zero or infinity, while valid_lft is infinity(0xffffffff) I sent a new patch to netdev-ml today.
Your kind consideration of this matter would be sincerely appreciated.
Yasushi
Quoted 58 lines
-----Original Message-----
From: Hannes Frederic Sowa [mailto:[email protected]]
Sent: Thursday, December 12, 2013 10:04 AM
To: Asano, Yasushi/浅野 恭史
Cc: [email protected]
Subject: Re: [PATCH 1/1] ipv6 addrconf:fix preferred lifetime state-changing behavior whilevalid_lftis infinity
Importance: HighQuoted 13 lines · Yasushi
Quoted 13 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hannes Frederic Sowa
Sent: Tuesday, December 10, 2013 8:47 AM
To: Asano, Yasushi
Cc: [email protected]
Subject: Re: [PATCH 1/1] ipv6 addrconf:fix preferred lifetime state-changing behavior whilevalid_lftis infinity
Importance: HighQuoted 2 lines · Yasushi
from: Yasushi Asano <[email protected]>
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
There is a problem when setting the lifetime of an IPv6 address. When I set
preferred_lftto a value not zero or infinity, whilevalid_lftis infinity(0xffffffff)
Quoted 4 lines
preferred lifetime is set to forever and does not update. Therefore preferred lifetime never becomes deprecated.
I think valid lifetime and preferred lifetime should be set
independently,
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
even if valid lifetime is infinity, preferred lifetime must expire
correctly (meaning it must eventually become deprecated)
Quoted 2 lines
I made a patch for 3.12 stable to solve the problem.
This indeed could be improved. Thanks for the patch. But you should
base
Quoted 8 lines
Quoted 7 lines
it on net-next so it can be applied and please clean up the warnings and errors if you run the patch through
./scripts/checkpatch--strict.Thank you,
Hannes
I made a patch based on net-next and emailed ML using git send-email last
night.
Quoted 2 lines
Subject: [PATCH 1/1] ipv6 addrconf:fix preferred lifetime state-changing
behavior while
valid_lftis infinityQuoted 2 lines
Date: Wed, 11 Dec 2013 19:57:32 +0900
Message-ID:Quoted 4 lines
X-Mailer: git-send-email 1.7.12.4
Thank you for your time and assistance regarding this matter. Yasushi
Quoted 6 lines
Huch? I have not seen anything nor has patchworks:
http://patchwork.ozlabs.org/project/netdev/list/Greetings,
Hannes
I'm sorry, I couldn't send an email correctly.
I tried it again. but I sent the e-mail twice by mistake. Sorry again.
I sent a patch based on net-next
Subject: [PATCH 1/1] ipv6 addrconf:fix preferred lifetime state-changing behavior while valid_lft is infinity
Date: Thu, 12 Dec 2013 19:15:47 +0900
Message-ID: <[email protected]>
Thank you for your time and assistance regarding this matter. Yasushi