Skip to content

Commit eac55bf

Browse files
Benoit Boissinotdavem330
authored andcommitted
IPv6: do not create temporary adresses with too short preferred lifetime
From RFC341: A temporary address is created only if this calculated Preferred Lifetime is greater than REGEN_ADVANCE time units. In particular, an implementation must not create a temporary address with a zero Preferred Lifetime. Signed-off-by: Benoit Boissinot <benoit.boissinot@ens-lyon.org> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c6fbfac commit eac55bf

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎net/ipv6/addrconf.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *i
776776
struct inet6_dev *idev = ifp->idev;
777777
struct in6_addr addr, *tmpaddr;
778778
unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_cstamp, tmp_tstamp;
779+
unsigned long regen_advance;
779780
int tmp_plen;
780781
int ret = 0;
781782
int max_addresses;
@@ -836,8 +837,23 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *i
836837
tmp_tstamp = ifp->tstamp;
837838
spin_unlock_bh(&ifp->lock);
838839

840+
regen_advance = idev->cnf.regen_max_retry *
841+
idev->cnf.dad_transmits *
842+
idev->nd_parms->retrans_time / HZ;
839843
write_unlock(&idev->lock);
840844

845+
/* A temporary address is created only if this calculated Preferred
846+
* Lifetime is greater than REGEN_ADVANCE time units. In particular,
847+
* an implementation must not create a temporary address with a zero
848+
* Preferred Lifetime.
849+
*/
850+
if (tmp_prefered_lft <= regen_advance) {
851+
in6_ifa_put(ifp);
852+
in6_dev_put(idev);
853+
ret = -1;
854+
goto out;
855+
}
856+
841857
addr_flags = IFA_F_TEMPORARY;
842858
/* set in addrconf_prefix_rcv() */
843859
if (ifp->flags & IFA_F_OPTIMISTIC)

0 commit comments

Comments
 (0)