Commit fad8da3e authored by Yasushi Asano's avatar Yasushi Asano Committed by David S. Miller

ipv6 addrconf: fix preferred lifetime state-changing behavior while valid_lft is infinity

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)
Signed-off-by: default avatarYasushi Asano <yasushi.asano@jp.fujitsu.com>
Acked-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4d231b76
...@@ -3456,7 +3456,12 @@ static void addrconf_verify(unsigned long foo) ...@@ -3456,7 +3456,12 @@ static void addrconf_verify(unsigned long foo)
&inet6_addr_lst[i], addr_lst) { &inet6_addr_lst[i], addr_lst) {
unsigned long age; 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; continue;
spin_lock(&ifp->lock); spin_lock(&ifp->lock);
...@@ -3481,7 +3486,8 @@ static void addrconf_verify(unsigned long foo) ...@@ -3481,7 +3486,8 @@ static void addrconf_verify(unsigned long foo)
ifp->flags |= IFA_F_DEPRECATED; 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; next = ifp->tstamp + ifp->valid_lft * HZ;
spin_unlock(&ifp->lock); spin_unlock(&ifp->lock);
...@@ -3761,7 +3767,8 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa, ...@@ -3761,7 +3767,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), put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope),
ifa->idev->dev->ifindex); 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; preferred = ifa->prefered_lft;
valid = ifa->valid_lft; valid = ifa->valid_lft;
if (preferred != INFINITY_LIFE_TIME) { if (preferred != INFINITY_LIFE_TIME) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment