Skip to content

Commit

Permalink
libxdp: Modify semantic of fill and comp in xsk_socket_opts
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tacslon authored and tohojo committed Jan 8, 2025
1 parent abff006 commit 835c290
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 3 additions & 4 deletions headers/xdp/xsk.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,9 @@ struct xsk_socket_config {
*
* @fill, @comp, @rx_size, @tx_size, @libxdp_flags, @xdp_flags,
* @bind_flags
* If a socket with exclusive ownership of a umem is going to be
* created, keep @fill and @comp unset. If the umem is to be shared
* with other sockets, set @fill and @comp to the corresponding
* fields of the umem.
* If @fill and @comp are both unset, fill_save and comp_save of
* the umem will be assigned to them, otherwise keep what they
* are set in opts.
* If the remaining fields are unset, they will be set to
* default value (see `xsk_set_xdp_socket_config()`).
*
Expand Down
8 changes: 6 additions & 2 deletions lib/libxdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,13 +1072,17 @@ struct xsk_socket *xsk_socket__create_opts(const char *ifname,
}
rx = OPTS_GET(opts, rx, NULL);
tx = OPTS_GET(opts, tx, NULL);
fill = OPTS_GET(opts, fill, umem->fill_save);
comp = OPTS_GET(opts, comp, umem->comp_save);
fill = OPTS_GET(opts, fill, NULL);
comp = OPTS_GET(opts, comp, NULL);

if (!umem || !(rx || tx)) {
err = -EFAULT;
goto err;
}
if (!fill && !comp) {
fill = umem->fill_save;
comp = umem->comp_save;
}

xsk = calloc(1, sizeof(*xsk));
if (!xsk) {
Expand Down

0 comments on commit 835c290

Please sign in to comment.