Skip to contentSkip to conversation

Don't generate a temporary address for deprecated addresses

PATCH New Benoit Boissinot 1 participant 3 messages Mar 18, 2008 – Mar 19, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't generate a temporary address for deprecated addresses

The RFC states that if the preferred lifetime is less than REGEN_ADVANCE, no temporary address should be created.

net/ipv6/addrconf.c +17 -0
index 101e0e7..5d0e404 100644 
@@ -776,6 +776,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *i 
        struct inet6_dev *idev = ifp->idev; 
        struct in6_addr addr, *tmpaddr; 
        unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_cstamp, tmp_tstamp; 
+       unsigned long regen_advance; 
        int tmp_plen; 
        int ret = 0; 
        int max_addresses; 
@@ -838,6 +839,22 @@ retry: 
  
        write_unlock(&idev->lock); 
  
+       regen_advance = ifp->idev->cnf.regen_max_retry * 
+                       ifp->idev->cnf.dad_transmits * 
+                       ifp->idev->nd_parms->retrans_time / HZ; 
+ 
+       /* 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. 
+        */ 
+       if (tmp_prefered_lft <= regen_advance) { 
+               in6_ifa_put(ifp); 
+               in6_dev_put(idev); 
+               ret = -1; 
+               goto out; 
+       } 
+ 
        addr_flags = IFA_F_TEMPORARY;
        /* set in addrconf_prefix_rcv() */
        if (ifp->flags & IFA_F_OPTIMISTIC)
Signature · 1 line
:wq
#1 lore raw

PATCH 1/1 convert to mod_timer

Convert addrconf_verify to mod_timer

net/ipv6/addrconf.c +1 -4
index 101e0e7..5d0e404 100644
@@ -2922,8 +2943,6 @@ static void addrconf_verify(unsigned long foo)
        now = jiffies;
        next = now + ADDR_CHECK_FREQUENCY;
 
-       del_timer(&addr_chk_timer);
-
        for (i=0; i < IN6_ADDR_HSIZE; i++) {
 
 restart:
@@ -3013,8 +3032,7 @@ restart:
                read_unlock(&addrconf_hash_lock);
        }
 
-       addr_chk_timer.expires = time_before(next, jiffies + HZ) ? jiffies + HZ : next;
-       add_timer(&addr_chk_timer);
+       mod_timer(&addr_chk_timer, time_before(next, jiffies + HZ) ? jiffies + HZ : next);
        spin_unlock_bh(&addrconf_verify_lock);
 }
 
Signature · 1 line
:wq
#2 lore raw

Re: [PATCH] [IPv6] [trivial] convert to mod_timer

Quoted 1 line · Benoit Boissinot

Convert addrconf_verify to mod_timer

after some reflexion, this patch is probably wrong, since addrconf_verify is called from outside the timer too.

sorry,

Benoit

Quoted 29 lines
net/ipv6/addrconf.c +1 -4
index 101e0e7..5d0e404 100644
@@ -2922,8 +2943,6 @@ static void addrconf_verify(unsigned long foo)
        now = jiffies;
        next = now + ADDR_CHECK_FREQUENCY;
 
-       del_timer(&addr_chk_timer);
-
        for (i=0; i < IN6_ADDR_HSIZE; i++) {
 
 restart:
@@ -3013,8 +3032,7 @@ restart:
                read_unlock(&addrconf_hash_lock);
        }
 
-       addr_chk_timer.expires = time_before(next, jiffies + HZ) ? jiffies + HZ : next;
-       add_timer(&addr_chk_timer);
+       mod_timer(&addr_chk_timer, time_before(next, jiffies + HZ) ? jiffies + HZ : next);
        spin_unlock_bh(&addrconf_verify_lock);
 }
 
Signature · 2 lines
-- 
:wq
Signature · 1 line
:wq