[PATCH 1/3] rust: net: netlink: Migrate to zerocopy's `IntoBytes`

Subsystems: networking [general], rust, the rest

COOLING12d

3 messages, 2 authors, 12d ago · open the first message on its own page

[PATCH 1/3] rust: net: netlink: Migrate to zerocopy's `IntoBytes`

From: Sagar Taunk <hidden>
Date: 2026-09-06 07:17:06

Replace remaning imports of kernel's own `transmute::FromBytes`/`AsBytes`
traits with their zerocopy equvalent. In this case, `IntoBytes` which is
already re-exported through kernel's prelude.

Link: https://github.com/Rust-for-Linux/linux/issues/1241
Signed-Off-By : Sagar Taunk [off-list ref]
Signed-off-by: Sagar Taunk <redacted>
---
 rust/kernel/net/netlink.rs | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/rust/kernel/net/netlink.rs b/rust/kernel/net/netlink.rs
index 22ef3dde36fa..c3b50dd50a4c 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,
 };
@@ -84,7 +83,7 @@ impl GenlMsg {
     #[inline]
     fn put<T>(&mut self, attrtype: c_int, value: &T) -> Result
     where
-        T: ?Sized + AsBytes,
+        T: ?Sized + IntoBytes,
     {
         let skb = self.skb.skb.as_ptr();
         let len = size_of_val(value);
-- 
2.55.0

Re: [PATCH 1/3] rust: net: netlink: Migrate to zerocopy's `IntoBytes`

From: Miguel Ojeda <hidden>
Date: 2026-09-06 09:49:39

On Sun, Sep 6, 2026 at 9:17 AM Sagar Taunk [off-list ref] wrote:
Signed-Off-By : Sagar Taunk [off-list ref]
Signed-off-by: Sagar Taunk <redacted>
It seems you wrote the first one by hand? There are two typos there.

Thanks!

Cheers,
Miguel

Re: [PATCH 1/3] rust: net: netlink: Migrate to zerocopy's `IntoBytes`

From: Sagar Taunk <hidden>
Date: 2026-09-06 10:12:38

Sorry, I missed that while checking. Let me send a V2. Also, are there any other changes I should make ?



On Sunday, September 6th, 2026 at 3:19 PM, Miguel Ojeda [off-list ref] wrote:
On Sun, Sep 6, 2026 at 9:17 AM Sagar Taunk [off-list ref] wrote:
quoted
Signed-Off-By : Sagar Taunk [off-list ref]
Signed-off-by: Sagar Taunk <redacted>
It seems you wrote the first one by hand? There are two typos there.

Thanks!

Cheers,
Miguel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help