]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/ipv6/route.c
ipv6: remove from fib tree aged out RTF_CACHE dst
[linux.git] / net / ipv6 / route.c
index 13b0d6d1cc303cab6d86b3e11fde73f7cba08fd8..074fac966018be8a3943ccc438045f77718f98a1 100644 (file)
@@ -1142,10 +1142,12 @@ static DEFINE_SPINLOCK(rt6_exception_lock);
 static void rt6_remove_exception(struct rt6_exception_bucket *bucket,
                                 struct rt6_exception *rt6_ex)
 {
-       struct net *net = dev_net(rt6_ex->rt6i->dst.dev);
+       struct net *net;
 
        if (!bucket || !rt6_ex)
                return;
+
+       net = dev_net(rt6_ex->rt6i->dst.dev);
        rt6_ex->rt6i->rt6i_node = NULL;
        hlist_del_rcu(&rt6_ex->hlist);
        rt6_release(rt6_ex->rt6i);
@@ -1338,8 +1340,10 @@ static int rt6_insert_exception(struct rt6_info *nrt,
        spin_unlock_bh(&rt6_exception_lock);
 
        /* Update fn->fn_sernum to invalidate all cached dst */
-       if (!err)
+       if (!err) {
                fib6_update_sernum(ort);
+               fib6_force_start_gc(net);
+       }
 
        return err;
 }
@@ -1413,7 +1417,7 @@ int rt6_remove_exception_rt(struct rt6_info *rt)
        int err;
 
        if (!from ||
-           !(rt->rt6i_flags | RTF_CACHE))
+           !(rt->rt6i_flags & RTF_CACHE))
                return -EINVAL;
 
        if (!rcu_access_pointer(from->rt6i_exception_bucket))
@@ -1457,7 +1461,7 @@ static void rt6_update_exception_stamp_rt(struct rt6_info *rt)
        struct rt6_exception *rt6_ex;
 
        if (!from ||
-           !(rt->rt6i_flags | RTF_CACHE))
+           !(rt->rt6i_flags & RTF_CACHE))
                return;
 
        rcu_read_lock();
@@ -1571,7 +1575,13 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
 {
        struct rt6_info *rt = rt6_ex->rt6i;
 
-       if (atomic_read(&rt->dst.__refcnt) == 1 &&
+       /* we are pruning and obsoleting aged-out and non gateway exceptions
+        * even if others have still references to them, so that on next
+        * dst_check() such references can be dropped.
+        * EXPIRES exceptions - e.g. pmtu-generated ones are pruned when
+        * expired, independently from their aging, as per RFC 8201 section 4
+        */
+       if (!(rt->rt6i_flags & RTF_EXPIRES) &&
            time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
                RT6_TRACE("aging clone %p\n", rt);
                rt6_remove_exception(bucket, rt6_ex);
@@ -1591,6 +1601,10 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
                        rt6_remove_exception(bucket, rt6_ex);
                        return;
                }
+       } else if (__rt6_check_expired(rt)) {
+               RT6_TRACE("purging expired route %p\n", rt);
+               rt6_remove_exception(bucket, rt6_ex);
+               return;
        }
        gc_args->more++;
 }