netns xfrm: flush SA/SPDs on netns stop
authorAlexey Dobriyan <adobriyan@gmail.com>
Wed, 26 Nov 2008 01:57:44 +0000 (17:57 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Nov 2008 01:57:44 +0000 (17:57 -0800)
SA/SPD doesn't pin netns (and it shouldn't), so get rid of them by hand.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_state.c

index 7c7bb54f22657500ed9722fdf13bf30ef2801d21..fcf8c928285af2ac2e56b80a81252750c2cf5858 100644 (file)
@@ -2441,9 +2441,23 @@ out_byidx:
 
 static void xfrm_policy_fini(struct net *net)
 {
+       struct xfrm_audit audit_info;
        unsigned int sz;
        int dir;
 
+       flush_work(&net->xfrm.policy_hash_work);
+#ifdef CONFIG_XFRM_SUB_POLICY
+       audit_info.loginuid = -1;
+       audit_info.sessionid = -1;
+       audit_info.secid = 0;
+       xfrm_policy_flush(net, XFRM_POLICY_TYPE_SUB, &audit_info);
+#endif
+       audit_info.loginuid = -1;
+       audit_info.sessionid = -1;
+       audit_info.secid = 0;
+       xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, &audit_info);
+       flush_work(&xfrm_policy_gc_work);
+
        WARN_ON(!list_empty(&net->xfrm.policy_all));
 
        for (dir = 0; dir < XFRM_POLICY_MAX * 2; dir++) {
index d594b5af5f6b1bece8d1b81e79350faf372cf133..662e47b0bcc3c576a529f636c4ffe9ad52896259 100644 (file)
@@ -2114,8 +2114,16 @@ out_bydst:
 
 void xfrm_state_fini(struct net *net)
 {
+       struct xfrm_audit audit_info;
        unsigned int sz;
 
+       flush_work(&net->xfrm.state_hash_work);
+       audit_info.loginuid = -1;
+       audit_info.sessionid = -1;
+       audit_info.secid = 0;
+       xfrm_state_flush(net, IPSEC_PROTO_ANY, &audit_info);
+       flush_work(&net->xfrm.state_gc_work);
+
        WARN_ON(!list_empty(&net->xfrm.state_all));
 
        sz = (net->xfrm.state_hmask + 1) * sizeof(struct hlist_head);