Commit 069c474e88bb7753183f1eadbd7786c27888c8e3
1 parent
08326dbe7b
Exists in
master
and in
39 other branches
xfrm: Revert false event eliding commits.
As reported by Alexey Dobriyan: -------------------- setkey now takes several seconds to run this simple script and it spits "recv: Resource temporarily unavailable" messages. #!/usr/sbin/setkey -f flush; spdflush; add A B ipcomp 44 -m tunnel -C deflate; add B A ipcomp 45 -m tunnel -C deflate; spdadd A B any -P in ipsec ipcomp/tunnel/192.168.1.2-192.168.1.3/use; spdadd B A any -P out ipsec ipcomp/tunnel/192.168.1.3-192.168.1.2/use; -------------------- Obviously applications want the events even when the table is empty. So we cannot make this behavioral change. Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 4 changed files with 9 additions and 20 deletions Side-by-side Diff
net/key/af_key.c
... | ... | @@ -1751,7 +1751,7 @@ |
1751 | 1751 | audit_info.secid = 0; |
1752 | 1752 | err = xfrm_state_flush(net, proto, &audit_info); |
1753 | 1753 | if (err) |
1754 | - return 0; | |
1754 | + return err; | |
1755 | 1755 | c.data.proto = proto; |
1756 | 1756 | c.seq = hdr->sadb_msg_seq; |
1757 | 1757 | c.pid = hdr->sadb_msg_pid; |
... | ... | @@ -2713,7 +2713,7 @@ |
2713 | 2713 | audit_info.secid = 0; |
2714 | 2714 | err = xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, &audit_info); |
2715 | 2715 | if (err) |
2716 | - return 0; | |
2716 | + return err; | |
2717 | 2717 | c.data.type = XFRM_POLICY_TYPE_MAIN; |
2718 | 2718 | c.event = XFRM_MSG_FLUSHPOLICY; |
2719 | 2719 | c.pid = hdr->sadb_msg_pid; |
net/xfrm/xfrm_policy.c
... | ... | @@ -771,8 +771,7 @@ |
771 | 771 | |
772 | 772 | int xfrm_policy_flush(struct net *net, u8 type, struct xfrm_audit *audit_info) |
773 | 773 | { |
774 | - int dir, err = 0, cnt = 0; | |
775 | - struct xfrm_policy *dp; | |
774 | + int dir, err = 0; | |
776 | 775 | |
777 | 776 | write_lock_bh(&xfrm_policy_lock); |
778 | 777 | |
779 | 778 | |
... | ... | @@ -790,10 +789,8 @@ |
790 | 789 | &net->xfrm.policy_inexact[dir], bydst) { |
791 | 790 | if (pol->type != type) |
792 | 791 | continue; |
793 | - dp = __xfrm_policy_unlink(pol, dir); | |
792 | + __xfrm_policy_unlink(pol, dir); | |
794 | 793 | write_unlock_bh(&xfrm_policy_lock); |
795 | - if (dp) | |
796 | - cnt++; | |
797 | 794 | |
798 | 795 | xfrm_audit_policy_delete(pol, 1, audit_info->loginuid, |
799 | 796 | audit_info->sessionid, |
800 | 797 | |
... | ... | @@ -812,10 +809,8 @@ |
812 | 809 | bydst) { |
813 | 810 | if (pol->type != type) |
814 | 811 | continue; |
815 | - dp = __xfrm_policy_unlink(pol, dir); | |
812 | + __xfrm_policy_unlink(pol, dir); | |
816 | 813 | write_unlock_bh(&xfrm_policy_lock); |
817 | - if (dp) | |
818 | - cnt++; | |
819 | 814 | |
820 | 815 | xfrm_audit_policy_delete(pol, 1, |
821 | 816 | audit_info->loginuid, |
... | ... | @@ -829,8 +824,6 @@ |
829 | 824 | } |
830 | 825 | |
831 | 826 | } |
832 | - if (!cnt) | |
833 | - err = -ESRCH; | |
834 | 827 | atomic_inc(&flow_cache_genid); |
835 | 828 | out: |
836 | 829 | write_unlock_bh(&xfrm_policy_lock); |
net/xfrm/xfrm_state.c
... | ... | @@ -603,14 +603,13 @@ |
603 | 603 | |
604 | 604 | int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info) |
605 | 605 | { |
606 | - int i, err = 0, cnt = 0; | |
606 | + int i, err = 0; | |
607 | 607 | |
608 | 608 | spin_lock_bh(&xfrm_state_lock); |
609 | 609 | err = xfrm_state_flush_secctx_check(net, proto, audit_info); |
610 | 610 | if (err) |
611 | 611 | goto out; |
612 | 612 | |
613 | - err = -ESRCH; | |
614 | 613 | for (i = 0; i <= net->xfrm.state_hmask; i++) { |
615 | 614 | struct hlist_node *entry; |
616 | 615 | struct xfrm_state *x; |
617 | 616 | |
... | ... | @@ -627,16 +626,13 @@ |
627 | 626 | audit_info->sessionid, |
628 | 627 | audit_info->secid); |
629 | 628 | xfrm_state_put(x); |
630 | - if (!err) | |
631 | - cnt++; | |
632 | 629 | |
633 | 630 | spin_lock_bh(&xfrm_state_lock); |
634 | 631 | goto restart; |
635 | 632 | } |
636 | 633 | } |
637 | 634 | } |
638 | - if (cnt) | |
639 | - err = 0; | |
635 | + err = 0; | |
640 | 636 | |
641 | 637 | out: |
642 | 638 | spin_unlock_bh(&xfrm_state_lock); |
net/xfrm/xfrm_user.c
... | ... | @@ -1525,7 +1525,7 @@ |
1525 | 1525 | audit_info.secid = NETLINK_CB(skb).sid; |
1526 | 1526 | err = xfrm_state_flush(net, p->proto, &audit_info); |
1527 | 1527 | if (err) |
1528 | - return 0; | |
1528 | + return err; | |
1529 | 1529 | c.data.proto = p->proto; |
1530 | 1530 | c.event = nlh->nlmsg_type; |
1531 | 1531 | c.seq = nlh->nlmsg_seq; |
... | ... | @@ -1677,7 +1677,7 @@ |
1677 | 1677 | audit_info.secid = NETLINK_CB(skb).sid; |
1678 | 1678 | err = xfrm_policy_flush(net, type, &audit_info); |
1679 | 1679 | if (err) |
1680 | - return 0; | |
1680 | + return err; | |
1681 | 1681 | c.data.type = type; |
1682 | 1682 | c.event = nlh->nlmsg_type; |
1683 | 1683 | c.seq = nlh->nlmsg_seq; |