Skip to content

Commit

Permalink
netns xfrm: flush SA/SPDs on netns stop
Browse files Browse the repository at this point in the history
SA/SPD doesn't pin netns (and it shouldn't), so get rid of them by hand.

Signed-off-by: Alexey Dobriyan <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and davem330 committed Nov 26, 2008
1 parent fbda33b commit 7c2776e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions net/xfrm/xfrm_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2441,9 +2441,23 @@ static int __net_init xfrm_policy_init(struct net *net)

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++) {
Expand Down
8 changes: 8 additions & 0 deletions net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -2114,8 +2114,16 @@ int __net_init xfrm_state_init(struct net *net)

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);
Expand Down

0 comments on commit 7c2776e

Please sign in to comment.