On Thu, Dec 14, 2023 at 7:58 AM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > On Wed, Dec 13, 2023 at 02:23:26PM -0800, Andrii Nakryiko wrote: > > Besides already supported special "any" value and hex bit mask, support > > string-based parsing of delegation masks based on exact enumerator > > names. Utilize BTF information of `enum bpf_cmd`, `enum bpf_map_type`, > > `enum bpf_prog_type`, and `enum bpf_attach_type` types to find supported > > symbolic names (ignoring __MAX_xxx guard values). So "BPF_PROG_LOAD" and > > "BPF_MAP_CREATE" are valid values to specify for delegate_cmds options, > > "BPF_MAP_TYPE_ARRAY" is among supported for map types, etc. > > > > Besides supporting string values, we also support multiple values > > specified at the same time, using colon (':') separator. > > > > There are corresponding changes on bpf_show_options side to use known > > values to print them in human-readable format, falling back to hex mask > > printing, if there are any unrecognized bits. This shouldn't be > > necessary when enum BTF information is present, but in general we should > > always be able to fall back to this even if kernel was built without BTF. > > > > Example below shows various ways to specify delegate_cmds options > > through mount command and how mount options are printed back: > > > > $ sudo mkdir -p /sys/fs/bpf/token > > $ sudo mount -t bpf bpffs /sys/fs/bpf/token \ > > -o delegate_cmds=BPF_PROG_LOAD \ > > -o delegate_cmds=BPF_MAP_CREATE \ > > -o delegate_cmds=BPF_TOKEN_CREATE:BPF_BTF_LOAD:BPF_LINK_CREATE > > $ mount | grep token > > bpffs on /sys/fs/bpf/token type bpf (rw,relatime,delegate_cmds=BPF_MAP_CREATE:BPF_PROG_LOAD:BPF_BTF_LOAD:BPF_LINK_CREATE:BPF_TOKEN_CREATE) > > imo this is too verbose. > For cmds it doesn't look as bad. "BPF_" prefix is repetitive, but not overly so. > But for maps and progs it will be bad. > It will look like: > delegate_progs=BPF_PROG_TYPE_SOCKET_FILTER:BPF_PROG_TYPE_SOCKET_XDP:BPF_PROG_TYPE_SCHED_CLS > which is not readable. > delegate_progs=SOCKET_FILTER:XDP:SCHED_CLS > is much better. > > And I would go further (like libbpf does) and lower case them for output > while allow both upper and lower for input: > delegate_progs=socket_filter:xdp:sched_cls. Ok, I was wondering if someone would complain about this :) Makes sense, I'll do it more flexibly and succinctly. > > Because of stripping the prefix for maps and progs I would strip the prefix for cmds too > for consistency. > > pw-bot: cr >