Skip to content

Commit b75326c

Browse files
fgontdavem330
authored andcommitted
ipv6: Honor all IPv6 PIO Valid Lifetime values
RFC4862 5.5.3 e) prevents received Router Advertisements from reducing the Valid Lifetime of configured addresses to less than two hours, thus preventing hosts from reacting to the information provided by a router that has positive knowledge that a prefix has become invalid. This patch makes hosts honor all Valid Lifetime values, as per draft-gont-6man-slaac-renum-06, Section 4.2. This is meant to help mitigate the problem discussed in draft-ietf-v6ops-slaac-renum. Note: Attacks aiming at disabling an advertised prefix via a Valid Lifetime of 0 are not really more harmful than other attacks that can be performed via forged RA messages, such as those aiming at completely disabling a next-hop router via an RA that advertises a Router Lifetime of 0, or performing a Denial of Service (DoS) attack by advertising illegitimate prefixes via forged PIOs. In scenarios where RA-based attacks are of concern, proper mitigations such as RA-Guard [RFC6105] [RFC7113] should be implemented. Signed-off-by: Fernando Gont <fgont@si6networks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 30685b2 commit b75326c

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

include/net/addrconf.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#define RTR_SOLICITATION_INTERVAL (4*HZ)
77
#define RTR_SOLICITATION_MAX_INTERVAL (3600*HZ) /* 1 hour */
88

9-
#define MIN_VALID_LIFETIME (2*3600) /* 2 hours */
10-
119
#define TEMP_VALID_LIFETIME (7*86400)
1210
#define TEMP_PREFERRED_LIFETIME (86400)
1311
#define REGEN_MAX_RETRY (3)

net/ipv6/addrconf.c

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,7 +2564,7 @@ int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
25642564
__u32 valid_lft, u32 prefered_lft)
25652565
{
25662566
struct inet6_ifaddr *ifp = ipv6_get_ifaddr(net, addr, dev, 1);
2567-
int create = 0, update_lft = 0;
2567+
int create = 0;
25682568

25692569
if (!ifp && valid_lft) {
25702570
int max_addresses = in6_dev->cnf.max_addresses;
@@ -2608,32 +2608,19 @@ int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
26082608
unsigned long now;
26092609
u32 stored_lft;
26102610

2611-
/* update lifetime (RFC2462 5.5.3 e) */
2611+
/* Update lifetime (RFC4862 5.5.3 e)
2612+
* We deviate from RFC4862 by honoring all Valid Lifetimes to
2613+
* improve the reaction of SLAAC to renumbering events
2614+
* (draft-gont-6man-slaac-renum-06, Section 4.2)
2615+
*/
26122616
spin_lock_bh(&ifp->lock);
26132617
now = jiffies;
26142618
if (ifp->valid_lft > (now - ifp->tstamp) / HZ)
26152619
stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ;
26162620
else
26172621
stored_lft = 0;
2618-
if (!create && stored_lft) {
2619-
const u32 minimum_lft = min_t(u32,
2620-
stored_lft, MIN_VALID_LIFETIME);
2621-
valid_lft = max(valid_lft, minimum_lft);
2622-
2623-
/* RFC4862 Section 5.5.3e:
2624-
* "Note that the preferred lifetime of the
2625-
* corresponding address is always reset to
2626-
* the Preferred Lifetime in the received
2627-
* Prefix Information option, regardless of
2628-
* whether the valid lifetime is also reset or
2629-
* ignored."
2630-
*
2631-
* So we should always update prefered_lft here.
2632-
*/
2633-
update_lft = 1;
2634-
}
26352622

2636-
if (update_lft) {
2623+
if (!create && stored_lft) {
26372624
ifp->valid_lft = valid_lft;
26382625
ifp->prefered_lft = prefered_lft;
26392626
ifp->tstamp = now;

0 commit comments

Comments
 (0)