Re: [PATCH net-next] net: sched: gred: dynamically allocate tc_gred_qopt_offload

From: Jakub Kicinski
Date: Tue Oct 19 2021 - 11:57:37 EST


On Tue, 19 Oct 2021 17:37:27 +0200 Arnd Bergmann wrote:
> @@ -470,8 +477,7 @@ static int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps,
> }
> }
>
> - gred_offload(sch, TC_GRED_REPLACE);
> - return 0;
> + return gred_offload(sch, TC_GRED_REPLACE);
> }
>
> static inline int gred_change_vq(struct Qdisc *sch, int dp,
> @@ -719,8 +725,7 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt,
> sch_tree_unlock(sch);
> kfree(prealloc);
>
> - gred_offload(sch, TC_GRED_REPLACE);
> - return 0;
> + return gred_offload(sch, TC_GRED_REPLACE);

Now we can return an error even tho the SW path has changed.
Qdisc offloads should not affect the SW changes AFAIR.

If we need to alloc dynamically let's allocate the buffer at init and
keep it in struct gred_sched. The offload calls are all under RTNL lock
so in fact we could even use static data, but let's do it right and
have a buffer per qdisc.