* [PATCH v3] rust: net: netlink: Migrate to zerocopy's IntoBytes
@ 2026-09-15 14:42 Sagar Taunk
2026-09-17 9:32 ` Alice Ryhl
2026-09-18 0:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Sagar Taunk @ 2026-09-15 14:42 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, netdev, rust-for-linux,
linux-kernel
Cc: Sagar Taunk
Replace the kernel's own `transmute::FromBytes` and `AsBytes` traits
with their zerocopy equivalents. Specifically, this updates
`GenlMsg::put` to rely on `IntoBytes` for converting attributes into
byte slices.
Also, add `Immutable` trait bound on `GenlMsg::put` as zerocopy
splits the `no interior mutability` guarantee that `AsBytes` bundled
together.
Link: https://github.com/Rust-for-Linux/linux/issues/1241
Signed-off-by: Sagar Taunk <sagartaunk@proton.me>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
---
Changes Since V2: Follow vertical import style as told by Alexandre Courbot.
No functional changes.
rust/kernel/net/netlink.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/net/netlink.rs b/rust/kernel/net/netlink.rs
index 22ef3dde36fa..a2f4bd171dcf 100644
--- a/rust/kernel/net/netlink.rs
+++ b/rust/kernel/net/netlink.rs
@@ -12,7 +12,6 @@
alloc::{self, AllocError},
error::to_result,
prelude::*,
- transmute::AsBytes,
types::Opaque,
ThisModule,
};
@@ -22,6 +21,11 @@
ptr::NonNull, //
};
+use zerocopy::{
+ Immutable,
+ IntoBytes, //
+};
+
/// The default netlink message size.
pub const GENLMSG_DEFAULT_SIZE: usize = bindings::GENLMSG_DEFAULT_SIZE;
@@ -84,7 +88,7 @@ impl GenlMsg {
#[inline]
fn put<T>(&mut self, attrtype: c_int, value: &T) -> Result
where
- T: ?Sized + AsBytes,
+ T: ?Sized + IntoBytes + Immutable,
{
let skb = self.skb.skb.as_ptr();
let len = size_of_val(value);
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] rust: net: netlink: Migrate to zerocopy's IntoBytes
2026-09-15 14:42 [PATCH v3] rust: net: netlink: Migrate to zerocopy's IntoBytes Sagar Taunk
@ 2026-09-17 9:32 ` Alice Ryhl
2026-09-18 0:06 ` Jakub Kicinski
2026-09-18 0:10 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Alice Ryhl @ 2026-09-17 9:32 UTC (permalink / raw)
To: Sagar Taunk
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, netdev, rust-for-linux,
linux-kernel
On Tue, Sep 15, 2026 at 02:42:44PM +0000, Sagar Taunk wrote:
> Replace the kernel's own `transmute::FromBytes` and `AsBytes` traits
> with their zerocopy equivalents. Specifically, this updates
> `GenlMsg::put` to rely on `IntoBytes` for converting attributes into
> byte slices.
>
> Also, add `Immutable` trait bound on `GenlMsg::put` as zerocopy
> splits the `no interior mutability` guarantee that `AsBytes` bundled
> together.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1241
> Signed-off-by: Sagar Taunk <sagartaunk@proton.me>
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Thanks, this change is ok with me.
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Can you send this to the net folks? Please update your patch title to
[PATCH net-next vX] according to the guidelines outlined in:
Documentation/process/maintainer-netdev.rst
Alice
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] rust: net: netlink: Migrate to zerocopy's IntoBytes
2026-09-17 9:32 ` Alice Ryhl
@ 2026-09-18 0:06 ` Jakub Kicinski
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2026-09-18 0:06 UTC (permalink / raw)
To: Alice Ryhl, Sagar Taunk
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
Onur Özkan, netdev, rust-for-linux, linux-kernel
On Thu, 17 Sep 2026 09:32:58 +0000 Alice Ryhl wrote:
> Can you send this to the net folks? Please update your patch title to
> [PATCH net-next vX] according to the guidelines outlined in:
Good note, please remember that next time, no need to repost this one.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] rust: net: netlink: Migrate to zerocopy's IntoBytes
2026-09-15 14:42 [PATCH v3] rust: net: netlink: Migrate to zerocopy's IntoBytes Sagar Taunk
2026-09-17 9:32 ` Alice Ryhl
@ 2026-09-18 0:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-18 0:10 UTC (permalink / raw)
To: Sagar Taunk
Cc: davem, edumazet, kuba, pabeni, horms, ojeda, boqun, gary,
bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross, dakr,
daniel.almeida, tamird, acourbot, work, netdev, rust-for-linux,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 15 Sep 2026 14:42:44 +0000 you wrote:
> Replace the kernel's own `transmute::FromBytes` and `AsBytes` traits
> with their zerocopy equivalents. Specifically, this updates
> `GenlMsg::put` to rely on `IntoBytes` for converting attributes into
> byte slices.
>
> Also, add `Immutable` trait bound on `GenlMsg::put` as zerocopy
> splits the `no interior mutability` guarantee that `AsBytes` bundled
> together.
>
> [...]
Here is the summary with links:
- [v3] rust: net: netlink: Migrate to zerocopy's IntoBytes
https://git.kernel.org/netdev/net-next/c/5e5916923759
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-18 0:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 14:42 [PATCH v3] rust: net: netlink: Migrate to zerocopy's IntoBytes Sagar Taunk
2026-09-17 9:32 ` Alice Ryhl
2026-09-18 0:06 ` Jakub Kicinski
2026-09-18 0:10 ` patchwork-bot+netdevbpf
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®