Skip to contentSkip to conversation

selftests/bpf: Fix sk lookup usage in test_sock_addr

PATCH Applied Andrey Ignatov 4 participants 4 messages Dec 13, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: Fix sk lookup usage in test_sock_addr

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")
---
 tools/testing/selftests/bpf/connect4_prog.c | 6 ++++--
 tools/testing/selftests/bpf/connect6_prog.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/connect4_prog.c +4 -2
index b8395f3c43e9..1fd244d35ba9 100644
@@ -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;
tools/testing/selftests/bpf/connect6_prog.c +4 -2
index 25f5dc7b7aa0..26397ab7b3c7 100644
@@ -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;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Andrey Ignatov

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")
Tested-by on v1 1/1
#2 lore raw
In reply to Andrey Ignatov
Quoted 9 lines · Andrey Ignatov

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")

Thanks for the fix!

Quoted 42 lines
---
  tools/testing/selftests/bpf/connect4_prog.c | 6 ++++--
  tools/testing/selftests/bpf/connect6_prog.c | 6 ++++--
  2 files changed, 8 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/connect4_prog.c +4 -2
index b8395f3c43e9..1fd244d35ba9 100644
@@ -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;
tools/testing/selftests/bpf/connect6_prog.c +4 -2
index 25f5dc7b7aa0..26397ab7b3c7 100644
@@ -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;
maintainer Applied
#3 lore raw
Quoted 7 lines · Yonghong Song
Quoted 6 lines · Andrey Ignatov

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.

Quoted 5 lines
Quoted 3 lines
Fixes f71c6143c203 ("bpf: Support sk lookup in netns with id 0")

Thanks for the fix!

Applied, thanks!