On Sat, Jun 8, 2024 at 2:01 AM Benjamin Tissoires <bentiss@xxxxxxxxxx> wrote: > > + > +static int hid_bpf_ops_init_member(const struct btf_type *t, > + const struct btf_member *member, > + void *kdata, const void *udata) > +{ > + u32 moff = __btf_member_bit_offset(t, member) / 8; > + u32 flags; > + > + switch (moff) { > + case offsetof(struct hid_bpf_ops, hid_id): > + /* For hid_id and flags fields, this function has to copy it > + * and return 1 to indicate that the data has been handled by > + * the struct_ops type, or the verifier will reject the map if > + * the value of those fields is not zero. > + */ > + ((struct hid_bpf_ops *)kdata)->hid_id = ((struct hid_bpf_ops *)udata)->hid_id; > + return 1; > + case offsetof(struct hid_bpf_ops, flags): > + flags = ((struct hid_bpf_ops *)udata)->flags; > + if (flags & ~BPF_F_BEFORE) > + return -EINVAL; > + ((struct hid_bpf_ops *)kdata)->flags = flags; minor nit: I'd cast kdata/udate in the beginning of the function to make the lines shorter and less verbose. Similar to how bpf_tcp_ca_init_member() does it. Acked-by: Alexei Starovoitov <ast@xxxxxxxxxx>