diff mbox series

[bpf-next,v3] selftests/bpf: fix compilation failure when CONFIG_NET_FOU!=y

Message ID 20240723071031.3389423-1-asavkov@redhat.com (mailing list archive)
State Accepted
Commit c67b2a6f3b842b0daef5c2c0c3ea529c43559d10
Delegated to: BPF
Headers show
Series [bpf-next,v3] selftests/bpf: fix compilation failure when CONFIG_NET_FOU!=y | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 14 maintainers not CCed: kpsingh@kernel.org shuah@kernel.org haoluo@google.com dxu@dxuuu.xyz john.fastabend@gmail.com jolsa@kernel.org antony.antony@secunet.com linux-kselftest@vger.kernel.org yonghong.song@linux.dev martin.lau@linux.dev mykolal@fb.com song@kernel.org eddyz87@gmail.com sdf@fomichev.me
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch warning WARNING: please, no spaces at the start of a line
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test (test_maps, false, 360) / test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-18 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17-O2
bpf/vmtest-bpf-next-VM_Test-30 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-31 success Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18-O2
bpf/vmtest-bpf-next-VM_Test-38 success Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-37 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-39 success Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-40 success Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-42 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-41 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18

Commit Message

Artem Savkov July 23, 2024, 7:10 a.m. UTC
Without CONFIG_NET_FOU bpf selftests are unable to build because of
missing definitions. Add ___local versions of struct bpf_fou_encap and
enum bpf_fou_encap_type to fix the issue.

Signed-off-by: Artem Savkov <asavkov@redhat.com>

---
v3: swith from using BPF_NO_KFUNC_PROTOTYPES to casting to keep kfunc
prototype intact.

v2: added BPF_NO_KFUNC_PROTOTYPES define to avoid issues when
CONFIG_NET_FOU is set.
---
 .../selftests/bpf/progs/test_tunnel_kern.c    | 26 ++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)

Comments

bot+bpf-ci@kernel.org July 23, 2024, 7:32 a.m. UTC | #1
Dear patch submitter,

CI has tested the following submission:
Status:     SUCCESS
Name:       [bpf-next,v3] selftests/bpf: fix compilation failure when CONFIG_NET_FOU!=y
Patchwork:  https://patchwork.kernel.org/project/netdevbpf/list/?series=873153&state=*
Matrix:     https://github.com/kernel-patches/bpf/actions/runs/10054486016

No further action is necessary on your part.


Please note: this email is coming from an unmonitored mailbox. If you have
questions or feedback, please reach out to the Meta Kernel CI team at
kernel-ci@meta.com.
Simon Horman July 23, 2024, 9:44 a.m. UTC | #2
On Tue, Jul 23, 2024 at 09:10:31AM +0200, Artem Savkov wrote:
> Without CONFIG_NET_FOU bpf selftests are unable to build because of
> missing definitions. Add ___local versions of struct bpf_fou_encap and
> enum bpf_fou_encap_type to fix the issue.
> 
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
> 
> ---
> v3: swith from using BPF_NO_KFUNC_PROTOTYPES to casting to keep kfunc
> prototype intact.
> 
> v2: added BPF_NO_KFUNC_PROTOTYPES define to avoid issues when
> CONFIG_NET_FOU is set.
> ---
>  .../selftests/bpf/progs/test_tunnel_kern.c    | 26 ++++++++++++++-----
>  1 file changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> index 3f5abcf3ff136..fcff3010d8a60 100644
> --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> @@ -26,6 +26,18 @@
>   */
>  #define ASSIGNED_ADDR_VETH1 0xac1001c8
>  
> +struct bpf_fou_encap___local {
> +       __be16 sport;
> +       __be16 dport;
> +};
> +
> +enum bpf_fou_encap_type___local {
> +       FOU_BPF_ENCAP_FOU___local,
> +       FOU_BPF_ENCAP_GUE___local,
> +};

