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

net_sched: allow flushing tc police actions

The act_police uses its own code to walk the
action hashtable, which leads to that we could
not flush standalone tc police actions, so just
switch to tcf_generic_walker() like other actions.

(Joint work from Roman and Cong.)

Signed-off-by: Roman Mashak <mrv@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Roman Mashak and committed by
David S. Miller
b5ac8518 0852e455

+1 -42
+1 -42
net/sched/act_police.c
··· 63 63 const struct tc_action_ops *ops) 64 64 { 65 65 struct tc_action_net *tn = net_generic(net, police_net_id); 66 - struct tcf_hashinfo *hinfo = tn->hinfo; 67 - int err = 0, index = -1, i = 0, s_i = 0, n_i = 0; 68 - struct nlattr *nest; 69 66 70 - spin_lock_bh(&hinfo->lock); 71 - 72 - s_i = cb->args[0]; 73 - 74 - for (i = 0; i < (POL_TAB_MASK + 1); i++) { 75 - struct hlist_head *head; 76 - struct tc_action *p; 77 - 78 - head = &hinfo->htab[tcf_hash(i, POL_TAB_MASK)]; 79 - 80 - hlist_for_each_entry_rcu(p, head, tcfa_head) { 81 - index++; 82 - if (index < s_i) 83 - continue; 84 - nest = nla_nest_start(skb, index); 85 - if (nest == NULL) 86 - goto nla_put_failure; 87 - if (type == RTM_DELACTION) 88 - err = tcf_action_dump_1(skb, p, 0, 1); 89 - else 90 - err = tcf_action_dump_1(skb, p, 0, 0); 91 - if (err < 0) { 92 - index--; 93 - nla_nest_cancel(skb, nest); 94 - goto done; 95 - } 96 - nla_nest_end(skb, nest); 97 - n_i++; 98 - } 99 - } 100 - done: 101 - spin_unlock_bh(&hinfo->lock); 102 - if (n_i) 103 - cb->args[0] += n_i; 104 - return n_i; 105 - 106 - nla_put_failure: 107 - nla_nest_cancel(skb, nest); 108 - goto done; 67 + return tcf_generic_walker(tn, skb, cb, type, ops); 109 68 } 110 69 111 70 static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = {