diff options
-rw-r--r-- | net/key/af_key.c | 5 | ||||
-rw-r--r-- | net/xfrm/xfrm_state.c | 8 | ||||
-rw-r--r-- | net/xfrm/xfrm_user.c | 5 |
3 files changed, 14 insertions, 4 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c index b3faede9a4f6..c269ce6094d6 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -1768,8 +1768,11 @@ static int pfkey_flush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hd | |||
1768 | audit_info.secid = 0; | 1768 | audit_info.secid = 0; |
1769 | err = xfrm_state_flush(net, proto, &audit_info); | 1769 | err = xfrm_state_flush(net, proto, &audit_info); |
1770 | err2 = unicast_flush_resp(sk, hdr); | 1770 | err2 = unicast_flush_resp(sk, hdr); |
1771 | if (err || err2) | 1771 | if (err || err2) { |
1772 | if (err == -ESRCH) /* empty table - go quietly */ | ||
1773 | err = 0; | ||
1772 | return err ? err : err2; | 1774 | return err ? err : err2; |
1775 | } | ||
1773 | 1776 | ||
1774 | c.data.proto = proto; | 1777 | c.data.proto = proto; |
1775 | c.seq = hdr->sadb_msg_seq; | 1778 | c.seq = hdr->sadb_msg_seq; |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index c9d6a5f1348d..9fa3322b2a7d 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -603,13 +603,14 @@ xfrm_state_flush_secctx_check(struct net *net, u8 proto, struct xfrm_audit *audi | |||
603 | 603 | ||
604 | int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info) | 604 | int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info) |
605 | { | 605 | { |
606 | int i, err = 0; | 606 | int i, err = 0, cnt = 0; |
607 | 607 | ||
608 | spin_lock_bh(&xfrm_state_lock); | 608 | spin_lock_bh(&xfrm_state_lock); |
609 | err = xfrm_state_flush_secctx_check(net, proto, audit_info); | 609 | err = xfrm_state_flush_secctx_check(net, proto, audit_info); |
610 | if (err) | 610 | if (err) |
611 | goto out; | 611 | goto out; |
612 | 612 | ||
613 | err = -ESRCH; | ||
613 | for (i = 0; i <= net->xfrm.state_hmask; i++) { | 614 | for (i = 0; i <= net->xfrm.state_hmask; i++) { |
614 | struct hlist_node *entry; | 615 | struct hlist_node *entry; |
615 | struct xfrm_state *x; | 616 | struct xfrm_state *x; |
@@ -626,13 +627,16 @@ restart: | |||
626 | audit_info->sessionid, | 627 | audit_info->sessionid, |
627 | audit_info->secid); | 628 | audit_info->secid); |
628 | xfrm_state_put(x); | 629 | xfrm_state_put(x); |
630 | if (!err) | ||
631 | cnt++; | ||
629 | 632 | ||
630 | spin_lock_bh(&xfrm_state_lock); | 633 | spin_lock_bh(&xfrm_state_lock); |
631 | goto restart; | 634 | goto restart; |
632 | } | 635 | } |
633 | } | 636 | } |
634 | } | 637 | } |
635 | err = 0; | 638 | if (cnt) |
639 | err = 0; | ||
636 | 640 | ||
637 | out: | 641 | out: |
638 | spin_unlock_bh(&xfrm_state_lock); | 642 | spin_unlock_bh(&xfrm_state_lock); |
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 943c8712bd97..cd94a9dd1bad 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -1524,8 +1524,11 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1524 | audit_info.sessionid = NETLINK_CB(skb).sessionid; | 1524 | audit_info.sessionid = NETLINK_CB(skb).sessionid; |
1525 | audit_info.secid = NETLINK_CB(skb).sid; | 1525 | audit_info.secid = NETLINK_CB(skb).sid; |
1526 | err = xfrm_state_flush(net, p->proto, &audit_info); | 1526 | err = xfrm_state_flush(net, p->proto, &audit_info); |
1527 | if (err) | 1527 | if (err) { |
1528 | if (err == -ESRCH) /* empty table */ | ||
1529 | return 0; | ||
1528 | return err; | 1530 | return err; |
1531 | } | ||
1529 | c.data.proto = p->proto; | 1532 | c.data.proto = p->proto; |
1530 | c.event = nlh->nlmsg_type; | 1533 | c.event = nlh->nlmsg_type; |
1531 | c.seq = nlh->nlmsg_seq; | 1534 | c.seq = nlh->nlmsg_seq; |