Skip to content

Commit b2a5a2d

Browse files
tacslontohojo
authored andcommitted
libxdp: Use opts-style API to create XDP socket in libxdp tests
Signed-off-by: Muyang Tian <[email protected]>
1 parent 835c290 commit b2a5a2d

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

lib/libxdp/tests/test_xsk_non_privileged.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,22 @@ static struct xsk_socket *create_xsk_non_privileged(const char *ifname,
127127
struct xsk_umem *umem,
128128
int queue_id)
129129
{
130-
struct xsk_socket_config cfg = {
130+
struct xsk_socket *xsk = NULL;
131+
struct xsk_ring_cons rx;
132+
struct xsk_ring_prod tx;
133+
134+
DECLARE_LIBXDP_OPTS(xsk_socket_opts, opts,
135+
.rx = &rx,
136+
.tx = &tx,
131137
.rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS,
132138
.tx_size = XSK_RING_PROD__DEFAULT_NUM_DESCS,
133139
.libxdp_flags = XSK_LIBXDP_FLAGS__INHIBIT_PROG_LOAD,
134140
.bind_flags = XDP_USE_NEED_WAKEUP,
135141
.xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST,
136-
};
137-
struct xsk_socket *xsk = NULL;
138-
struct xsk_ring_cons rx;
139-
struct xsk_ring_prod tx;
140-
141-
if (xsk_socket__create(&xsk, ifname, queue_id,
142-
umem, &rx, &tx, &cfg) || !xsk) {
143-
perror("xsk_socket__create failed");
142+
);
143+
xsk = xsk_socket__create_opts(ifname, queue_id, umem, &opts);
144+
if (!xsk) {
145+
perror("xsk_socket__create_opts failed");
144146
exit(EXIT_FAILURE);
145147
}
146148

lib/libxdp/tests/test_xsk_refcnt.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ static struct xsk_umem_info *xsk_configure_umem(void *buffer, u64 size)
125125
static struct xsk_socket_info *xsk_configure_socket(struct xsk_umem_info *umem,
126126
unsigned int qid)
127127
{
128-
struct xsk_socket_config cfg = {};
129128
struct xsk_socket_info *xsk;
130129
struct xsk_ring_cons *rxr;
131130

@@ -134,11 +133,12 @@ static struct xsk_socket_info *xsk_configure_socket(struct xsk_umem_info *umem,
134133
exit(EXIT_FAILURE);
135134

136135
xsk->umem = umem;
137-
cfg.rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS;
138-
139136
rxr = &xsk->rx;
140-
xsk_socket__create(&xsk->xsk, opt_if, qid, umem->umem,
141-
rxr, NULL, &cfg);
137+
DECLARE_LIBXDP_OPTS(xsk_socket_opts, opts,
138+
.rx = rxr,
139+
.rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS,
140+
);
141+
xsk->xsk = xsk_socket__create_opts(opt_if, qid, umem->umem, &opts);
142142

143143
return xsk;
144144
}

0 commit comments

Comments
 (0)