Commit f93e1cdc authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

net/sched: fix filter flushing

When user instructs to remove all filters from chain, we cannot destroy
the chain as other actions may hold a reference. Also the put in errout
would try to destroy it again. So instead, just walk the chain and remove
all existing filters.

Fixes: 5bc17018 ("net: sched: introduce multichain support for filters")
Signed-off-by: default avatarJiri Pirko <>
Acked-by: default avatarCong Wang <>
Signed-off-by: default avatarDavid S. Miller <>
parent 31efcc25
......@@ -201,15 +201,22 @@ static struct tcf_chain *tcf_chain_create(struct tcf_block *block,
return chain;
static void tcf_chain_destroy(struct tcf_chain *chain)
static void tcf_chain_flush(struct tcf_chain *chain)
struct tcf_proto *tp;
if (*chain->p_filter_chain)
RCU_INIT_POINTER(*chain->p_filter_chain, NULL);
while ((tp = rtnl_dereference(chain->filter_chain)) != NULL) {
RCU_INIT_POINTER(chain->filter_chain, tp->next);
static void tcf_chain_destroy(struct tcf_chain *chain)
......@@ -510,7 +517,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
if (n->nlmsg_type == RTM_DELTFILTER && prio == 0) {
tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER);
err = 0;
goto errout;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment