From: Simon Horman <simon.horman@corigine.com>
To: Victor Nogueira <victor@mojatatu.com>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com,
xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
pctammela@mojatatu.com, kernel@mojatatu.com
Subject: Re: [PATCH net 1/5] net: sched: cls_bpf: Undo tcf_bind_filter in case of an error
Date: Tue, 4 Jul 2023 21:48:45 +0100 [thread overview]
Message-ID: <ZKSFrSW2zJZYelNj@corigine.com> (raw)
In-Reply-To: <20230704151456.52334-2-victor@mojatatu.com>
On Tue, Jul 04, 2023 at 12:14:52PM -0300, Victor Nogueira wrote:
> If cls_bpf_offload errors out, we must also undo tcf_bind_filter that
> was done in cls_bpf_set_parms.
>
> Fix that by calling tcf_unbind_filter in errout_parms.
>
> Fixes: eadb41489fd2 ("net: cls_bpf: add support for marking filters as hardware-only")
>
nit: no blank line here.
> Signed-off-by: Victor Nogueira <victor@mojatatu.com>
> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
> Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
> ---
> net/sched/cls_bpf.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
> index 466c26df853a..4d9974b1b29d 100644
> --- a/net/sched/cls_bpf.c
> +++ b/net/sched/cls_bpf.c
> @@ -409,7 +409,7 @@ static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog,
> static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp,
> struct cls_bpf_prog *prog, unsigned long base,
> struct nlattr **tb, struct nlattr *est, u32 flags,
> - struct netlink_ext_ack *extack)
> + bool *bound_to_filter, struct netlink_ext_ack *extack)
> {
> bool is_bpf, is_ebpf, have_exts = false;
> u32 gen_flags = 0;
> @@ -451,6 +451,7 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp,
> if (tb[TCA_BPF_CLASSID]) {
> prog->res.classid = nla_get_u32(tb[TCA_BPF_CLASSID]);
> tcf_bind_filter(tp, &prog->res, base);
> + *bound_to_filter = true;
> }
>
> return 0;
> @@ -464,6 +465,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
> {
> struct cls_bpf_head *head = rtnl_dereference(tp->root);
> struct cls_bpf_prog *oldprog = *arg;
> + bool bound_to_filter = false;
> struct nlattr *tb[TCA_BPF_MAX + 1];
> struct cls_bpf_prog *prog;
> int ret;
Please use reverse xmas tree - longest line to shortest - for
local variable declarations in Networking code.
> @@ -505,7 +507,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
> prog->handle = handle;
>
> ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], flags,
> - extack);
> + &bound_to_filter, extack);
> if (ret < 0)
> goto errout_idr;
>
> @@ -530,6 +532,8 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
> return 0;
>
> errout_parms:
> + if (bound_to_filter)
> + tcf_unbind_filter(tp, &prog->res);
> cls_bpf_free_parms(prog);
> errout_idr:
> if (!oldprog)
--
pw-bot: changes-requested
next prev parent reply other threads:[~2023-07-04 20:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-04 15:14 [PATCH net 0/5] net: sched: Undo tcf_bind_filter in case of errors in set callbacks Victor Nogueira
2023-07-04 15:14 ` [PATCH net 1/5] net: sched: cls_bpf: Undo tcf_bind_filter in case of an error Victor Nogueira
2023-07-04 20:48 ` Simon Horman [this message]
2023-07-04 20:55 ` Jamal Hadi Salim
2023-07-04 21:19 ` Simon Horman
2023-07-04 21:42 ` Jamal Hadi Salim
2023-07-05 7:45 ` Simon Horman
2023-07-04 15:14 ` [PATCH net 2/5] net: sched: cls_matchall: Undo tcf_bind_filter in case of failure after mall_set_parms Victor Nogueira
2023-07-04 15:14 ` [PATCH net 3/5] net: sched: cls_u32: Undo tcf_bind_filter if u32_replace_hw_knode Victor Nogueira
2023-07-04 15:14 ` [PATCH net 4/5] net: sched: cls_u32: Undo refcount decrement in case update failed Victor Nogueira
2023-07-04 15:14 ` [PATCH net 5/5] net: sched: cls_flower: Undo tcf_bind_filter if fl_set_key fails Victor Nogueira
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=ZKSFrSW2zJZYelNj@corigine.com \
--to=simon.horman@corigine.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kernel@mojatatu.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pctammela@mojatatu.com \
--cc=victor@mojatatu.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).