Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfrm: do the garbage collection after flushing policy

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>

authored by

Xin Long and committed by
Steffen Klassert
35db0691 fd2c83b3

+4
+4
net/xfrm/xfrm_policy.c
··· 1006 1006 err = -ESRCH; 1007 1007 out: 1008 1008 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); 1009 + 1010 + if (cnt) 1011 + xfrm_garbage_collect(net); 1012 + 1009 1013 return err; 1010 1014 } 1011 1015 EXPORT_SYMBOL(xfrm_policy_flush);