Skip to content

Commit

Permalink
selftests/bpf: Add F_SETFL for fcntl
Browse files Browse the repository at this point in the history
Incorrect arguments are passed to fcntl() in test_sockmap.c when invoking
it to set file status flags. If O_NONBLOCK is used as 2nd argument and
passed into fcntl, -EINVAL will be returned (See do_fcntl() in fs/fcntl.c).
The correct approach is to use F_SETFL as 2nd argument, O_NONBLOCK as
3rd.

Fixes: 16962b2 ("bpf: sockmap, add selftests")
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang committed Apr 3, 2024
1 parent 3eb2e63 commit f67bdd6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/test_sockmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
struct timeval timeout;
fd_set w;

fcntl(fd, fd_flags);
fcntl(fd, F_SETFL, fd_flags);
/* Account for pop bytes noting each iteration of apply will
* call msg_pop_data helper so we need to account for this
* by calculating the number of apply iterations. Note user
Expand Down

0 comments on commit f67bdd6

Please sign in to comment.