Re: [PATCH net-next v3 1/2] netdev-genl: Add an XSK attribute to queues

From: Joe Damato
Date: Thu Feb 06 2025 - 20:46:38 EST


On Thu, Feb 06, 2025 at 05:41:38PM -0800, Jakub Kicinski wrote:
> On Thu, 6 Feb 2025 17:31:47 -0800 Joe Damato wrote:
> > > nla_nest_start() can fail, you gotta nul-check the return value.
> > > You could possibly add an nla_put_empty_nest() helper in netlink.h
> > > to make this less awkward? I think the iouring guys had the same bug
> >
> > Ah, right.
> >
> > I'll see what a helper looks like. Feels like maybe overkill?
>
> Yeah, not sure either. Technically nla_nest_end() isn't required here,
> but that's not very obvious to a casual reader. So a helper that hides
> that fact could be useful:
>
> static inline int nla_put_empty_nest(struct sk_buff *skb, int attrtype)
> {
> return nla_nest_start(skb, attrtype) ? 0 : -EMSGSIZE;
> }

Yea after reading the code it makes sense that nla_nest_end is not
needed. I wrote a small thing similar to what you proposed above,
but yours is more succinct.

I'll go with that and see how it looks.

> But totally unsure whether it's worthwhile. Just don't want for someone
> to suggest this on v4 and make you respin once again.

No worries; respinning is not the end of the world.