ipv6: Clamp reported valid_lft to a minimum of 0
Subsystems (3)
PATCH 1/2 ipv6: Clamp reported valid_lft to a minimum of 0
Since addresses are only revalidated every 2 minutes, the reported valid_lft can underflow shortly before the address is deleted. Clamp it to a minimum of 0, as for prefered_lft.
---
This is compile-tested only. I don't claim any familiarity with this code.
Ben.
net/ipv6/addrconf.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
net/ipv6/addrconf.c +6 -2
@@ -3492,8 +3492,12 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa, preferred -= tval; else preferred =0 ; -if (valid !=INFINITY_LIFE_TIME ) - valid -= tval; +if (valid !=INFINITY_LIFE_TIME ) { +if (valid > tval) + valid -= tval; +else + valid =0 ; + } } }else { preferred =INFINITY_LIFE_TIME ;
Signature · 1 line
1.7.1
PATCH 2/2 ipv6: Use interface max_desync_factor instead of static default
max_desync_factor can be configured per-interface, but nothing is using the value.
---
Also compile-tested only.
Note that there is nothing to stop temp_prefered_lft being set smaller than max_desync_factor, which can result in underflow in calculation of tmp_prefered_lft in ipv6_create_tempaddr(). However, the same applies to the current static variable desync_factor.
Ben.
net/ipv6/addrconf.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
net/ipv6/addrconf.c +4 -4
@@ -121,8 +121,6 @@ static inline void addrconf_sysctl_unregister(struct inet6_dev *idev)static int __ipv6_regen_rndid (struct inet6_dev *idev);static int __ipv6_try_regen_rndid (struct inet6_dev *idev,struct in6_addr *tmpaddr);static void ipv6_regen_rndid (unsigned long data); - -static int desync_factor =MAX_DESYNC_FACTOR *HZ ;#endif static int ipv6_generate_eui64 (u8 *eui,struct net_device *dev);
@@ -890,7 +888,8 @@ retry: idev->cnf.temp_valid_lft); tmp_prefered_lft =min_t (__u32, ifp->prefered_lft, - idev->cnf.temp_prefered_lft - desync_factor /HZ ); + idev->cnf.temp_prefered_lft - + idev->cnf.max_desync_factor); tmp_plen = ifp->prefix_len; max_addresses = idev->cnf.max_addresses; tmp_cstamp = ifp->cstamp;
@@ -1650,7 +1649,8 @@ static void ipv6_regen_rndid(unsigned long data) expires = jiffies + idev->cnf.temp_prefered_lft *HZ - - idev->cnf.regen_max_retry * idev->cnf.dad_transmits * idev->nd_parms->retrans_time - desync_factor; + idev->cnf.regen_max_retry * idev->cnf.dad_transmits * idev->nd_parms->retrans_time - + idev->cnf.max_desync_factor *HZ ;if (time_before (expires, jiffies)) { printk(KERN_WARNING "ipv6_regen_rndid(): too short regeneration interval; timer disabled for %s.\n",
Signature · 1 line
1.7.1
Re: [PATCH 2/2] ipv6: Use interface max_desync_factor instead of static default
From: Ben Hutchings <[email protected]>
Date: Sat, 26 Jun 2010 22:42:55 +0100
Quoted 5 lines
max_desync_factorcan be configured per-interface, but nothing is using the value.Reported-by Piotr Lewandowski <[email protected]>Signed-off-by Ben Hutchings <[email protected]>
Applied to net-next-2.6
From: Ben Hutchings <[email protected]>
Date: Sat, 26 Jun 2010 22:37:47 +0100
Quoted 6 lines
Since addresses are only revalidated every 2 minutes, the reported
valid_lftcan underflow shortly before the address is deleted. Clamp it to a minimum of 0, as forprefered_lft.Reported-by Piotr Lewandowski <[email protected]>Signed-off-by Ben Hutchings <[email protected]>
Applied to net-next-2.6