nit: The above use spaces rather than tabs for indentation.
Andrii Nakryiko July 23, 2024, 8:21 p.m. UTC | #3
On Tue, Jul 23, 2024 at 12:10 AM Artem Savkov <asavkov@redhat.com> wrote:
>
> Without CONFIG_NET_FOU bpf selftests are unable to build because of
> missing definitions. Add ___local versions of struct bpf_fou_encap and
> enum bpf_fou_encap_type to fix the issue.
>
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
>
> ---
> v3: swith from using BPF_NO_KFUNC_PROTOTYPES to casting to keep kfunc
> prototype intact.
>
> v2: added BPF_NO_KFUNC_PROTOTYPES define to avoid issues when
> CONFIG_NET_FOU is set.
> ---
>  .../selftests/bpf/progs/test_tunnel_kern.c    | 26 ++++++++++++++-----
>  1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> index 3f5abcf3ff136..fcff3010d8a60 100644
> --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> @@ -26,6 +26,18 @@
>   */
>  #define ASSIGNED_ADDR_VETH1 0xac1001c8
>
> +struct bpf_fou_encap___local {
> +       __be16 sport;
> +       __be16 dport;
> +};
> +
> +enum bpf_fou_encap_type___local {
> +       FOU_BPF_ENCAP_FOU___local,
> +       FOU_BPF_ENCAP_GUE___local,
> +};

both of the above are internal kernel types (not UAPI ones), so I
added preserve_access_index to the struct and ...

