From e96a1347fe7cf90c07ccce53d3b633db97ac99a6 Mon Sep 17 00:00:00 2001 From: Muyang Tian Date: Sat, 14 Dec 2024 17:28:36 +0800 Subject: [PATCH] libxdp: Use opts-style API to create XDP socket in libxdp tests Signed-off-by: Muyang Tian --- lib/libxdp/tests/test_xsk_non_privileged.c | 20 +++++++++++--------- lib/libxdp/tests/test_xsk_refcnt.c | 11 ++++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/libxdp/tests/test_xsk_non_privileged.c b/lib/libxdp/tests/test_xsk_non_privileged.c index 04301135..42f8486c 100644 --- a/lib/libxdp/tests/test_xsk_non_privileged.c +++ b/lib/libxdp/tests/test_xsk_non_privileged.c @@ -127,20 +127,22 @@ static struct xsk_socket *create_xsk_non_privileged(const char *ifname, struct xsk_umem *umem, int queue_id) { - struct xsk_socket_config cfg = { + struct xsk_socket *xsk = NULL; + struct xsk_ring_cons rx; + struct xsk_ring_prod tx; + + DECLARE_LIBXDP_OPTS(xsk_socket_opts, opts, + .rx = &rx, + .tx = &tx, .rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS, .tx_size = XSK_RING_PROD__DEFAULT_NUM_DESCS, .libxdp_flags = XSK_LIBXDP_FLAGS__INHIBIT_PROG_LOAD, .bind_flags = XDP_USE_NEED_WAKEUP, .xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST, - }; - struct xsk_socket *xsk = NULL; - struct xsk_ring_cons rx; - struct xsk_ring_prod tx; - - if (xsk_socket__create(&xsk, ifname, queue_id, - umem, &rx, &tx, &cfg) || !xsk) { - perror("xsk_socket__create failed"); + ); + xsk = xsk_socket__create_opts(ifname, queue_id, umem, &opts); + if (!xsk) { + perror("xsk_socket__create_opts failed"); exit(EXIT_FAILURE); } diff --git a/lib/libxdp/tests/test_xsk_refcnt.c b/lib/libxdp/tests/test_xsk_refcnt.c index bdd22da1..5cf05db7 100644 --- a/lib/libxdp/tests/test_xsk_refcnt.c +++ b/lib/libxdp/tests/test_xsk_refcnt.c @@ -125,7 +125,6 @@ static struct xsk_umem_info *xsk_configure_umem(void *buffer, u64 size) static struct xsk_socket_info *xsk_configure_socket(struct xsk_umem_info *umem, unsigned int qid) { - struct xsk_socket_config cfg = {}; struct xsk_socket_info *xsk; struct xsk_ring_cons *rxr; @@ -134,11 +133,13 @@ static struct xsk_socket_info *xsk_configure_socket(struct xsk_umem_info *umem, exit(EXIT_FAILURE); xsk->umem = umem; - cfg.rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS; - rxr = &xsk->rx; - xsk_socket__create(&xsk->xsk, opt_if, qid, umem->umem, - rxr, NULL, &cfg); + + DECLARE_LIBXDP_OPTS(xsk_socket_opts, opts, + .rx = rxr, + .rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS, + ); + xsk->xsk = xsk_socket__create_opts(opt_if, qid, umem->umem, &opts); return xsk; }