Re: [PATCH 1/4] rust: netlink: add raw netlink abstraction

From: Andrew Lunn

Date: Sun Mar 08 2026 - 13:25:06 EST


> There are several static inline methods that I need to call. Here is the
> list:
>
> - genlmsg_new
> - genlmsg_multicast
> - genlmsg_cancel
> - genlmsg_end
> - nlmsg_free
> - genl_has_listeners
>
> And on Android devices running this code, they will in fact have been
> inlined into Rust code, permitting fast code without function call
> overhead. Inlining happens via my other (recent) patchset [1], which the
> Android kernel is already using in production.
>
> [1]: https://lore.kernel.org/all/20260203-inline-helpers-v2-0-beb8547a03c9@xxxxxxxxxx/

Ah, cool. That is going to be very useful in networking.

> If that is the case, then it sounds like the correct API design would be
> to have a separate NetlinkSkBuff type so that you cannot mix them up
> with an sk_buff used for packet data.
>
> > So, maybe you can have a base definition of skbuff in rust/kernel/net,
> > and build on top of that to make a netlink specific skbuff, with a
> > limited list of methods which can access it, those needed for netlink?
> > Make use of the Rust type system? And leave the messy fast path packet
> > data things for somebody else.
>
> That makes sense to me. If there is duplication between the two sk_buff
> types, then one can be defined in terms of the other (or maybe it's
> easier to not do that).

Probably struct sk_buff is one of those complex things where we make
our best guess design now, and be prepared to redesign and refactor
the code as we learn more. To me, it feels like we need a base SkBuff
with full access to all API methods. And then a restricted type for
NetlinkSkBuff on top of that for users of netlink.

Andrew