[PATCH bpf-next] net-veth: add type safety to veth_xdp_to_ptr() and veth_ptr_to_xdp()

Subsystems: networking drivers, the rest

STALE2228d LANDED

Landed in mainline as defcffeb517b on 2020-08-19.

2 messages, 2 authors, 2020-08-19 · open the first message on its own page

[PATCH bpf-next] net-veth: add type safety to veth_xdp_to_ptr() and veth_ptr_to_xdp()

From: Maciej Żenczykowski <hidden>
Date: 2020-08-19 02:00:42

From: Maciej Żenczykowski <redacted>

This reduces likelihood of incorrect use.

Test: builds
Signed-off-by: Maciej Żenczykowski <redacted>
---
 drivers/net/veth.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index e56cd562a664..b80cbffeb88e 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -234,14 +234,14 @@ static bool veth_is_xdp_frame(void *ptr)
 	return (unsigned long)ptr & VETH_XDP_FLAG;
 }
 
-static void *veth_ptr_to_xdp(void *ptr)
+static struct xdp_frame *veth_ptr_to_xdp(void *ptr)
 {
 	return (void *)((unsigned long)ptr & ~VETH_XDP_FLAG);
 }
 
-static void *veth_xdp_to_ptr(void *ptr)
+static void *veth_xdp_to_ptr(struct xdp_frame *xdp)
 {
-	return (void *)((unsigned long)ptr | VETH_XDP_FLAG);
+	return (void *)((unsigned long)xdp | VETH_XDP_FLAG);
 }
 
 static void veth_ptr_free(void *ptr)
-- 
2.28.0.220.ged08abb693-goog

Re: [PATCH bpf-next] net-veth: add type safety to veth_xdp_to_ptr() and veth_ptr_to_xdp()

From: Alexei Starovoitov <hidden>
Date: 2020-08-19 21:16:51

On Tue, Aug 18, 2020 at 7:00 PM Maciej Żenczykowski
[off-list ref] wrote:
From: Maciej Żenczykowski <redacted>

This reduces likelihood of incorrect use.

Test: builds
I kept this in the commit log though it's a pointless comment.
Please reconsider for the future.
If you want to mention how you've tested it, please say so after "---" line.
Signed-off-by: Maciej Żenczykowski <redacted>
Applied. Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help