OSDN Git Service

bpf: Introduce dynamic program extensions
[tomoyo/tomoyo-test1.git] / include / linux / bpf.h
index 8e3b8f4..05d1661 100644 (file)
@@ -465,7 +465,8 @@ void notrace __bpf_prog_exit(struct bpf_prog *prog, u64 start);
 enum bpf_tramp_prog_type {
        BPF_TRAMP_FENTRY,
        BPF_TRAMP_FEXIT,
-       BPF_TRAMP_MAX
+       BPF_TRAMP_MAX,
+       BPF_TRAMP_REPLACE, /* more than MAX */
 };
 
 struct bpf_trampoline {
@@ -480,6 +481,11 @@ struct bpf_trampoline {
                void *addr;
                bool ftrace_managed;
        } func;
+       /* if !NULL this is BPF_PROG_TYPE_EXT program that extends another BPF
+        * program by replacing one of its functions. func.addr is the address
+        * of the function it replaced.
+        */
+       struct bpf_prog *extension_prog;
        /* list of BPF programs using this trampoline */
        struct hlist_head progs_hlist[BPF_TRAMP_MAX];
        /* Number of attached programs. A counter per kind. */
@@ -1107,6 +1113,8 @@ int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
                             struct bpf_reg_state *regs);
 int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog,
                          struct bpf_reg_state *reg);
+int btf_check_type_match(struct bpf_verifier_env *env, struct bpf_prog *prog,
+                        struct btf *btf, const struct btf_type *t);
 
 struct bpf_prog *bpf_prog_by_id(u32 id);