Commit d95ba15b authored by Geliang Tang's avatar Geliang Tang Committed by Daniel Borkmann

selftests/bpf: Fix tx_prog_fd values in test_sockmap

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: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Tested-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/08b20ffc544324d40939efeae93800772a91a58e.1716446893.git.tanggeliang@kylinos.cn
parent ec1249d3
......@@ -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++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment