[SRU][F:linux-bluefield][PATCH v1 3/5] net/sched: flower: Move filter handle initialization earlier

Bartlomiej Zolnierkiewicz bartlomiej.zolnierkiewicz at canonical.com
Tue Mar 28 16:49:46 UTC 2023


On Thu, Mar 23, 2023 at 8:18 PM William Tu <witu at nvidia.com> wrote:
>
> From: Paul Blakey <paulb at nvidia.com>
>
> BugLink: https://bugs.launchpad.net/bugs/2012571
>
> To support miss to action during hardware offload the filter's
> handle is needed when setting up the actions (tcf_exts_init()),
> and before offloading.
>
> Move filter handle initialization earlier.
>
> Signed-off-by: Paul Blakey <paulb at nvidia.com>
> (Cherry picked from upstream commit 08a0063df3aed8d76a4034279117db12dbc1050f)
> Reviewed-by: Jiri Pirko <jiri at nvidia.com>
> Reviewed-by: Simon Horman <simon.horman at corigine.com>
> Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
> Signed-off-by: Jakub Kicinski <kuba at kernel.org>

Your "S-o-b:" is needed here, also the "cherry-picked" line needs to be moved.

(BTW while using "git cherry-pick" you may specify "-x -s" parameters
to make the command automatically add "cherry-picked" and "S-o-b:"
lines.)

If the cherry pick was actually done by Paul and not you it should be more like:

Signed-off-by: Paul Blakey <paulb at nvidia.com>
Reviewed-by: Jiri Pirko <jiri at nvidia.com>
Reviewed-by: Simon Horman <simon.horman at corigine.com>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
Signed-off-by: Jakub Kicinski <kuba at kernel.org>
(cherry-picked from 08a0063df3aed8d76a4034279117db12dbc1050f)
Signed-off-by: Paul Blakey <paulb at nvidia.com>
Signed-off-by: William Tu <witu at nvidia.com>

to correctly document the patch history.

Best Regards,
Bartlomiej

> ---
>  net/sched/cls_flower.c | 62 ++++++++++++++++++++++++------------------
>  1 file changed, 35 insertions(+), 27 deletions(-)
>
> diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
> index 0b428f5ca73b..0f5ce744bd51 100644
> --- a/net/sched/cls_flower.c
> +++ b/net/sched/cls_flower.c
> @@ -1639,10 +1639,6 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
>         INIT_LIST_HEAD(&fnew->hw_list);
>         refcount_set(&fnew->refcnt, 1);
>
> -       err = tcf_exts_init(&fnew->exts, net, TCA_FLOWER_ACT, 0);
> -       if (err < 0)
> -               goto errout;
> -
>         if (tb[TCA_FLOWER_FLAGS]) {
>                 fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]);
>
> @@ -1652,14 +1648,44 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
>                 }
>         }
>
> +       if (!fold) {
> +               spin_lock(&tp->lock);
> +               if (!handle) {
> +                       handle = 1;
> +                       err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
> +                                           INT_MAX, GFP_ATOMIC);
> +               } else {
> +                       err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
> +                                           handle, GFP_ATOMIC);
> +
> +                       /* Filter with specified handle was concurrently
> +                        * inserted after initial check in cls_api. This is not
> +                        * necessarily an error if NLM_F_EXCL is not set in
> +                        * message flags. Returning EAGAIN will cause cls_api to
> +                        * try to update concurrently inserted rule.
> +                        */
> +                       if (err == -ENOSPC)
> +                               err = -EAGAIN;
> +               }
> +               spin_unlock(&tp->lock);
> +
> +               if (err)
> +                       goto errout;
> +       }
> +       fnew->handle = handle;
> +
> +       err = tcf_exts_init(&fnew->exts, net, TCA_FLOWER_ACT, 0);
> +       if (err < 0)
> +               goto errout_idr;
> +
>         err = fl_set_parms(net, tp, fnew, mask, base, tb, tca[TCA_RATE], ovr,
>                            tp->chain->tmplt_priv, rtnl_held, extack);
>         if (err)
> -               goto errout;
> +               goto errout_idr;
>
>         err = fl_check_assign_mask(head, fnew, fold, mask);
>         if (err)
> -               goto errout;
> +               goto errout_idr;
>
>         err = fl_ht_insert_unique(fnew, fold, &in_ht);
>         if (err)
> @@ -1725,29 +1751,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
>                 refcount_dec(&fold->refcnt);
>                 __fl_put(fold);
>         } else {
> -               if (handle) {
> -                       /* user specifies a handle and it doesn't exist */
> -                       err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
> -                                           handle, GFP_ATOMIC);
> -
> -                       /* Filter with specified handle was concurrently
> -                        * inserted after initial check in cls_api. This is not
> -                        * necessarily an error if NLM_F_EXCL is not set in
> -                        * message flags. Returning EAGAIN will cause cls_api to
> -                        * try to update concurrently inserted rule.
> -                        */
> -                       if (err == -ENOSPC)
> -                               err = -EAGAIN;
> -               } else {
> -                       handle = 1;
> -                       err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
> -                                           INT_MAX, GFP_ATOMIC);
> -               }
> -               if (err)
> -                       goto errout_hw;
> +               idr_replace(&head->handle_idr, fnew, fnew->handle);
>
>                 refcount_inc(&fnew->refcnt);
> -               fnew->handle = handle;
>                 list_add_tail_rcu(&fnew->list, &fnew->mask->filters);
>                 spin_unlock(&tp->lock);
>         }
> @@ -1770,6 +1776,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
>                                        fnew->mask->filter_ht_params);
>  errout_mask:
>         fl_mask_put(head, fnew->mask);
> +errout_idr:
> +       idr_remove(&head->handle_idr, fnew->handle);
>  errout:
>         __fl_put(fnew);
>  errout_tb:



More information about the kernel-team mailing list