]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
xfrm: do the garbage collection after flushing policy
authorXin Long <lucien.xin@gmail.com>
Mon, 24 Apr 2017 07:33:39 +0000 (15:33 +0800)
committerSteffen Klassert <steffen.klassert@secunet.com>
Wed, 26 Apr 2017 08:34:32 +0000 (10:34 +0200)
Now xfrm garbage collection can be triggered by 'ip xfrm policy del'.
These is no reason not to do it after flushing policies, especially
considering that 'garbage collection deferred' is only triggered
when it reaches gc_thresh.

It's no good that the policy is gone but the xdst still hold there.
The worse thing is that xdst->route/orig_dst is also hold and can
not be released even if the orig_dst is already expired.

This patch is to do the garbage collection if there is any policy
removed in xfrm_policy_flush.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_policy.c

index 236cbbc0ab9cfff05cd027ffb0dc56aa15e61033..dfc77b9c5e5a8dd2b31440be47fb4480513680e1 100644 (file)
@@ -1006,6 +1006,10 @@ int xfrm_policy_flush(struct net *net, u8 type, bool task_valid)
                err = -ESRCH;
 out:
        spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
+
+       if (cnt)
+               xfrm_garbage_collect(net);
+
        return err;
 }
 EXPORT_SYMBOL(xfrm_policy_flush);