Re: [PATCH 4/4] tools: ynl: add start-index property for indexed arrays

Zahari Doychev
2025-10-21T17:51:13Z

On Mon, Oct 20, 2025 at 04:32:21PM -0700, Jakub Kicinski wrote:
> On Sat, 18 Oct 2025 17:17:37 +0200 Zahari Doychev wrote:
> > The Linux tc actions expect that the action order starts from index
> > one. To accommodate this, add a start-index property to the ynl spec
> > for indexed arrays. This property allows the starting index to be
> > specified, ensuring compatibility with consumers that require a
> > non-zero-based index.
> >
> > For example if we have "start_index = 1" then we get the following
> > diff.
> >
> > ynl_attr_put_str(nlh, TCA_FLOWER_INDEV, obj->indev);
> > array = ynl_attr_nest_start(nlh, TCA_FLOWER_ACT);
> > for (i = 0; i < obj->_count.act; i++)
> > - tc_act_attrs_put(nlh, i, &obj->act[i]);
> > + tc_act_attrs_put(nlh, i + 1, &obj->act[i]);
> > ynl_attr_nest_end(nlh, array);
>
> The first one is just silently skipped by the kernel right?

yes, and then only the second action is being confiugred. The
index defines the action order and the expectation is that they
start from order 1.

>
> We need to be selective about what API stupidity we try to
> cover up in YNL. Otherwise the specs will be unmanageably complex.
> IMO this one should be a comment in the spec explaining that action
> 0 is ignore and that's it.
>

I am not sure if this applies for all cases of indexed arrays. For sure
it applies for the tc_act_attrs case but I need to check the rest again.

Do you think it would be fine to start from 1 for all indexed arrays?