Skip to content

Commit

Permalink
libxdp: Add validation for only one of fill and comp are set
Browse files Browse the repository at this point in the history
Signed-off-by: Muyang Tian <[email protected]>
  • Loading branch information
tacslon authored and tohojo committed Jan 8, 2025
1 parent b2a5a2d commit e7e2272
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions headers/xdp/xsk.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ struct xsk_socket_config {
*
* @fill, @comp, @rx_size, @tx_size, @libxdp_flags, @xdp_flags,
* @bind_flags
* 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 @fill and @comp are both unset, they will be set to umem's
* fill_save and comp_save respectively. Note that it is invalid
* to set only one of them.
* If the remaining fields are unset, they will be set to
* default value (see `xsk_set_xdp_socket_config()`).
*
Expand Down
2 changes: 1 addition & 1 deletion lib/libxdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ struct xsk_socket *xsk_socket__create_opts(const char *ifname,
fill = OPTS_GET(opts, fill, NULL);
comp = OPTS_GET(opts, comp, NULL);

if (!umem || !(rx || tx)) {
if (!umem || !(rx || tx) || (fill == NULL) ^ (comp == NULL)) {
err = -EFAULT;
goto err;
}
Expand Down

0 comments on commit e7e2272

Please sign in to comment.