Skip to content

Commit 2dfd184

Browse files
wdebruijborkmann
authored andcommitted
flow_dissector: fix build failure without CONFIG_NET
If boolean CONFIG_BPF_SYSCALL is enabled, kernel/bpf/syscall.c will call flow_dissector functions from net/core/flow_dissector.c. This causes this build failure if CONFIG_NET is disabled: kernel/bpf/syscall.o: In function `__x64_sys_bpf': syscall.c:(.text+0x3278): undefined reference to `skb_flow_dissector_bpf_prog_attach' syscall.c:(.text+0x3310): undefined reference to `skb_flow_dissector_bpf_prog_detach' kernel/bpf/syscall.o:(.rodata+0x3f0): undefined reference to `flow_dissector_prog_ops' kernel/bpf/verifier.o:(.rodata+0x250): undefined reference to `flow_dissector_verifier_ops' Analogous to other optional BPF program types in syscall.c, add stubs if the relevant functions are not compiled and move the BPF_PROG_TYPE definition in the #ifdef CONFIG_NET block. Fixes: d58e468 ("flow_dissector: implements flow dissector BPF hook") Reported-by: Randy Dunlap <[email protected]> Signed-off-by: Willem de Bruijn <[email protected]> Acked-by: Randy Dunlap <[email protected]> # build-tested Acked-by: Yonghong Song <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 534e0e5 commit 2dfd184

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

include/linux/bpf_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_SEG6LOCAL, lwt_seg6local)
1616
BPF_PROG_TYPE(BPF_PROG_TYPE_SOCK_OPS, sock_ops)
1717
BPF_PROG_TYPE(BPF_PROG_TYPE_SK_SKB, sk_skb)
1818
BPF_PROG_TYPE(BPF_PROG_TYPE_SK_MSG, sk_msg)
19+
BPF_PROG_TYPE(BPF_PROG_TYPE_FLOW_DISSECTOR, flow_dissector)
1920
#endif
2021
#ifdef CONFIG_BPF_EVENTS
2122
BPF_PROG_TYPE(BPF_PROG_TYPE_KPROBE, kprobe)
@@ -32,7 +33,6 @@ BPF_PROG_TYPE(BPF_PROG_TYPE_LIRC_MODE2, lirc_mode2)
3233
#ifdef CONFIG_INET
3334
BPF_PROG_TYPE(BPF_PROG_TYPE_SK_REUSEPORT, sk_reuseport)
3435
#endif
35-
BPF_PROG_TYPE(BPF_PROG_TYPE_FLOW_DISSECTOR, flow_dissector)
3636

3737
BPF_MAP_TYPE(BPF_MAP_TYPE_ARRAY, array_map_ops)
3838
BPF_MAP_TYPE(BPF_MAP_TYPE_PERCPU_ARRAY, percpu_array_map_ops)

include/linux/skbuff.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,10 +1194,23 @@ void skb_flow_dissector_init(struct flow_dissector *flow_dissector,
11941194
const struct flow_dissector_key *key,
11951195
unsigned int key_count);
11961196

1197+
#ifdef CONFIG_NET
11971198
int skb_flow_dissector_bpf_prog_attach(const union bpf_attr *attr,
11981199
struct bpf_prog *prog);
11991200

12001201
int skb_flow_dissector_bpf_prog_detach(const union bpf_attr *attr);
1202+
#else
1203+
static inline int skb_flow_dissector_bpf_prog_attach(const union bpf_attr *attr,
1204+
struct bpf_prog *prog)
1205+
{
1206+
return -EOPNOTSUPP;
1207+
}
1208+
1209+
static inline int skb_flow_dissector_bpf_prog_detach(const union bpf_attr *attr)
1210+
{
1211+
return -EOPNOTSUPP;
1212+
}
1213+
#endif
12011214

12021215
bool __skb_flow_dissect(const struct sk_buff *skb,
12031216
struct flow_dissector *flow_dissector,

0 commit comments

Comments
 (0)