public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [v3 PATCH bpf-next 0/4] bpftool: add tcx subcommand in net
@ 2024-07-21 14:33 Tao Chen
  2024-07-21 14:33 ` [v3 PATCH bpf-next 1/4] bpftool: refactor xdp attach/detach type judgment Tao Chen
  2024-07-22 14:50 ` [v3 PATCH bpf-next 0/4] bpftool: add tcx subcommand in net patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Tao Chen @ 2024-07-21 14:33 UTC (permalink / raw)
  To: Quentin Monnet, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, chen.dylane
  Cc: Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, bpf,
	linux-kernel

XDP prog has already realised with net attach/detach subcommand.
As Qmonnet said [0], tcx prog may also can be added. So this patch set
adds tcx subcommand in net attach/detach.

[0] https://github.com/libbpf/bpftool/issues/124

Change list:
- v2 -> v3:
    - fix return value in patch2
    - replace tabs with spaces patch2
- v1 -> v2:
  - As suggested by Quentin, modification as fellows:
    - refactor xdp attach/detach type judgment in patch1
    - err handle fix for xdp in patch2
    - change command tcx* to tcx_* in patch2
    - some code modification for readable in patch2
    - document modification for readable in patch4

Revisions:
- v1 https://lore.kernel.org/bpf/20240715113704.1279881-1-chen.dylane@gmail.com
- v2 https://lore.kernel.org/bpf/20240717174524.1511212-1-chen.dylane@gmail.com

Tao Chen (4):
  bpftool: refactor xdp attach/detach type judgment
  bpftool: add net attach/detach command to tcx prog
  bpftool: add bash-completion for tcx subcommand
  bpftool: add document for net attach/detach on tcx subcommand

 .../bpf/bpftool/Documentation/bpftool-net.rst | 22 +++++-
 tools/bpf/bpftool/bash-completion/bpftool     |  2 +-
 tools/bpf/bpftool/net.c                       | 69 +++++++++++++++++--
 3 files changed, 85 insertions(+), 8 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [v3 PATCH bpf-next 1/4] bpftool: refactor xdp attach/detach type judgment
  2024-07-21 14:33 [v3 PATCH bpf-next 0/4] bpftool: add tcx subcommand in net Tao Chen
@ 2024-07-21 14:33 ` Tao Chen
  2024-07-22 14:50 ` [v3 PATCH bpf-next 0/4] bpftool: add tcx subcommand in net patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Tao Chen @ 2024-07-21 14:33 UTC (permalink / raw)
  To: Quentin Monnet, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, chen.dylane
  Cc: Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, bpf,
	linux-kernel

This commit no logical changed, just increases code readability and
facilitates TCX prog expansion, which will be implemented in the next
patch.

Acked-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Tao Chen <chen.dylane@gmail.com>
---
 tools/bpf/bpftool/net.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/tools/bpf/bpftool/net.c b/tools/bpf/bpftool/net.c
index 968714b4c3d4..1b9f4225b394 100644
--- a/tools/bpf/bpftool/net.c
+++ b/tools/bpf/bpftool/net.c
@@ -684,10 +684,18 @@ static int do_attach(int argc, char **argv)
 		}
 	}
 
+	switch (attach_type) {
 	/* attach xdp prog */
-	if (is_prefix("xdp", attach_type_strings[attach_type]))
-		err = do_attach_detach_xdp(progfd, attach_type, ifindex,
-					   overwrite);
+	case NET_ATTACH_TYPE_XDP:
+	case NET_ATTACH_TYPE_XDP_GENERIC:
+	case NET_ATTACH_TYPE_XDP_DRIVER:
+	case NET_ATTACH_TYPE_XDP_OFFLOAD:
+		err = do_attach_detach_xdp(progfd, attach_type, ifindex, overwrite);
+		break;
+	default:
+		break;
+	}
+
 	if (err) {
 		p_err("interface %s attach failed: %s",
 		      attach_type_strings[attach_type], strerror(-err));
@@ -721,10 +729,18 @@ static int do_detach(int argc, char **argv)
 	if (ifindex < 1)
 		return -EINVAL;
 
+	switch (attach_type) {
 	/* detach xdp prog */
-	progfd = -1;
-	if (is_prefix("xdp", attach_type_strings[attach_type]))
+	case NET_ATTACH_TYPE_XDP:
+	case NET_ATTACH_TYPE_XDP_GENERIC:
+	case NET_ATTACH_TYPE_XDP_DRIVER:
+	case NET_ATTACH_TYPE_XDP_OFFLOAD:
+		progfd = -1;
 		err = do_attach_detach_xdp(progfd, attach_type, ifindex, NULL);
+		break;
+	default:
+		break;
+	}
 
 	if (err < 0) {
 		p_err("interface %s detach failed: %s",
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [v3 PATCH bpf-next 0/4] bpftool: add tcx subcommand in net
  2024-07-21 14:33 [v3 PATCH bpf-next 0/4] bpftool: add tcx subcommand in net Tao Chen
  2024-07-21 14:33 ` [v3 PATCH bpf-next 1/4] bpftool: refactor xdp attach/detach type judgment Tao Chen
@ 2024-07-22 14:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-07-22 14:50 UTC (permalink / raw)
  To: Tao Chen
  Cc: qmo, ast, daniel, andrii, martin.lau, eddyz87, song,
	yonghong.song, john.fastabend, bpf, linux-kernel

Hello:

This series was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Sun, 21 Jul 2024 22:33:49 +0800 you wrote:
> XDP prog has already realised with net attach/detach subcommand.
> As Qmonnet said [0], tcx prog may also can be added. So this patch set
> adds tcx subcommand in net attach/detach.
> 
> [0] https://github.com/libbpf/bpftool/issues/124
> 
> Change list:
> - v2 -> v3:
>     - fix return value in patch2
>     - replace tabs with spaces patch2
> - v1 -> v2:
>   - As suggested by Quentin, modification as fellows:
>     - refactor xdp attach/detach type judgment in patch1
>     - err handle fix for xdp in patch2
>     - change command tcx* to tcx_* in patch2
>     - some code modification for readable in patch2
>     - document modification for readable in patch4
> 
> [...]

Here is the summary with links:
  - [v3,bpf-next,1/4] bpftool: refactor xdp attach/detach type judgment
    https://git.kernel.org/bpf/bpf-next/c/f408126f7b33
  - [v3,bpf-next,2/4] bpftool: add net attach/detach command to tcx prog
    https://git.kernel.org/bpf/bpf-next/c/7f1cfa6b64c6
  - [v3,bpf-next,3/4] bpftool: add bash-completion for tcx subcommand
    https://git.kernel.org/bpf/bpf-next/c/0445e0c5c2e1
  - [v3,bpf-next,4/4] bpftool: add document for net attach/detach on tcx subcommand
    https://git.kernel.org/bpf/bpf-next/c/6d5848d4fe98

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-22 14:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-21 14:33 [v3 PATCH bpf-next 0/4] bpftool: add tcx subcommand in net Tao Chen
2024-07-21 14:33 ` [v3 PATCH bpf-next 1/4] bpftool: refactor xdp attach/detach type judgment Tao Chen
2024-07-22 14:50 ` [v3 PATCH bpf-next 0/4] bpftool: add tcx subcommand in net patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox