Message ID | 08b20ffc544324d40939efeae93800772a91a58e.1716446893.git.tanggeliang@kylinos.cn (mailing list archive) |
---|---|
State | Accepted |
Commit | d95ba15b97847f4ae520db83bd98b61d50fb3068 |
Headers | show |
Series | fixes for test_sockmap | expand |
Geliang Tang wrote: > From: Geliang Tang <tanggeliang@kylinos.cn> > > The values of tx_prog_fd in run_options() should not be 0, so set it as -1 > in else branch, and test it using "if (tx_prog_fd > 0)" condition, not > "if (tx_prog_fd)" or "if (tx_prog_fd >= 0)". > > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> > --- Acked-by: John Fastabend <john.fastabend@gmail.com>
diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index 4499b3cfc3a6..fde0dd741e69 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -1027,9 +1027,9 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) else if (txmsg_drop) tx_prog_fd = prog_fd[8]; else - tx_prog_fd = 0; + tx_prog_fd = -1; - if (tx_prog_fd) { + if (tx_prog_fd > 0) { int redir_fd, i = 0; err = bpf_prog_attach(tx_prog_fd, @@ -1285,7 +1285,7 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) bpf_prog_detach2(prog_fd[0], map_fd[8], BPF_SK_SKB_STREAM_PARSER); bpf_prog_detach2(prog_fd[2], map_fd[8], BPF_SK_SKB_STREAM_VERDICT); - if (tx_prog_fd >= 0) + if (tx_prog_fd > 0) bpf_prog_detach2(tx_prog_fd, map_fd[1], BPF_SK_MSG_VERDICT); for (i = 0; i < 8; i++) {