diff options
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> | 2008-04-02 03:01:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-02 03:01:35 -0400 |
commit | eac55bf97094f6b64116426864cf4666ef7587bc (patch) | |
tree | 467776de93a7fdbb75904dbd702f7c417e18aa69 /net/ipv6/addrconf.c | |
parent | c6fbfac2e61c9a8617f64b93e8c990b8d864bce5 (diff) |
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>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r-- | net/ipv6/addrconf.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index e11f10eceffc..e7a1882db048 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -776,6 +776,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *i | |||
776 | struct inet6_dev *idev = ifp->idev; | 776 | struct inet6_dev *idev = ifp->idev; |
777 | struct in6_addr addr, *tmpaddr; | 777 | struct in6_addr addr, *tmpaddr; |
778 | unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_cstamp, tmp_tstamp; | 778 | unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_cstamp, tmp_tstamp; |
779 | unsigned long regen_advance; | ||
779 | int tmp_plen; | 780 | int tmp_plen; |
780 | int ret = 0; | 781 | int ret = 0; |
781 | int max_addresses; | 782 | int max_addresses; |
@@ -836,8 +837,23 @@ retry: | |||
836 | tmp_tstamp = ifp->tstamp; | 837 | tmp_tstamp = ifp->tstamp; |
837 | spin_unlock_bh(&ifp->lock); | 838 | spin_unlock_bh(&ifp->lock); |
838 | 839 | ||
840 | regen_advance = idev->cnf.regen_max_retry * | ||
841 | idev->cnf.dad_transmits * | ||
842 | idev->nd_parms->retrans_time / HZ; | ||
839 | write_unlock(&idev->lock); | 843 | write_unlock(&idev->lock); |
840 | 844 | ||
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 | |||
841 | addr_flags = IFA_F_TEMPORARY; | 857 | addr_flags = IFA_F_TEMPORARY; |
842 | /* set in addrconf_prefix_rcv() */ | 858 | /* set in addrconf_prefix_rcv() */ |
843 | if (ifp->flags & IFA_F_OPTIMISTIC) | 859 | if (ifp->flags & IFA_F_OPTIMISTIC) |