@@ -165,6 +165,7 @@ int btf_find_spin_lock(const struct btf *btf, const struct btf_type *t);
int btf_find_timer(const struct btf *btf, const struct btf_type *t);
struct bpf_map_value_off *btf_parse_kptrs(const struct btf *btf,
const struct btf_type *t);
+int btf_find_dynptr(const struct btf *btf, const struct btf_type *t);
bool btf_type_is_void(const struct btf_type *t);
s32 btf_find_by_name_kind(const struct btf *btf, const char *name, u8 kind);
const struct btf_type *btf_type_skip_modifiers(const struct btf *btf,
@@ -3522,6 +3522,19 @@ struct bpf_map_value_off *btf_parse_kptrs(const struct btf *btf,
return ERR_PTR(ret);
}
+/* Now only allow to use 'struct bpf_dynptr' as map key.
+ * Map key with embedded bpf_dynptr is not allowed.
+ */
+int btf_find_dynptr(const struct btf *btf, const struct btf_type *t)
+{
+ /* Only allow struct type */
+ if (__btf_type_is_struct(t) && t->size == sizeof(struct bpf_dynptr) &&
+ !strcmp("bpf_dynptr", __btf_name_by_offset(btf, t->name_off)))
+ return 0;
+
+ return -EINVAL;
+}
+
static void __btf_struct_show(const struct btf *btf, const struct btf_type *t,
u32 type_id, void *data, u8 bits_offset,
struct btf_show *show)