]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/bpf: Use local type for bpf_fou_encap in test_tunnel_kern
authorGregory Bell <grbell@redhat.com>
Fri, 17 Apr 2026 15:41:22 +0000 (11:41 -0400)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 26 Apr 2026 23:42:23 +0000 (16:42 -0700)
Replace the forward-declared struct bpf_fou_encap with the existing
bpf_fou_encap___local type in the bpf_skb_set_fou_encap and
bpf_skb_get_fou_encap declarations. This removes the need for
the forward declaration and the explicit casts at each call.

Fixes: d17f9b370df6 ("selftests/bpf: Fix compilation failure when CONFIG_NET_FOU!=y")
Signed-off-by: Gregory Bell <grbell@redhat.com>
Link: https://lore.kernel.org/r/20260417154122.2558890-3-grbell@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/test_tunnel_kern.c

index 32127f1cd6872e8ce0bf3a068ec693c085424388..30f1de458669d37f5679262374456f8717ea4577 100644 (file)
@@ -6,6 +6,7 @@
  * modify it under the terms of version 2 of the GNU General Public
  * License as published by the Free Software Foundation.
  */
+#define BPF_NO_KFUNC_PROTOTYPES
 #include "vmlinux.h"
 #include <bpf/bpf_core_read.h>
 #include <bpf/bpf_helpers.h>
@@ -36,12 +37,10 @@ enum bpf_fou_encap_type___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;
+                         struct bpf_fou_encap___local *encap, int type) __ksym;
 int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx,
-                         struct bpf_fou_encap *encap) __ksym;
+                         struct bpf_fou_encap___local *encap) __ksym;
 struct xfrm_state *
 bpf_xdp_get_xfrm_state(struct xdp_md *ctx, struct bpf_xfrm_state_opts *opts,
                       u32 opts__sz) __ksym;
@@ -781,7 +780,7 @@ int ipip_gue_set_tunnel(struct __sk_buff *skb)
        encap.sport = 0;
        encap.dport = bpf_htons(5555);
 
-       ret = bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap,
+       ret = bpf_skb_set_fou_encap(skb, &encap,
                                    bpf_core_enum_value(enum bpf_fou_encap_type___local,
                                                        FOU_BPF_ENCAP_GUE___local));
        if (ret < 0) {
@@ -820,7 +819,7 @@ int ipip_fou_set_tunnel(struct __sk_buff *skb)
        encap.sport = 0;
        encap.dport = bpf_htons(5555);
 
-       ret = bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap,
+       ret = bpf_skb_set_fou_encap(skb, &encap,
                                    FOU_BPF_ENCAP_FOU___local);
        if (ret < 0) {
                log_err(ret);
@@ -843,7 +842,7 @@ int ipip_encap_get_tunnel(struct __sk_buff *skb)
                return TC_ACT_SHOT;
        }
 
-       ret = bpf_skb_get_fou_encap(skb, (struct bpf_fou_encap *)&encap);
+       ret = bpf_skb_get_fou_encap(skb, &encap);
        if (ret < 0) {
                log_err(ret);
                return TC_ACT_SHOT;