bpf, net: introduce bpf_struct_ops_desc.
[sfrench/cifs-2.6.git] / net / bpf / bpf_dummy_struct_ops.c
index 8906f7bdf4a92ad24f23efe51c2ffb0f6fdd49e2..ba2c58dba2da56663f3559ee4718e460e997807e 100644 (file)
@@ -22,6 +22,8 @@ struct bpf_dummy_ops_test_args {
        struct bpf_dummy_ops_state state;
 };
 
+static struct btf *bpf_dummy_ops_btf;
+
 static struct bpf_dummy_ops_test_args *
 dummy_ops_init_args(const union bpf_attr *kattr, unsigned int nr)
 {
@@ -90,9 +92,15 @@ int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr,
        void *image = NULL;
        unsigned int op_idx;
        int prog_ret;
+       s32 type_id;
        int err;
 
-       if (prog->aux->attach_btf_id != st_ops->type_id)
+       type_id = btf_find_by_name_kind(bpf_dummy_ops_btf,
+                                       bpf_bpf_dummy_ops.name,
+                                       BTF_KIND_STRUCT);
+       if (type_id < 0)
+               return -EINVAL;
+       if (prog->aux->attach_btf_id != type_id)
                return -EOPNOTSUPP;
 
        func_proto = prog->aux->attach_func_proto;
@@ -148,6 +156,7 @@ out:
 
 static int bpf_dummy_init(struct btf *btf)
 {
+       bpf_dummy_ops_btf = btf;
        return 0;
 }