Skip to content

Commit e7e2272

Browse files
tacslontohojo
authored andcommitted
libxdp: Add validation for only one of fill and comp are set
Signed-off-by: Muyang Tian <[email protected]>
1 parent b2a5a2d commit e7e2272

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: headers/xdp/xsk.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ struct xsk_socket_config {
259259
*
260260
* @fill, @comp, @rx_size, @tx_size, @libxdp_flags, @xdp_flags,
261261
* @bind_flags
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.
262+
* If @fill and @comp are both unset, they will be set to umem's
263+
* fill_save and comp_save respectively. Note that it is invalid
264+
* to set only one of them.
265265
* If the remaining fields are unset, they will be set to
266266
* default value (see `xsk_set_xdp_socket_config()`).
267267
*

Diff for: lib/libxdp/xsk.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ struct xsk_socket *xsk_socket__create_opts(const char *ifname,
10751075
fill = OPTS_GET(opts, fill, NULL);
10761076
comp = OPTS_GET(opts, comp, NULL);
10771077

1078-
if (!umem || !(rx || tx)) {
1078+
if (!umem || !(rx || tx) || (fill == NULL) ^ (comp == NULL)) {
10791079
err = -EFAULT;
10801080
goto err;
10811081
}

0 commit comments

Comments
 (0)