mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: hi@tychen.cc,bpf@vger.kernel.org
Cc: hi@tychen.cc,qmo@kernel.org,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,shuah@kernel.org,linux-kernel@vger.kernel.org,linux-kselftest@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next 1/2] bpftool: Accept symbolic map creation flags
Date: Sun,  6 Sep 2026 18:16:45 +0000 (UTC)	[thread overview]
Message-ID: <4e6b09c913c4320ca7849be75acc2eb88b61564e7f3a75d768ef86c392b3786c@mail.kernel.org> (raw)
In-Reply-To: <20260906170715.1212085-2-hi@tychen.cc>

[-- Attachment #1: Type: text/plain, Size: 3502 bytes --]

> 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

  reply	other threads:[~2026-09-06 18:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 17:07 [PATCH bpf-next 0/2] bpftool: Support " Tianyi Chen
2026-09-06 17:07 ` [PATCH bpf-next 1/2] bpftool: Accept " Tianyi Chen
2026-09-06 18:16   ` bot+bpf-ci [this message]
2026-09-06 17:07 ` [PATCH bpf-next 2/2] selftests/bpf: Cover symbolic bpftool " Tianyi Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4e6b09c913c4320ca7849be75acc2eb88b61564e7f3a75d768ef86c392b3786c@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=hi@tychen.cc \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --cc=qmo@kernel.org \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®