selftests/bpf: Fix sk lookup usage in test_sock_addr
authorAndrey Ignatov <rdna@fb.com>
Thu, 13 Dec 2018 21:19:01 +0000 (13:19 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 13 Dec 2018 22:42:16 +0000 (23:42 +0100)
Semantic of netns_id argument of bpf_sk_lookup_tcp and bpf_sk_lookup_udp
was changed (fixed) in f71c6143c203. Corresponding changes have to be
applied to all call sites in selftests. The patch fixes corresponding
call sites in test_sock_addr test: pass BPF_F_CURRENT_NETNS instead of 0
in netns_id argument.

Fixes: f71c6143c203 ("bpf: Support sk lookup in netns with id 0")
Reported-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Acked-by: Joe Stringer <joe@wand.net.nz>
Tested-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/connect4_prog.c
tools/testing/selftests/bpf/connect6_prog.c

index b8395f3c43e960f424a0adb16a06eb6149f0af61..1fd244d35ba93558fc0d5a3d8f07e08c2a45c4b2 100644 (file)
@@ -35,9 +35,11 @@ int connect_v4_prog(struct bpf_sock_addr *ctx)
        if (ctx->type != SOCK_STREAM && ctx->type != SOCK_DGRAM)
                return 0;
        else if (ctx->type == SOCK_STREAM)
-               sk = bpf_sk_lookup_tcp(ctx, &tuple, sizeof(tuple.ipv4), 0, 0);
+               sk = bpf_sk_lookup_tcp(ctx, &tuple, sizeof(tuple.ipv4),
+                                      BPF_F_CURRENT_NETNS, 0);
        else
-               sk = bpf_sk_lookup_udp(ctx, &tuple, sizeof(tuple.ipv4), 0, 0);
+               sk = bpf_sk_lookup_udp(ctx, &tuple, sizeof(tuple.ipv4),
+                                      BPF_F_CURRENT_NETNS, 0);
 
        if (!sk)
                return 0;
index 25f5dc7b7aa05c6f8da0df80eee7e245a7dc4a4f..26397ab7b3c784f807947b165b0fe7a7dc7a9bd5 100644 (file)
@@ -47,9 +47,11 @@ int connect_v6_prog(struct bpf_sock_addr *ctx)
        if (ctx->type != SOCK_STREAM && ctx->type != SOCK_DGRAM)
                return 0;
        else if (ctx->type == SOCK_STREAM)
-               sk = bpf_sk_lookup_tcp(ctx, &tuple, sizeof(tuple.ipv6), 0, 0);
+               sk = bpf_sk_lookup_tcp(ctx, &tuple, sizeof(tuple.ipv6),
+                                      BPF_F_CURRENT_NETNS, 0);
        else
-               sk = bpf_sk_lookup_udp(ctx, &tuple, sizeof(tuple.ipv6), 0, 0);
+               sk = bpf_sk_lookup_udp(ctx, &tuple, sizeof(tuple.ipv6),
+                                      BPF_F_CURRENT_NETNS, 0);
 
        if (!sk)
                return 0;