> +
> +struct bpf_fou_encap;
> +
>  int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx,
>                           struct bpf_fou_encap *encap, int type) __ksym;
>  int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx,
> @@ -745,7 +757,7 @@ SEC("tc")
>  int ipip_gue_set_tunnel(struct __sk_buff *skb)
>  {
>         struct bpf_tunnel_key key = {};
> -       struct bpf_fou_encap encap = {};
> +       struct bpf_fou_encap___local encap = {};
>         void *data = (void *)(long)skb->data;
>         struct iphdr *iph = data;
>         void *data_end = (void *)(long)skb->data_end;
> @@ -769,7 +781,8 @@ int ipip_gue_set_tunnel(struct __sk_buff *skb)
>         encap.sport = 0;
>         encap.dport = bpf_htons(5555);
>
> -       ret = bpf_skb_set_fou_encap(skb, &encap, FOU_BPF_ENCAP_GUE);
> +       ret = bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap,
> +                                   FOU_BPF_ENCAP_GUE___local);
>         if (ret < 0) {
>                 log_err(ret);
>                 return TC_ACT_SHOT;
> @@ -782,7 +795,7 @@ SEC("tc")
>  int ipip_fou_set_tunnel(struct __sk_buff *skb)
>  {
>         struct bpf_tunnel_key key = {};
> -       struct bpf_fou_encap encap = {};
> +       struct bpf_fou_encap___local encap = {};
>         void *data = (void *)(long)skb->data;
>         struct iphdr *iph = data;
>         void *data_end = (void *)(long)skb->data_end;
> @@ -806,7 +819,8 @@ int ipip_fou_set_tunnel(struct __sk_buff *skb)
>         encap.sport = 0;
>         encap.dport = bpf_htons(5555);
>
> -       ret = bpf_skb_set_fou_encap(skb, &encap, FOU_BPF_ENCAP_FOU);
> +       ret = bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap,
> +                                   FOU_BPF_ENCAP_FOU___local);


use bpf_core_enum_value() here for getting enum value in CO-RE-relocatable way

(also fixed spaces vs tabs issue that were pointed out)

pushed to bpf-next


>         if (ret < 0) {
>                 log_err(ret);
>                 return TC_ACT_SHOT;
> @@ -820,7 +834,7 @@ int ipip_encap_get_tunnel(struct __sk_buff *skb)
>  {
>         int ret;
>         struct bpf_tunnel_key key = {};
> -       struct bpf_fou_encap encap = {};
> +       struct bpf_fou_encap___local encap = {};
>
>         ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0);
>         if (ret < 0) {
> @@ -828,7 +842,7 @@ int ipip_encap_get_tunnel(struct __sk_buff *skb)
>                 return TC_ACT_SHOT;
>         }
>
> -       ret = bpf_skb_get_fou_encap(skb, &encap);
> +       ret = bpf_skb_get_fou_encap(skb, (struct bpf_fou_encap *)&encap);
>         if (ret < 0) {
>                 log_err(ret);
>                 return TC_ACT_SHOT;
> --
> 2.45.2
>
patchwork-bot+netdevbpf@kernel.org July 23, 2024, 8:30 p.m. UTC | #4
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Tue, 23 Jul 2024 09:10:31 +0200 you wrote:
> Without CONFIG_NET_FOU bpf selftests are unable to build because of
> missing definitions. Add ___local versions of struct bpf_fou_encap and
> enum bpf_fou_encap_type to fix the issue.
> 
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
> 
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3] selftests/bpf: fix compilation failure when CONFIG_NET_FOU!=y
    https://git.kernel.org/bpf/bpf-next/c/c67b2a6f3b84

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
index 3f5abcf3ff136..fcff3010d8a60 100644
--- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
@@ -26,6 +26,18 @@ 
  */
 #define ASSIGNED_ADDR_VETH1 0xac1001c8
 
+struct bpf_fou_encap___local {
+       __be16 sport;
+       __be16 dport;
+};
+
+enum bpf_fou_encap_type___local {
+       FOU_BPF_ENCAP_FOU___local,
+       FOU_BPF_ENCAP_GUE___local,
+};
+
+struct bpf_fou_encap;
+
 int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx,
 			  struct bpf_fou_encap *encap, int type) __ksym;
 int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx,
@@ -745,7 +757,7 @@  SEC("tc")
 int ipip_gue_set_tunnel(struct __sk_buff *skb)
 {
 	struct bpf_tunnel_key key = {};
-	struct bpf_fou_encap encap = {};
+	struct bpf_fou_encap___local encap = {};
 	void *data = (void *)(long)skb->data;
 	struct iphdr *iph = data;
 	void *data_end = (void *)(long)skb->data_end;
@@ -769,7 +781,8 @@  int ipip_gue_set_tunnel(struct __sk_buff *skb)
 	encap.sport = 0;
 	encap.dport = bpf_htons(5555);
 
-	ret = bpf_skb_set_fou_encap(skb, &encap, FOU_BPF_ENCAP_GUE);
+	ret = bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap,
+				    FOU_BPF_ENCAP_GUE___local);
 	if (ret < 0) {
 		log_err(ret);
 		return TC_ACT_SHOT;
@@ -782,7 +795,7 @@  SEC("tc")
 int ipip_fou_set_tunnel(struct __sk_buff *skb)
 {
 	struct bpf_tunnel_key key = {};
-	struct bpf_fou_encap encap = {};
+	struct bpf_fou_encap___local encap = {};
 	void *data = (void *)(long)skb->data;
 	struct iphdr *iph = data;
 	void *data_end = (void *)(long)skb->data_end;
@@ -806,7 +819,8 @@  int ipip_fou_set_tunnel(struct __sk_buff *skb)
 	encap.sport = 0;
 	encap.dport = bpf_htons(5555);
 
-	ret = bpf_skb_set_fou_encap(skb, &encap, FOU_BPF_ENCAP_FOU);
+	ret = bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap,
+				    FOU_BPF_ENCAP_FOU___local);
 	if (ret < 0) {
 		log_err(ret);
 		return TC_ACT_SHOT;
@@ -820,7 +834,7 @@  int ipip_encap_get_tunnel(struct __sk_buff *skb)
 {
 	int ret;
 	struct bpf_tunnel_key key = {};
-	struct bpf_fou_encap encap = {};
+	struct bpf_fou_encap___local encap = {};
 
 	ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0);
 	if (ret < 0) {
@@ -828,7 +842,7 @@  int ipip_encap_get_tunnel(struct __sk_buff *skb)
 		return TC_ACT_SHOT;
 	}
 
-	ret = bpf_skb_get_fou_encap(skb, &encap);
+	ret = bpf_skb_get_fou_encap(skb, (struct bpf_fou_encap *)&encap);
 	if (ret < 0) {
 		log_err(ret);
 		return TC_ACT_SHOT;