Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: Invert the dependency between bpf-netns.h and netns/bpf.h

netns/bpf.h gets included by netdevice.h (thru net_namespace.h)
which in turn gets included in a lot of places. We should keep
netns/bpf.h as light-weight as possible.

bpf-netns.h seems to contain more implementation details than
deserves to be included in a netns header. It needs to pull in
uapi/bpf.h to get various enum types.

Move enum netns_bpf_attach_type to netns/bpf.h and invert the
dependency. This makes netns/bpf.h fit the mold of a struct
definition header more clearly, and drops the number of objects
rebuilt when uapi/bpf.h is touched from 7.7k to 1.1k.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211230012742.770642-3-kuba@kernel.org

authored by

Jakub Kicinski and committed by
Alexei Starovoitov
aebb51ec 3b80b73a

+9 -8
+1 -7
include/linux/bpf-netns.h
··· 3 3 #define _BPF_NETNS_H 4 4 5 5 #include <linux/mutex.h> 6 + #include <net/netns/bpf.h> 6 7 #include <uapi/linux/bpf.h> 7 - 8 - enum netns_bpf_attach_type { 9 - NETNS_BPF_INVALID = -1, 10 - NETNS_BPF_FLOW_DISSECTOR = 0, 11 - NETNS_BPF_SK_LOOKUP, 12 - MAX_NETNS_BPF_ATTACH_TYPE 13 - }; 14 8 15 9 static inline enum netns_bpf_attach_type 16 10 to_netns_bpf_attach_type(enum bpf_attach_type attach_type)
+8 -1
include/net/netns/bpf.h
··· 6 6 #ifndef __NETNS_BPF_H__ 7 7 #define __NETNS_BPF_H__ 8 8 9 - #include <linux/bpf-netns.h> 9 + #include <linux/list.h> 10 10 11 11 struct bpf_prog; 12 12 struct bpf_prog_array; 13 + 14 + enum netns_bpf_attach_type { 15 + NETNS_BPF_INVALID = -1, 16 + NETNS_BPF_FLOW_DISSECTOR = 0, 17 + NETNS_BPF_SK_LOOKUP, 18 + MAX_NETNS_BPF_ATTACH_TYPE 19 + }; 13 20 14 21 struct netns_bpf { 15 22 /* Array of programs to run compiled from progs or links */