Skip to content

Commit

Permalink
libxdp: Use 0 as default(or unset) value for fd when creating umem
Browse files Browse the repository at this point in the history
Signed-off-by: Muyang Tian <[email protected]>
  • Loading branch information
tacslon committed Nov 7, 2024
1 parent fb8a8f5 commit d7c82d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/libxdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ struct xsk_umem *xsk_umem__create_opts(void *umem_area,
err = -EINVAL;
goto err;
}
fd = OPTS_GET(opts, fd, -1);
fd = OPTS_GET(opts, fd, 0);
size = OPTS_GET(opts, size, 0);

if (!size && !xsk_page_aligned(umem_area)) {
Expand All @@ -330,7 +330,7 @@ struct xsk_umem *xsk_umem__create_opts(void *umem_area,
goto err;
}

umem->fd = fd < 0 ? socket(AF_XDP, SOCK_RAW, 0) : fd;
umem->fd = fd > 0 ? fd : socket(AF_XDP, SOCK_RAW, 0);
if (umem->fd < 0) {
err = -errno;
goto out_umem_alloc;
Expand Down Expand Up @@ -412,7 +412,7 @@ int xsk_umem__create(struct xsk_umem **umem_ptr, void *umem_area,
struct xsk_ring_cons *comp,
const struct xsk_umem_config *usr_config)
{
return xsk_umem__create_with_fd(umem_ptr, -1, umem_area, size,
return xsk_umem__create_with_fd(umem_ptr, 0, umem_area, size,
fill, comp, usr_config);
}

Expand Down

0 comments on commit d7c82d9

Please sign in to comment.