Skip to content

Commit 3bd401e

Browse files
kuba-mooNobody
authored andcommitted
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 <[email protected]>
1 parent 2b5d688 commit 3bd401e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

include/linux/bpf-netns.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@
33
#define _BPF_NETNS_H
44

55
#include <linux/mutex.h>
6+
#include <net/netns/bpf.h>
67
#include <uapi/linux/bpf.h>
78

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-
159
static inline enum netns_bpf_attach_type
1610
to_netns_bpf_attach_type(enum bpf_attach_type attach_type)
1711
{

include/net/netns/bpf.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@
66
#ifndef __NETNS_BPF_H__
77
#define __NETNS_BPF_H__
88

9-
#include <linux/bpf-netns.h>
9+
#include <linux/list.h>
1010

1111
struct bpf_prog;
1212
struct bpf_prog_array;
1313

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+
};
20+
1421
struct netns_bpf {
1522
/* Array of programs to run compiled from progs or links */
1623
struct bpf_prog_array __rcu *run_array[MAX_NETNS_BPF_ATTACH_TYPE];

0 commit comments

Comments
 (0)