net: sched: cls_matchall: allow to delete filter

Currently user is unable to delete the filter. See following example:
$ tc filter add dev ens16np1 ingress pref 1 handle 1 matchall action drop
$ tc filter show dev ens16np1 ingress
filter protocol all pref 1 matchall chain 0
filter protocol all pref 1 matchall chain 0 handle 0x1
  in_hw
        action order 1: gact action drop
         random type none pass val 0
         index 1 ref 1 bind 1

$ tc filter del dev ens16np1 ingress pref 1 handle 1 matchall action drop
RTNETLINK answers: Operation not supported

Implement tcf_proto_ops->delete() op and allow user to delete the filter.

Reported-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko 2019-06-17 18:02:32 +02:00 committed by David S. Miller
parent ad9bf54519
commit f517f2716c

View File

@ -21,6 +21,7 @@ struct cls_mall_head {
unsigned int in_hw_count; unsigned int in_hw_count;
struct tc_matchall_pcnt __percpu *pf; struct tc_matchall_pcnt __percpu *pf;
struct rcu_work rwork; struct rcu_work rwork;
bool deleting;
}; };
static int mall_classify(struct sk_buff *skb, const struct tcf_proto *tp, static int mall_classify(struct sk_buff *skb, const struct tcf_proto *tp,
@ -258,7 +259,11 @@ err_exts_init:
static int mall_delete(struct tcf_proto *tp, void *arg, bool *last, static int mall_delete(struct tcf_proto *tp, void *arg, bool *last,
bool rtnl_held, struct netlink_ext_ack *extack) bool rtnl_held, struct netlink_ext_ack *extack)
{ {
return -EOPNOTSUPP; struct cls_mall_head *head = rtnl_dereference(tp->root);
head->deleting = true;
*last = true;
return 0;
} }
static void mall_walk(struct tcf_proto *tp, struct tcf_walker *arg, static void mall_walk(struct tcf_proto *tp, struct tcf_walker *arg,
@ -269,7 +274,7 @@ static void mall_walk(struct tcf_proto *tp, struct tcf_walker *arg,
if (arg->count < arg->skip) if (arg->count < arg->skip)
goto skip; goto skip;
if (!head) if (!head || head->deleting)
return; return;
if (arg->fn(tp, head, arg) < 0) if (arg->fn(tp, head, arg) < 0)
arg->stop = 1; arg->stop = 1;