Netdev List
 help / color / mirror / Atom feed
* [ynl] how to fix the order of selector and `_decode_sub_msg`
@ 2026-08-25 12:48 Hangbin Liu
  2026-08-27 17:14 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Hangbin Liu @ 2026-08-25 12:48 UTC (permalink / raw)
  To: Donald Hunter, Jakub Kicinski; +Cc: netdev

Hi Donald, Jakub,

Recently I have been trying to add encap decoding support for `rt‑route.yaml`,
with formats similar to:

      -
        name: encap-type
        type: u16
        enum: encap-type
      -
        name: encap
        type: sub-message
        sub-message: encap-data
        selector: encap-type

However, sub‑message decoding is broken inside `ynl.py`. The root cause is
that `lwtunnel_fill_encap()` sets the encap‑type *after* the encap payload
data.

In iproute2, `parse_rtattr()` extracts all attributes together. In contrast,
`ynl.py` stores attributes one‑by‑one into `search_attrs` after they get
decoded (_decode() -> self._rsp_add()). As a result, we cannot locate the
`selector` while decoding the "encap" payload.

Should we decode sub‑messages after finishing first‑level attribute decoding?
Do you have any suggestions on how we can fix this?

Thanks
Hangbin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ynl] how to fix the order of selector and `_decode_sub_msg`
  2026-08-25 12:48 [ynl] how to fix the order of selector and `_decode_sub_msg` Hangbin Liu
@ 2026-08-27 17:14 ` Jakub Kicinski
  2026-08-28  1:41   ` Hangbin Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2026-08-27 17:14 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: Donald Hunter, netdev

On Tue, 25 Aug 2026 20:48:55 +0800 Hangbin Liu wrote:
> Hi Donald, Jakub,
> 
> Recently I have been trying to add encap decoding support for `rt‑route.yaml`,
> with formats similar to:
> 
>       -
>         name: encap-type
>         type: u16
>         enum: encap-type
>       -
>         name: encap
>         type: sub-message
>         sub-message: encap-data
>         selector: encap-type
> 
> However, sub‑message decoding is broken inside `ynl.py`. The root cause is
> that `lwtunnel_fill_encap()` sets the encap‑type *after* the encap payload
> data.
> 
> In iproute2, `parse_rtattr()` extracts all attributes together. In contrast,
> `ynl.py` stores attributes one‑by‑one into `search_attrs` after they get
> decoded (_decode() -> self._rsp_add()). As a result, we cannot locate the
> `selector` while decoding the "encap" payload.
> 
> Should we decode sub‑messages after finishing first‑level attribute decoding?
> Do you have any suggestions on how we can fix this?

I'd change the kernel to output the type before the data.
The code seems to be trying to cancel out cleanly on EOPNOTSUPP.
Which is a good code pattern in principle but I don't think it makes
sense for dump / get. And no existing ->fill_encap can return EOPNOTSUPP
so instead of complicating things we should just move the type before
the data in the kernel.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ynl] how to fix the order of selector and `_decode_sub_msg`
  2026-08-27 17:14 ` Jakub Kicinski
@ 2026-08-28  1:41   ` Hangbin Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Hangbin Liu @ 2026-08-28  1:41 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: Donald Hunter, netdev

On Thu, Aug 27, 2026 at 10:14:16AM -0700, Jakub Kicinski wrote:
> On Tue, 25 Aug 2026 20:48:55 +0800 Hangbin Liu wrote:
> > Hi Donald, Jakub,
> > 
> > Recently I have been trying to add encap decoding support for `rt‑route.yaml`,
> > with formats similar to:
> > 
> >       -
> >         name: encap-type
> >         type: u16
> >         enum: encap-type
> >       -
> >         name: encap
> >         type: sub-message
> >         sub-message: encap-data
> >         selector: encap-type
> > 
> > However, sub‑message decoding is broken inside `ynl.py`. The root cause is
> > that `lwtunnel_fill_encap()` sets the encap‑type *after* the encap payload
> > data.
> > 
> > In iproute2, `parse_rtattr()` extracts all attributes together. In contrast,
> > `ynl.py` stores attributes one‑by‑one into `search_attrs` after they get
> > decoded (_decode() -> self._rsp_add()). As a result, we cannot locate the
> > `selector` while decoding the "encap" payload.
> > 
> > Should we decode sub‑messages after finishing first‑level attribute decoding?
> > Do you have any suggestions on how we can fix this?
> 
> I'd change the kernel to output the type before the data.
> The code seems to be trying to cancel out cleanly on EOPNOTSUPP.
> Which is a good code pattern in principle but I don't think it makes
> sense for dump / get. And no existing ->fill_encap can return EOPNOTSUPP
> so instead of complicating things we should just move the type before
> the data in the kernel.

Thanks, that would be an easy fix.

Hangbin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-28  1:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25 12:48 [ynl] how to fix the order of selector and `_decode_sub_msg` Hangbin Liu
2026-08-27 17:14 ` Jakub Kicinski
2026-08-28  1:41   ` Hangbin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox