From d7c82d9ce8528e9338f245dbdf21442642ffb6cc Mon Sep 17 00:00:00 2001 From: Muyang Tian Date: Thu, 7 Nov 2024 19:26:46 +0800 Subject: [PATCH] libxdp: Use 0 as default(or unset) value for fd when creating umem Signed-off-by: Muyang Tian --- lib/libxdp/xsk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libxdp/xsk.c b/lib/libxdp/xsk.c index 958a2b05..5b4964a7 100644 --- a/lib/libxdp/xsk.c +++ b/lib/libxdp/xsk.c @@ -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)) { @@ -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; @@ -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); }