Commit defcffeb authored by Maciej Żenczykowski's avatar Maciej Żenczykowski Committed by Alexei Starovoitov

net-veth: Add type safety to veth_xdp_to_ptr() and veth_ptr_to_xdp()

This reduces likelihood of incorrect use.

Test: builds
Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200819020027.4072288-1-zenczykowski@gmail.com
parent 596b5ef4
...@@ -234,14 +234,14 @@ static bool veth_is_xdp_frame(void *ptr) ...@@ -234,14 +234,14 @@ static bool veth_is_xdp_frame(void *ptr)
return (unsigned long)ptr & VETH_XDP_FLAG; 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); 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) static void veth_ptr_free(void *ptr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment