Skip to content

Commit 835c290

Browse files
tacslontohojo
authored andcommitted
libxdp: Modify semantic of fill and comp in xsk_socket_opts
Use umem's fill_save and fill_comp if fill and comp in opts are both unset when calling xsk_socket__create_opts(), otherwise use what they are set in opts. This is to keep the same semantic as xsk_socket__create() and xsk_socket__create_shared(). Signed-off-by: Muyang Tian <[email protected]>
1 parent abff006 commit 835c290

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

headers/xdp/xsk.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,9 @@ struct xsk_socket_config {
259259
*
260260
* @fill, @comp, @rx_size, @tx_size, @libxdp_flags, @xdp_flags,
261261
* @bind_flags
262-
* If a socket with exclusive ownership of a umem is going to be
263-
* created, keep @fill and @comp unset. If the umem is to be shared
264-
* with other sockets, set @fill and @comp to the corresponding
265-
* fields of the umem.
262+
* If @fill and @comp are both unset, fill_save and comp_save of
263+
* the umem will be assigned to them, otherwise keep what they
264+
* are set in opts.
266265
* If the remaining fields are unset, they will be set to
267266
* default value (see `xsk_set_xdp_socket_config()`).
268267
*

lib/libxdp/xsk.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,13 +1072,17 @@ struct xsk_socket *xsk_socket__create_opts(const char *ifname,
10721072
}
10731073
rx = OPTS_GET(opts, rx, NULL);
10741074
tx = OPTS_GET(opts, tx, NULL);
1075-
fill = OPTS_GET(opts, fill, umem->fill_save);
1076-
comp = OPTS_GET(opts, comp, umem->comp_save);
1075+
fill = OPTS_GET(opts, fill, NULL);
1076+
comp = OPTS_GET(opts, comp, NULL);
10771077

10781078
if (!umem || !(rx || tx)) {
10791079
err = -EFAULT;
10801080
goto err;
10811081
}
1082+
if (!fill && !comp) {
1083+
fill = umem->fill_save;
1084+
comp = umem->comp_save;
1085+
}
10821086

10831087
xsk = calloc(1, sizeof(*xsk));
10841088
if (!xsk) {

0 commit comments

Comments
 (0)