Open a-nogikh opened 10 months ago
For the second struct we also want something like flags[bpf_attach_flags & ~BPF_F_ID, int32]
, right?
Or, BPF_F_ID is just assumed to not be present in bpf_attach_flags
?
FTR https://github.com/google/syzkaller/issues/2226 is an approach that could address the problem from the other side (determine the field depending on flags).
Do we need to support several always present flags?
I think that would be useful. The id_or_fd
union we have for BPF is a good example. Right now it's a single union for all 4 cases, but ideally we should be able to distinguish based on the flags of the parent structures: bpf_attach_arg
and bpf_detach_arg
. Flag BPF_F_ID
tells us id_or_fd
is an ID, as in my original example. But in addition, BPF_F_LINK
tells us id_or_fd
points to a link (vs. a program).
For the second struct we also want something like
flags[bpf_attach_flags & ~BPF_F_ID, int32]
, right? Or, BPF_F_ID is just assumed to not be present inbpf_attach_flags
?
Yeah, that's correct. We'd ideally want to be able to exclude flags as well.
FTR #2226 is an approach that could address the problem from the other side (determine the field depending on flags).
That syntax definitely looks more flexible to me, though I'm guessing it's harder to support.
From the mailing list:
This could fit nicely in the expression evaluation support feature: e.g.
flags[bpf_attach_flags | BPF_F_ID, int32]
. But it's unlikely to be implemented soon, so extending theflag
type definition makes sense.We still need to determine:
flags "[" flag-list "," type ["," default-flag-value] "]"
flags "[" flag-list ["|" flag-name] "," type "]"
Cc @pchaigno
N.B. There are also string flags. The feature is not applicable to them.