selftests/bpf: fix qdisc kfunc declarations
Subsystems (3)
PATCH 1/1 selftests/bpf: fix qdisc kfunc declarations
The qdisc BPF selftests fail to build because qdisc-related kfuncs are used without proper declarations, and struct bpf_sk_buff_ptr is only introduced in a function prototype scope, triggering -Wvisibility and type mismatch errors under -Werror.
Fix the build by:
- adding a file-scope forward declaration for struct bpf_sk_buff_ptr
- declaring qdisc kfuncs (bpf_qdisc_* and bpf_skb_get_hash/bpf_kfree_skb) as __ksym in the shared header
- including required BPF headers in qdisc test progs
Tested: make -C tools/testing/selftests/bpf OUTPUT=/tmp/selftests-bpf \/tmp/selftests-bpf/bpf_qdisc_fifo.bpf.o \/tmp/selftests-bpf/bpf_qdisc_fq.bpf.o \/tmp/selftests-bpf/bpf_qdisc_fail__incompl_ops.bpf.o
--- .../selftests/bpf/progs/bpf_qdisc_common.h | 17 +++++++++++++++++ .../bpf/progs/bpf_qdisc_fail__incompl_ops.c | 4 ++++ .../selftests/bpf/progs/bpf_qdisc_fifo.c | 4 ++++ .../testing/selftests/bpf/progs/bpf_qdisc_fq.c | 1 + 4 files changed, 26 insertions(+)
tools/testing/selftests/bpf/progs/bpf_qdisc_common.h +17 -0
@@ -3,6 +3,9 @@#ifndef _BPF_QDISC_COMMON_H#define _BPF_QDISC_COMMON_H +#include <vmlinux.h> +#include <bpf/bpf_helpers.h> +#define NET_XMIT_SUCCESS 0x00#define NET_XMIT_DROP 0x01/* skb dropped */ #define NET_XMIT_CN 0x02/* congestion notification */
@@ -14,6 +17,20 @@struct bpf_sk_buff_ptr ; +/* kfunc declarations provided via vmlinux BTF */ +extern void bpf_qdisc_skb_drop(struct sk_buff *skb, + struct bpf_sk_buff_ptr *to_free) __ksym; + +extern void bpf_qdisc_bstats_update(struct Qdisc *sch, + const struct sk_buff *skb) __ksym; + +extern void bpf_qdisc_watchdog_schedule(struct Qdisc *sch, + u64 expire, u64 delta_ns) __ksym; + +extern __u32 bpf_skb_get_hash(struct sk_buff *skb) __ksym; + +extern void bpf_kfree_skb(struct sk_buff *skb) __ksym; +static struct qdisc_skb_cb *qdisc_skb_cb (const struct sk_buff *skb) {return (struct qdisc_skb_cb *)skb->cb;
tools/testing/selftests/bpf/progs/bpf_qdisc_fail__incompl_ops.c +4 -0
@@ -1,6 +1,10 @@// SPDX-License-Identifier: GPL-2.0 #include <vmlinux.h> + +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> +#include "bpf_experimental.h" #include "bpf_qdisc_common.h"
tools/testing/selftests/bpf/progs/bpf_qdisc_fifo.c +4 -0
@@ -1,6 +1,10 @@// SPDX-License-Identifier: GPL-2.0 #include <vmlinux.h> + +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> +#include "bpf_experimental.h" #include "bpf_qdisc_common.h"
tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c +1 -0
@@ -35,6 +35,7 @@#include <vmlinux.h> #include <errno.h> #include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> #include "bpf_experimental.h" #include "bpf_qdisc_common.h"
Signature · 1 line
2.43.0
Quoted 46 lines · Sun Jian
The qdisc BPF selftests fail to build because qdisc-related kfuncs are used without proper declarations, and struct
bpf_sk_buff_ptris only introduced in a function prototype scope, triggering -Wvisibility and type mismatch errors under -Werror.Fix the build by:
- adding a file-scope forward declaration for structbpf_sk_buff_ptr
- declaring qdisc kfuncs (bpf_qdisc_* and bpf_skb_get_hash/bpf_kfree_skb) as__ksymin the shared header
- including required BPF headers in qdisc test progsTested: make -C
tools/testing/selftests/bpfOUTPUT=/tmp/selftests-bpf \/tmp/selftests-bpf/bpf_qdisc_fifo.bpf.o\/tmp/selftests-bpf/bpf_qdisc_fq.bpf.o\/tmp/selftests-bpf/bpf_qdisc_fail__incompl_ops.bpf.oSigned-off-by Sun Jian <[email protected]>--- .../selftests/bpf/progs/bpf_qdisc_common.h | 17 +++++++++++++++++ .../bpf/progs/bpf_qdisc_fail__incompl_ops.c | 4 ++++ .../selftests/bpf/progs/bpf_qdisc_fifo.c | 4 ++++ .../testing/selftests/bpf/progs/bpf_qdisc_fq.c | 1 + 4 files changed, 26 insertions(+)tools/testing/selftests/bpf/progs/bpf_qdisc_common.h +6
-0@@ -3,6 +3,9 @@#ifndef _BPF_QDISC_COMMON_H#define _BPF_QDISC_COMMON_H +#include <vmlinux.h> +#include <bpf/bpf_helpers.h> +#define NET_XMIT_SUCCESS 0x00#define NET_XMIT_DROP 0x01/* skb dropped */ #define NET_XMIT_CN 0x02/* congestion notification */ @@ -14,6 +17,20 @@struct bpf_sk_buff_ptr ; +/* kfunc declarations provided via vmlinux BTF */ +extern void bpf_qdisc_skb_drop(struct sk_buff *skb, + struct bpf_sk_buff_ptr *to_free) __ksym;
tools/testing/selftests/bpf/progs/bpf_qdisc_common.h line 32
Quoted 10 lines
tools/testing/selftests/bpf/progs/bpf_qdisc_common.h +10
-0+ +extern void bpf_qdisc_bstats_update(struct Qdisc *sch, + const struct sk_buff *skb) __ksym; + +extern void bpf_qdisc_watchdog_schedule(struct Qdisc *sch, + u64 expire, u64 delta_ns) __ksym; + +extern __u32 bpf_skb_get_hash(struct sk_buff *skb) __ksym; + +extern void bpf_kfree_skb(struct sk_buff *skb) __ksym;
Stop this spam.
You keep ignoring earlier feedback.
pw-bot: cr
Quoted 2 lines · Alexei Starovoitov
Stop this spam.
You keep ignoring earlier feedback.
Sorry. I misdiagnosed a local build/setup issue as a kernel bug. I’ll stop sending patches and fix my setup first.
Thanks,
Sun