All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com,
	edumazet@google.com, daniel@iogearbox.net,
	simon.horman@netronome.com, mlxsw@mellanox.com,
	colin.king@canonical.com
Subject: [patch net-next 2/2] net/sched: fix filter flushing
Date: Sat, 20 May 2017 15:01:32 +0200	[thread overview]
Message-ID: <20170520130132.1626-2-jiri@resnulli.us> (raw)
In-Reply-To: <20170520130132.1626-1-jiri@resnulli.us>

From: Jiri Pirko <jiri@mellanox.com>

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: 5bc1701881e3 ("net: sched: introduce multichain support for filters")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/sched/cls_api.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 85088ed..01a8b8b 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -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);
 }
 
@@ -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;
 	}
-- 
2.9.3

  reply	other threads:[~2017-05-20 13:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 13:01 [patch net-next 1/2] net/sched: properly assign RCU pointer in tcf_chain_tp_insert/remove Jiri Pirko
2017-05-20 13:01 ` Jiri Pirko [this message]
2017-05-21  0:16   ` [patch net-next 2/2] net/sched: fix filter flushing Cong Wang
2017-05-21  5:54     ` Jiri Pirko
2017-05-21 18:27       ` Cong Wang
2017-05-21 19:19         ` Jiri Pirko
2017-05-22 10:42           ` Jamal Hadi Salim
2017-05-22 12:36             ` Jiri Pirko
2017-05-22 20:54           ` Cong Wang
2017-05-22 21:04             ` Cong Wang
2017-05-23  5:17               ` Jiri Pirko
2017-05-23  5:39                 ` Cong Wang
2017-05-23  5:40   ` Cong Wang
2017-05-23 15:00   ` David Miller
2017-05-23 15:00 ` [patch net-next 1/2] net/sched: properly assign RCU pointer in tcf_chain_tp_insert/remove David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170520130132.1626-2-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=colin.king@canonical.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jhs@mojatatu.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=simon.horman@netronome.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.