Re: [PATCH bpf-next 1/2] bpftool: Accept symbolic map creation flags
From: bot+bpf-ci
Date: Sun Sep 06 2026 - 14:21:22 EST
> diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
> index 75cbcb512eba..95f16fff876e 100644
> --- a/tools/bpf/bpftool/bash-completion/bpftool
> +++ b/tools/bpf/bpftool/bash-completion/bpftool
> @@ -718,6 +718,10 @@ _bpftool()
> esac
> ;;
> create)
> + # Keep a flags list together if readline splits at commas.
> + if [[ $COMP_WORDBREAKS == *,* && ( $cur == , || $prev == , ) ]]; then
> + _get_comp_words_by_ref -n , cur prev
> + fi
> case $prev in
> $command)
> _filedir
> @@ -729,7 +733,26 @@ _bpftool()
> COMPREPLY=( $( compgen -W "$BPFTOOL_MAP_CREATE_TYPES" -- "$cur" ) )
> return 0
> ;;
> - key|value|flags|entries)
> + flags)
> + local flags='BPF_F_NO_PREALLOC BPF_F_NO_COMMON_LRU
> + BPF_F_NUMA_NODE BPF_F_RDONLY BPF_F_WRONLY
> + BPF_F_STACK_BUILD_ID BPF_F_ZERO_SEED
> + BPF_F_RDONLY_PROG BPF_F_WRONLY_PROG BPF_F_CLONE
> + BPF_F_MMAPABLE BPF_F_PRESERVE_ELEMS BPF_F_INNER_MAP
> + BPF_F_LINK BPF_F_VTYPE_BTF_OBJ_FD BPF_F_TOKEN_FD
> + BPF_F_SEGV_ON_FAULT BPF_F_NO_USER_CONV
> + BPF_F_RB_OVERWRITE'
> + local prefix= flag
> + # Readline replaces only the suffix after a word break.
> + if [[ $cur == *,* && $COMP_WORDBREAKS != *,* ]]; then
> + prefix="${cur%,*},"
> + fi
> + for flag in $(compgen -W "$flags" -- "${cur##*,}"); do
> + COMPREPLY+=( "${prefix}${flag}" )
> + done
> + return 0
> + ;;
> + key|value|entries)
> return 0
> ;;
Can the comma-separated completion work as written? When bash completes a
single match, it appends a trailing space, which splits the argument into
two words. Example:
$ bpftool map create /sys/fs/bpf/m type hash key 4 value 4 \
entries 1 name m flags BPF_F_MM<TAB>
completes to:
... flags BPF_F_MMAPABLE ,BPF_F_RDONLY
That becomes two argv words (the space before the comma). do_create() in
map.c consumes "flags BPF_F_MMAPABLE" and re-enters its loop with only
",BPF_F_RDONLY" left, so REQ_ARGS(2) fails with the message "'
BPF_F_MMAPABLE' needs at least 2 arguments, 1 found". To build a multi-
flag list the user has to delete the inserted space by hand, which defeats
the prefix-preservation logic at lines 745-749.
The usual fix is `compopt -o nospace` when emitting list elements (guarded
for shells without compopt), or suppressing the space only when more than
one flag remains plausible.
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/34048916873