netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jamal Hadi Salim <jhs@mojatatu.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
	 davem@davemloft.net, edumazet@google.com,
	xiyou.wangcong@gmail.com,  victor@mojatatu.com,
	pctammela@mojatatu.com, idosch@idosch.org,  mleitner@redhat.com,
	vladbu@nvidia.com, paulb@nvidia.com
Subject: Re: [patch net] net: sched: track device in tcf_block_get/put_ext() only for clsact binder types
Date: Fri, 12 Jan 2024 09:48:19 -0500	[thread overview]
Message-ID: <CAM0EoM=sg9ivqey0sG7E3dC_Sh=_vMgNJpJrUzxp9OcPAdVr6Q@mail.gmail.com> (raw)
In-Reply-To: <20240112113930.1647666-1-jiri@resnulli.us>

On Fri, Jan 12, 2024 at 6:39 AM Jiri Pirko <jiri@resnulli.us> wrote:
>
> From: Jiri Pirko <jiri@nvidia.com>
>
> Clsact/ingress qdisc is not the only one using shared block,
> red is also using it. The device tracking was originally introduced
> by commit 913b47d3424e ("net/sched: Introduce tc block netdev
> tracking infra") for clsact/ingress only. Commit 94e2557d086a ("net:
> sched: move block device tracking into tcf_block_get/put_ext()")
> mistakenly enabled that for red as well.
>
> Fix that by adding a check for the binder type being clsact when adding
> device to the block->ports xarray.
>
> Reported-by: Ido Schimmel <idosch@idosch.org>
> Closes: https://lore.kernel.org/all/ZZ6JE0odnu1lLPtu@shredder/
> Fixes: 94e2557d086a ("net: sched: move block device tracking into tcf_block_get/put_ext()")
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>

Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>

cheers,
jamal

> ---
>  net/sched/cls_api.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> index e3236a3169c3..92a12e3d0fe6 100644
> --- a/net/sched/cls_api.c
> +++ b/net/sched/cls_api.c
> @@ -1424,6 +1424,14 @@ static void tcf_block_owner_del(struct tcf_block *block,
>         WARN_ON(1);
>  }
>
> +static bool tcf_block_tracks_dev(struct tcf_block *block,
> +                                struct tcf_block_ext_info *ei)
> +{
> +       return tcf_block_shared(block) &&
> +              (ei->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ||
> +               ei->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS);
> +}
> +
>  int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
>                       struct tcf_block_ext_info *ei,
>                       struct netlink_ext_ack *extack)
> @@ -1462,7 +1470,7 @@ int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
>         if (err)
>                 goto err_block_offload_bind;
>
> -       if (tcf_block_shared(block)) {
> +       if (tcf_block_tracks_dev(block, ei)) {
>                 err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL);
>                 if (err) {
>                         NL_SET_ERR_MSG(extack, "block dev insert failed");
> @@ -1516,7 +1524,7 @@ void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
>
>         if (!block)
>                 return;
> -       if (tcf_block_shared(block))
> +       if (tcf_block_tracks_dev(block, ei))
>                 xa_erase(&block->ports, dev->ifindex);
>         tcf_chain0_head_change_cb_del(block, ei);
>         tcf_block_owner_del(block, q, ei->binder_type);
> --
> 2.43.0
>

  parent reply	other threads:[~2024-01-12 14:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12 11:39 [patch net] net: sched: track device in tcf_block_get/put_ext() only for clsact binder types Jiri Pirko
2024-01-12 14:36 ` Ido Schimmel
2024-01-12 14:48 ` Jamal Hadi Salim [this message]
2024-01-12 14:55 ` Victor Nogueira
2024-01-13 15:50 ` patchwork-bot+netdevbpf

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='CAM0EoM=sg9ivqey0sG7E3dC_Sh=_vMgNJpJrUzxp9OcPAdVr6Q@mail.gmail.com' \
    --to=jhs@mojatatu.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=idosch@idosch.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=mleitner@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paulb@nvidia.com \
    --cc=pctammela@mojatatu.com \
    --cc=victor@mojatatu.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).