public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Simon Horman <simon.horman@netronome.com>,
	mlxsw@mellanox.com, Colin King <colin.king@canonical.com>
Subject: Re: [patch net-next 2/2] net/sched: fix filter flushing
Date: Mon, 22 May 2017 14:36:20 +0200	[thread overview]
Message-ID: <20170522123620.GA1845@nanopsycho> (raw)
In-Reply-To: <ebf100e6-e927-35bd-3c3a-9bd481237979@mojatatu.com>

Mon, May 22, 2017 at 12:42:44PM CEST, jhs@mojatatu.com wrote:
>On 17-05-21 03:19 PM, Jiri Pirko wrote:
>> Sun, May 21, 2017 at 08:27:21PM CEST, xiyou.wangcong@gmail.com wrote:
>> > On Sat, May 20, 2017 at 10:54 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>> > > Sun, May 21, 2017 at 02:16:45AM CEST, xiyou.wangcong@gmail.com wrote:
>> > > > On Sat, May 20, 2017 at 6:01 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>> > > > > +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);
>> > > > 
>> > > > 
>> > > > I wonder if we should return EBUSY and do nothing in case of busy?
>> > > > The chain is no longer visual to new actions after your list_del(), but
>> > > > the old one could still use and see it.
>> > > 
>> > > No. User request to flush the chain, that is what happens in the past
>> > > and that is what should happen now.
>> > > If there is still a reference, the chain_put will keep the empty chain.
>> > 
>> > But if you dump the actions, this chain is still shown "goto chain"?
>> 
>> Yes, it will be shown there.
>> 
>> 
>> > You can't claim you really delete it as long as actions can still
>> > see it and dump it.
>> 
>> No, user just wants to delete all the filters. That is done. User does
>> not care if the actual chain structure is there or not.
>> 
>
>I am trying to visualize a scenario where this is a problem.
>Using gact action it may be  possible to cause issues (requires
>validating - when i get time I will test).
>Steps are something like:
>
>1. create filter on chain 11 (refcnt = 1)

refcnt will be 0, chain->filter_chain will be non-NULL.
Please see the code before you assume anything. Namely tcf_chain_get and
tcf_chain_put.


>2. create gact action index 5 goto chain 11 (refcnt =2)

refcnt will be 1 after this


>3'. create new filter on chain 0 ... action gact index 5
>3''. create new filter on chain 0 ... action gact index 5
>
>
>None of the #3 steps will increment the refcnt.

Right


>Delete the filter from #1 (refcnt becomes 1)

Right, refcnt was 1, after delete will still be 1


>Delete the filter from #3'1 (refcnt = 0, destroy happens)

No. refcnt will still be 1.


>Filter #3'' is still hanging there. Dump that and strange things
>happen.

No. I see nothing strange.


>
>cheers,
>jamal

  reply	other threads:[~2017-05-22 12:36 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 ` [patch net-next 2/2] net/sched: fix filter flushing Jiri Pirko
2017-05-21  0:16   ` 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 [this message]
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=20170522123620.GA1845@nanopsycho \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox