mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Donald Hunter" <donald.hunter@gmail.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Carlos Llamas" <cmllamas@google.com>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH 1/4] rust: netlink: add raw netlink abstraction
Date: Sun, 8 Mar 2026 15:48:40 +0100	[thread overview]
Message-ID: <f93ee07b-5dfd-4748-a7f2-814539e60d81@lunn.ch> (raw)
In-Reply-To: <aayYhgy3pRxFWbr7@google.com>

> We can make a kernel::net module (rust/kernel/net/) and put it there
> instead? I guess netlink.rs can also be a submodule of that.
> 
> Hmm ... but I'm currently using genlmsg_new() / nlmsg_free(), and I
> assume the other use-cases do not go through those methods, since they
> sound netlink specific.
> 
> To be honest, I'm new to the kernel's networking stack, so I probably
> can't design Rust wrapper for sk_buff that supports all those different
> usecases without someone walking me through how it works. It may or may
> not be best to write a netlink-specific struct now and expand it later.

At its core, an skbuff represents a block of memory. Normally that
memory would be packet data flowing through the network stack. You can
append to the front and back of the data in the buffer. You can add
the buffer to linked lists, there are reference counting operations,
so the buffer can have multiple users, there are places you can store
per protocol data, and places you can store data while within one
protocol layer, etc.

When using sk_buff for packet data, you are generally on a fast path,
so much of the code is in header files as inline functions. This is
going to make rust binding harder, my current understanding is that it
is hard to make use of such functions from rust.

However, for netlink, its is slow path code, it seems like all the
functions you need to call are in object files, not inline headers.

I also suspect, but don't know, that the netlink upper API is disjoint
to the packet handling upper API. How you allocate a skbuff for
netlink is different to packet data. It is very likely an error if you
try to transmit out an interface an skbuff allocated for netlink
usage, etc.

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.

     Andrew

  reply	other threads:[~2026-03-08 14:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06 15:12 [PATCH 0/4] Rust netlink support + use in Rust Binder Alice Ryhl
2026-03-06 15:12 ` [PATCH 1/4] rust: netlink: add raw netlink abstraction Alice Ryhl
2026-03-07 15:43   ` Andrew Lunn
2026-03-07 21:28     ` Alice Ryhl
2026-03-08 14:48       ` Andrew Lunn [this message]
2026-03-08 15:23         ` Alice Ryhl
2026-03-08 17:24           ` Andrew Lunn
2026-03-09  8:38             ` Alice Ryhl
2026-03-06 15:12 ` [PATCH 2/4] ynl_gen: generate Rust files from yaml files Alice Ryhl
2026-03-07 18:41   ` Jakub Kicinski
2026-03-07 21:30     ` Alice Ryhl
2026-03-06 15:12 ` [PATCH 3/4] rust_binder: add generated netlink.rs file Alice Ryhl
2026-03-16 12:07   ` Andreas Hindborg
2026-03-06 15:12 ` [PATCH 4/4] rust_binder: report netlink transactions Alice Ryhl
2026-03-07 16:56   ` Andrew Lunn
2026-03-07 21:19     ` Alice Ryhl
2026-03-07 18:41 ` [PATCH 0/4] Rust netlink support + use in Rust Binder Jakub Kicinski
2026-03-07 21:19   ` Alice Ryhl
2026-03-07 21:39     ` Andrew Lunn
2026-03-07 22:41       ` Alice Ryhl
2026-03-08 14:12         ` Andrew Lunn
2026-03-08 15:08           ` Alice Ryhl
2026-03-07 21:59     ` Jakub Kicinski
2026-03-07 22:50       ` Alice Ryhl
2026-03-09 21:24         ` Jakub Kicinski
2026-03-10  7:47           ` Alice Ryhl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f93ee07b-5dfd-4748-a7f2-814539e60d81@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=arve@android.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=brauner@kernel.org \
    --cc=cmllamas@google.com \
    --cc=dakr@kernel.org \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tkjos@android.com \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®