Skip to content

Commit d687f62

Browse files
Delyan KratunovAlexei Starovoitov
authored andcommitted
bpf: move bpf_prog to bpf.h
In order to add a version of bpf_prog_run_array which accesses the bpf_prog->aux member, bpf_prog needs to be more than a forward declaration inside bpf.h. Given that filter.h already includes bpf.h, this merely reorders the type declarations for filter.h users. bpf.h users now have access to bpf_prog internals. Signed-off-by: Delyan Kratunov <[email protected]> Link: https://lore.kernel.org/r/3ed7824e3948f22d84583649ccac0ff0d38b6b58.1655248076.git.delyank@fb.com Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 3e6fe5c commit d687f62

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

include/linux/bpf.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define _LINUX_BPF_H 1
66

77
#include <uapi/linux/bpf.h>
8+
#include <uapi/linux/filter.h>
89

910
#include <linux/workqueue.h>
1011
#include <linux/file.h>
@@ -22,6 +23,7 @@
2223
#include <linux/sched/mm.h>
2324
#include <linux/slab.h>
2425
#include <linux/percpu-refcount.h>
26+
#include <linux/stddef.h>
2527
#include <linux/bpfptr.h>
2628
#include <linux/btf.h>
2729

@@ -1084,6 +1086,40 @@ struct bpf_prog_aux {
10841086
};
10851087
};
10861088

1089+
struct bpf_prog {
1090+
u16 pages; /* Number of allocated pages */
1091+
u16 jited:1, /* Is our filter JIT'ed? */
1092+
jit_requested:1,/* archs need to JIT the prog */
1093+
gpl_compatible:1, /* Is filter GPL compatible? */
1094+
cb_access:1, /* Is control block accessed? */
1095+
dst_needed:1, /* Do we need dst entry? */
1096+
blinding_requested:1, /* needs constant blinding */
1097+
blinded:1, /* Was blinded */
1098+
is_func:1, /* program is a bpf function */
1099+
kprobe_override:1, /* Do we override a kprobe? */
1100+
has_callchain_buf:1, /* callchain buffer allocated? */
1101+
enforce_expected_attach_type:1, /* Enforce expected_attach_type checking at attach time */
1102+
call_get_stack:1, /* Do we call bpf_get_stack() or bpf_get_stackid() */
1103+
call_get_func_ip:1, /* Do we call get_func_ip() */
1104+
tstamp_type_access:1; /* Accessed __sk_buff->tstamp_type */
1105+
enum bpf_prog_type type; /* Type of BPF program */
1106+
enum bpf_attach_type expected_attach_type; /* For some prog types */
1107+
u32 len; /* Number of filter blocks */
1108+
u32 jited_len; /* Size of jited insns in bytes */
1109+
u8 tag[BPF_TAG_SIZE];
1110+
struct bpf_prog_stats __percpu *stats;
1111+
int __percpu *active;
1112+
unsigned int (*bpf_func)(const void *ctx,
1113+
const struct bpf_insn *insn);
1114+
struct bpf_prog_aux *aux; /* Auxiliary fields */
1115+
struct sock_fprog_kern *orig_prog; /* Original BPF program */
1116+
/* Instructions for interpreter */
1117+
union {
1118+
DECLARE_FLEX_ARRAY(struct sock_filter, insns);
1119+
DECLARE_FLEX_ARRAY(struct bpf_insn, insnsi);
1120+
};
1121+
};
1122+
10871123
struct bpf_array_aux {
10881124
/* Programs with direct jumps into programs part of this array. */
10891125
struct list_head poke_progs;

include/linux/filter.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -559,40 +559,6 @@ struct bpf_prog_stats {
559559
struct u64_stats_sync syncp;
560560
} __aligned(2 * sizeof(u64));
561561

562-
struct bpf_prog {
563-
u16 pages; /* Number of allocated pages */
564-
u16 jited:1, /* Is our filter JIT'ed? */
565-
jit_requested:1,/* archs need to JIT the prog */
566-
gpl_compatible:1, /* Is filter GPL compatible? */
567-
cb_access:1, /* Is control block accessed? */
568-
dst_needed:1, /* Do we need dst entry? */
569-
blinding_requested:1, /* needs constant blinding */
570-
blinded:1, /* Was blinded */
571-
is_func:1, /* program is a bpf function */
572-
kprobe_override:1, /* Do we override a kprobe? */
573-
has_callchain_buf:1, /* callchain buffer allocated? */
574-
enforce_expected_attach_type:1, /* Enforce expected_attach_type checking at attach time */
575-
call_get_stack:1, /* Do we call bpf_get_stack() or bpf_get_stackid() */
576-
call_get_func_ip:1, /* Do we call get_func_ip() */
577-
tstamp_type_access:1; /* Accessed __sk_buff->tstamp_type */
578-
enum bpf_prog_type type; /* Type of BPF program */
579-
enum bpf_attach_type expected_attach_type; /* For some prog types */
580-
u32 len; /* Number of filter blocks */
581-
u32 jited_len; /* Size of jited insns in bytes */
582-
u8 tag[BPF_TAG_SIZE];
583-
struct bpf_prog_stats __percpu *stats;
584-
int __percpu *active;
585-
unsigned int (*bpf_func)(const void *ctx,
586-
const struct bpf_insn *insn);
587-
struct bpf_prog_aux *aux; /* Auxiliary fields */
588-
struct sock_fprog_kern *orig_prog; /* Original BPF program */
589-
/* Instructions for interpreter */
590-
union {
591-
DECLARE_FLEX_ARRAY(struct sock_filter, insns);
592-
DECLARE_FLEX_ARRAY(struct bpf_insn, insnsi);
593-
};
594-
};
595-
596562
struct sk_filter {
597563
refcount_t refcnt;
598564
struct rcu_head rcu;

0 commit comments

Comments
 (0)