Skip to content

Commit

Permalink
net-veth: Add type safety to veth_xdp_to_ptr() and veth_ptr_to_xdp()
Browse files Browse the repository at this point in the history
This reduces likelihood of incorrect use.

Test: builds

Signed-off-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200819020027.4072288-1-zenczykowski@gmail.com
  • Loading branch information
Maciej Żenczykowski authored and Alexei Starovoitov committed Aug 19, 2020
1 parent 596b5ef commit defcffe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/veth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit defcffe

Please sign in to comment.