From: Davide Caratti <dcaratti@redhat.com>
To: Vlad Buslov <vladbu@mellanox.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>,
Paolo Abeni <pabeni@redhat.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH RFC 2/5] net/sched: prepare TC actions to properly validate the control action
Date: Tue, 19 Feb 2019 17:50:46 +0100 [thread overview]
Message-ID: <cb2b7e6bda5a21cbc3a4585f25d76b48cd273a90.camel@redhat.com> (raw)
In-Reply-To: <vbfbm39qbsw.fsf@mellanox.com>
hi Vlad,
On Mon, 2019-02-18 at 16:52 +0000, Vlad Buslov wrote:
> Hi Davide,
>
> I really like the idea of putting all action validation code in single
> place, instead of spreading it between act API and specific actions init
> code.
sure, the previous validation code was in tcf_action_add_1(), and I
attempted to fix the problems (well, it's the same problem showing up in
3 different ways) without adding the same code everywhere.
Sadly, we need to handle correctly the situations where
tcf_action_check_ctrlact() returns an error, and I'm seeing that we
can't fix every action with the same exact code everywhere (to avoid
leaking IDRs, or memory, or both).
> See my comment regarding minor problem with using
> tcf_action_set_ctrlact() on current net-next below.
> > +void tcf_action_set_ctrlact(struct tc_action *p, int action,
> > + struct tcf_chain *goto_chain)
> > +{
> > + struct tcf_chain *old;
> > +
> > + old = xchg(&p->goto_chain, goto_chain);
> > + if (old)
> > + tcf_chain_put_by_act(old);
>
> This is blocking in current net-next because tcf_chain_put_by_act()
> obtains block->lock mutex, so you can't call it while holding tcf_lock
> spinlock like you do in following patches. Its not a big problem but
> I guess you will have to just inline this code into all init handlers
> instead of tcf_action_set_ctrlact() function.
Argh! you are right. Thanks a lot for spotting this.
Ok, let's kill tcf_action_set_ctrlact() and swap 'newchain' with
a->goto_chain in each action init(), with a->tcfa_lock taken. I will
then call tcf_chain_put_by_act() in the init() handler, after the
spinlock is released.
> BTW is atomic xchg strictly necessary if you hold tcf_lock while
> re-assigning goto_chain pointer?
No, it's not necessary. The new value of goto_chain is used only when the
new value of tcfa_action is updated: so, if we just do the assignment of
goto_chain and tcfa_action together with the spinlock taken, at least we
are improving the
current code.
Thanks!
--
davide
next prev parent reply other threads:[~2019-02-19 16:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-15 23:06 [PATCH RFC 0/5] net/sched: validate the control action with all the other parameters Davide Caratti
2019-02-15 23:06 ` [PATCH RFC 1/5] net/sched: fix refcount leak when 'goto_chain' is used Davide Caratti
2019-02-15 23:06 ` [PATCH RFC 2/5] net/sched: prepare TC actions to properly validate the control action Davide Caratti
2019-02-18 16:52 ` Vlad Buslov
2019-02-19 16:50 ` Davide Caratti [this message]
2019-02-15 23:06 ` [PATCH RFC 3/5] net/sched: act_bpf: validate the control action inside init() Davide Caratti
2019-02-15 23:06 ` [PATCH RFC 4/5] net/sched: act_csum: " Davide Caratti
2019-02-15 23:06 ` [PATCH RFC 5/5] net/sched: act_gact: " Davide Caratti
2019-02-19 6:42 ` [PATCH RFC 0/5] net/sched: validate the control action with all the other parameters Cong Wang
2019-02-19 16:51 ` Davide Caratti
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=cb2b7e6bda5a21cbc3a4585f25d76b48cd273a90.camel@redhat.com \
--to=dcaratti@redhat.com \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladbu@mellanox.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).