Skip to content

Commit

Permalink
net/sched: fix filter flushing
Browse files Browse the repository at this point in the history
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: 5bc1701 ("net: sched: introduce multichain support for filters")
Signed-off-by: Jiri Pirko <[email protected]>
Acked-by: Cong Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jpirko authored and davem330 committed May 23, 2017
1 parent 31efcc2 commit f93e1cd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

list_del(&chain->list);
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);
tcf_proto_destroy(tp);
}
}

static void tcf_chain_destroy(struct tcf_chain *chain)
{
list_del(&chain->list);
tcf_chain_flush(chain);
kfree(chain);
}

Expand Down Expand Up @@ -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);
tcf_chain_destroy(chain);
tcf_chain_flush(chain);
err = 0;
goto errout;
}
Expand Down

0 comments on commit f93e1cd

Please sign in to comment.