netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Vlad Buslov <vladbu@nvidia.com>
Cc: "Jamal Hadi Salim" <jhs@mojatatu.com>,
	"Linux Kernel Network Developers" <netdev@vger.kernel.org>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"David Miller" <davem@davemloft.net>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Marcelo Ricardo Leitner" <marcelo.leitner@gmail.com>,
	"Davide Caratti" <dcaratti@redhat.com>
Subject: Re: [PATCH net v2 2/3] net: sched: fix action overwrite reference counting
Date: Thu, 8 Apr 2021 14:52:32 -0700	[thread overview]
Message-ID: <CAM_iQpUD_Fv8tLQXyoKYeC3pxXFmqMOZR1v4V6E7EKgUQpEm1g@mail.gmail.com> (raw)
In-Reply-To: <ygnhsg419pw7.fsf@nvidia.com>

On Thu, Apr 8, 2021 at 12:50 AM Vlad Buslov <vladbu@nvidia.com> wrote:
>
>
> On Thu 08 Apr 2021 at 02:50, Cong Wang <xiyou.wangcong@gmail.com> wrote:
> > In my last comments, I actually meant whether we can avoid this
> > 'init_res[]' array. Since here you want to check whether an action
> > returned by tcf_action_init_1() is a new one or an existing one, how
> > about checking its refcnt? Something like:
> >
> >   act = tcf_action_init_1(...);
> >   if (IS_ERR(act)) {
> >     err = PTR_ERR(act);
> >     goto err;
> >   }
> >   if (refcount_read(&act->tcfa_refcnt) == 1) {
> >     // we know this is a newly allocated one
> >   }
> >
> > Thanks.
>
> Hmm, I don't think this would work in general case. Consider following
> cases:
>
> 1. Action existed during init as filter action(refcnt=1), init overwrote
> it setting refcnt=2, by the time we got to checking tcfa_refcnt filter
> has been deleted (refcnt=1) so code will incorrectly assume that it has
> created the action.
>
> 2. We need this check in tcf_action_add() to release the refcnt in case
> of overwriting existing actions, but by that time actions are already
> accessible though idr, so even in case when new action has been created
> (refcnt=1) it could already been referenced by concurrently created
> filter (refcnt=2).

Hmm, I nearly forgot RTNL is lifted for some cases along TC filter
and action control paths... It seems we have no better way to work
around this.

Thanks.

  parent reply	other threads:[~2021-04-08 21:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 15:36 [PATCH net v2 0/3] Action initalization fixes Vlad Buslov
2021-04-07 15:36 ` [PATCH net v2 1/3] Revert "net: sched: bump refcount for new action in ACT replace mode" Vlad Buslov
2021-04-07 15:36 ` [PATCH net v2 2/3] net: sched: fix action overwrite reference counting Vlad Buslov
2021-04-07 23:50   ` Cong Wang
2021-04-08  7:50     ` Vlad Buslov
2021-04-08 13:43       ` Jamal Hadi Salim
2021-04-08 21:52       ` Cong Wang [this message]
2021-04-08 11:59     ` Jamal Hadi Salim
2021-04-08 21:55       ` Cong Wang
2021-04-07 15:36 ` [PATCH net v2 3/3] net: sched: fix err handler in tcf_action_init() Vlad Buslov
2021-04-08 22:02 ` [PATCH net v2 0/3] Action initalization fixes Cong Wang

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=CAM_iQpUD_Fv8tLQXyoKYeC3pxXFmqMOZR1v4V6E7EKgUQpEm1g@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dcaratti@redhat.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    --cc=vladbu@nvidia.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;
as well as URLs for NNTP newsgroup(s).