BPF List
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Wang Yufen <wangyufen@huawei.com>,
	quentin@isovalent.com, ast@kernel.org, andrii@kernel.org,
	martin.lau@linux.dev, song@kernel.org, yhs@fb.com,
	john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com,
	haoluo@google.com, jolsa@kernel.org, davem@davemloft.net,
	kuba@kernel.org, hawk@kernel.org, nathan@kernel.org,
	ndesaulniers@google.com, trix@redhat.com
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [bpf-next v6 2/3] bpftool: Update doc (add autoattach to prog load)
Date: Mon, 26 Sep 2022 18:20:35 +0200	[thread overview]
Message-ID: <2b001fcb-4340-e1ba-4b84-a69c670cf09a@iogearbox.net> (raw)
In-Reply-To: <1664014430-5286-2-git-send-email-wangyufen@huawei.com>

On 9/24/22 12:13 PM, Wang Yufen wrote:
> Add autoattach optional to prog load|loadall for supporting
> one-step load-attach-pin_link.
> 
> Signed-off-by: Wang Yufen <wangyufen@huawei.com>
> ---
>   tools/bpf/bpftool/Documentation/bpftool-prog.rst | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/bpf/bpftool/Documentation/bpftool-prog.rst b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
> index eb1b2a254eb1..2d9f27a0120f 100644
> --- a/tools/bpf/bpftool/Documentation/bpftool-prog.rst
> +++ b/tools/bpf/bpftool/Documentation/bpftool-prog.rst
> @@ -31,7 +31,7 @@ PROG COMMANDS
>   |	**bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes** | **visual** | **linum**}]
>   |	**bpftool** **prog dump jited**  *PROG* [{**file** *FILE* | **opcodes** | **linum**}]
>   |	**bpftool** **prog pin** *PROG* *FILE*
> -|	**bpftool** **prog** { **load** | **loadall** } *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*]
> +|	**bpftool** **prog** { **load** | **loadall** } *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*] [**autoattach**]
>   |	**bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
>   |	**bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
>   |	**bpftool** **prog tracelog**
> @@ -131,7 +131,7 @@ DESCRIPTION
>   		  contain a dot character ('.'), which is reserved for future
>   		  extensions of *bpffs*.
>   
> -	**bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*]
> +	**bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*] [**autoattach**]
>   		  Load bpf program(s) from binary *OBJ* and pin as *PATH*.
>   		  **bpftool prog load** pins only the first program from the
>   		  *OBJ* as *PATH*. **bpftool prog loadall** pins all programs
> @@ -150,6 +150,15 @@ DESCRIPTION
>   		  Optional **pinmaps** argument can be provided to pin all
>   		  maps under *MAP_DIR* directory.
>   
> +		  If **autoattach** is specified program will be attached
> +		  before pin. In that case, only the link (representing the
> +		  program attached to its hook) is pinned, not the program as
> +		  such, so the path won't show in "**bpftool prog show -f**",
> +		  only show in "**bpftool link show -f**". Also, this only works
> +		  when bpftool (libbpf) is able to infer all necessary information
> +		  from the objectfile, in particular, it's not supported for all
> +		  program types.

Related to Quentin's comment, the documentation should also describe clear semantics
on what happens in failure case. I presume the use case you have in mind is to use
this facility for scripts e.g. to run/load some tests objs? Thus would be good to describe
to users what they need to do/clean up when things only partially succeed etc..

>   		  Note: *PATH* must be located in *bpffs* mount. It must not
>   		  contain a dot character ('.'), which is reserved for future
>   		  extensions of *bpffs*.
> 


  reply	other threads:[~2022-09-26 17:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-24 10:13 [bpf-next v6 1/3] bpftool: Add auto_attach for bpf prog load|loadall Wang Yufen
2022-09-24 10:13 ` [bpf-next v6 2/3] bpftool: Update doc (add autoattach to prog load) Wang Yufen
2022-09-26 16:20   ` Daniel Borkmann [this message]
2022-09-27 11:05     ` wangyufen
2022-09-24 10:13 ` [bpf-next v6 3/3] bpftool: Update the bash completion(add " Wang Yufen
2022-09-26 10:46 ` [bpf-next v6 1/3] bpftool: Add auto_attach for bpf prog load|loadall Quentin Monnet
2022-09-27 11:04   ` wangyufen

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=2b001fcb-4340-e1ba-4b84-a69c670cf09a@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=haoluo@google.com \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=martin.lau@linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=quentin@isovalent.com \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=trix@redhat.com \
    --cc=wangyufen@huawei.com \
    --cc=yhs@fb.com \
    /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