netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jamal Hadi Salim <jhs@mojatatu.com>
To: Cong Wang <xiyou.wangcong@gmail.com>, Vlad Buslov <vladbu@nvidia.com>
Cc: "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 07:59:27 -0400	[thread overview]
Message-ID: <6dd90b61-ad41-6e3a-bab7-1f6da2ed1905@mojatatu.com> (raw)
In-Reply-To: <CAM_iQpXEGs-Sq-SjNrewEyQJ7p2-KUxL5-eUvWs0XTKGoh7BsQ@mail.gmail.com>

On 2021-04-07 7:50 p.m., Cong Wang wrote:
> On Wed, Apr 7, 2021 at 8:36 AM Vlad Buslov <vladbu@nvidia.com> wrote:
>>
>> Action init code increments reference counter when it changes an action.
>> This is the desired behavior for cls API which needs to obtain action
>> reference for every classifier that points to action. However, act API just
>> needs to change the action and releases the reference before returning.
>> This sequence breaks when the requested action doesn't exist, which causes
>> act API init code to create new action with specified index, but action is
>> still released before returning and is deleted (unless it was referenced
>> concurrently by cls API).
>>
>> Reproduction:
>>
>> $ sudo tc actions ls action gact
>> $ sudo tc actions change action gact drop index 1
>> $ sudo tc actions ls action gact
>>
> 
> I didn't know 'change' could actually create an action when
> it does not exist. So it sets NLM_F_REPLACE, how could it
> replace a non-existing one? Is this the right behavior or is it too
> late to change even if it is not?

Thats expected behavior for "change" essentially mapping
to classical "SET" i.e.
"create if it doesnt exist, replace if it exists"
i.e NLM_F_CREATE | NLM_F_REPLACE

In retrospect, "replace" should probably have been just NLM_F_REPLACE
"replace if it exists, error otherwise".
Currently there is no distinction between the two.

"Add" is classical "CREATE" i.e "create if doesnt exist, otherwise
error"

It may be feasible to fix "replace" but not sure how many scripts over
the years are now dependent on that behavior.

cheers,
jamal

  parent reply	other threads:[~2021-04-08 11:59 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
2021-04-08 11:59     ` Jamal Hadi Salim [this message]
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=6dd90b61-ad41-6e3a-bab7-1f6da2ed1905@mojatatu.com \
    --to=jhs@mojatatu.com \
    --cc=davem@davemloft.net \
    --cc=dcaratti@redhat.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 \
    --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;
as well as URLs for NNTP newsgroup(s).