From patchwork Mon Jul 15 11:37:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Chen X-Patchwork-Id: 13733348 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A62C518A925; Mon, 15 Jul 2024 11:37:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043434; cv=none; b=Vj9suj+V8kRgLL6hjE62ooKnqiKoyyXDtw2pD8rzt9t5g1wR4/36KeuSoqK6l3u7lYfHLNhOonc1hFt7biExXPJueEpwEMaFQTIt75rRms0d8iAvUvubFIMpxq3v0P7NXFb2lAaSuYDg43d/5nFD+auWp7zeWCSowxTJeKBry/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043434; c=relaxed/simple; bh=1QUcsR+BiVPRqwBvfE5+BpO2UKVt8GgqxB8nghPOXWg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BzVtrmuSs7IQmSut6tBPzMn9MffQ+WqMCETN/5ZrqJkmwxAM+M1G2Yu2yiIy083t4AxnFpcfCahk8RXu00qxg+KXh0PvFaN4TD7ag+ORyTOYcNkEkiuk3655jlffGAfUfWpERfa77Ljo8/cjoUicPkrJ3jznS5/Ls3VIIr0vNWA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AcjuZQJp; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AcjuZQJp" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-706a1711ee5so2717714b3a.0; Mon, 15 Jul 2024 04:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721043432; x=1721648232; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b3sefb0CySiaiRrHnR/EzipZicbEpcn9KQcRu1F8eSY=; b=AcjuZQJp2St3RlR1D5WiuOx5V7S3S/F4U0rKTL0IP3cr2cnXLi4IbNHzxjMUM6O/J3 Lh8lnN1xzl3ai5vm5F0C29+kdmSmotgyUyHXYsm3LqNZnoFVUQvvBEddoJ/YMRJZB6mI rZTM/D/ZJ6aQytPqssBa6l3NI8k3VH1TRp9iUPRIft8mYQneS0IBJ5Nj5/3Ay3Qkxdjm jCkdR72ZMohvEYFk3vfj+mKmhj0nAU6kXPdDpcpIjfvVXYCUukpJCycs6MnZzxQreyiF KKn3BHUNW+t2QXQKlvH7+fwzUI3qBpaY3MdyE5Jdi/pQx7YulIJ6YUlaQSSjCgPyWF+c c0WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721043432; x=1721648232; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b3sefb0CySiaiRrHnR/EzipZicbEpcn9KQcRu1F8eSY=; b=rYNopr4bbMzp8ZQbpZtBrQ7RIN4SmslB+0sVOURiIpw22PK//sPiJtWUHNV16lGRDE SINaGVvAmkgErkc8BzA0HR3PXtCQ/pwGGFh3CaUNgQ0VuM0M73tAyiQcAUJMa8Z3eMVP WLdIrEIxce5CidcJFg8ypRKKKAMXyTk0erJIejd3zsxZkvdCKZ+W0wxYIekYjSyvHp4K TNoGo6c3nhclAEEjUkdKBF6Kjk+4XxOGz9ptb0VqjAuvxM13wtQM6pvbEGIK5P2lqZnj 9ZhUbyY29B3eJi4W+GFAFNRFfKt8QX6TptQ7dV06Vzv2TsjqEzyatyRHNUWTAr92tw77 nkOA== X-Forwarded-Encrypted: i=1; AJvYcCV6qt8VDVQud4p2sJiOJoM4JbRpN4eIK7n40XMOx8s3GAJZlzkn+TxuJTuWVUJAvuddif8oHT07bFYQP7ah3CJjizRbYLZesp8JVf6QLoiRKXm4zoOVUwlLkBSayy3OqPzY X-Gm-Message-State: AOJu0Yz0J8AX7DiK1B9xVBwE0hV6mFk/VZdQ3s3LMW30lgt8uAPe9PYm MNVPU0BeGg7683Ra+N/50LX467Nb2HpheHLn/5po17FCiws5pyld X-Google-Smtp-Source: AGHT+IELDSghqsJ5SvzpPtMIsnQUL8zllWJcQtJ6eQ++tSJ+WPlujPq3wziYMh93vzcKE2vkEJKmHQ== X-Received: by 2002:a05:6a21:e89:b0:1c2:922f:379c with SMTP id adf61e73a8af0-1c29822d199mr17708540637.23.1721043431732; Mon, 15 Jul 2024 04:37:11 -0700 (PDT) Received: from localhost ([116.198.225.81]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eb9c90asm4255021b3a.12.2024.07.15.04.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 04:37:11 -0700 (PDT) From: Tao Chen To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , chen.dylane@gmail.com Cc: Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH bpf-next 1/3] bpftool: add net attach/detach command to tcx prog Date: Mon, 15 Jul 2024 19:37:02 +0800 Message-Id: <20240715113704.1279881-2-chen.dylane@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715113704.1279881-1-chen.dylane@gmail.com> References: <20240715113704.1279881-1-chen.dylane@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net X-Patchwork-State: RFC Now, attach/detach tcx prog supported in libbpf, so we can add new command 'bpftool attach/detach tcx' to attach tcx prog with bpftool for user. # bpftool prog load tc_prog.bpf.o /sys/fs/bpf/tc_prog # bpftool prog show ... 192: sched_cls name tc_prog tag 187aeb611ad00cfc gpl loaded_at 2024-07-11T15:58:16+0800 uid 0 xlated 152B jited 97B memlock 4096B map_ids 100,99,97 btf_id 260 # bpftool net attach tcxingress name tc_prog dev lo # bpftool net ... tc: lo(1) tcx/ingress tc_prog prog_id 29 # bpftool net detach tcxingress dev lo # bpftool net ... tc: # bpftool net attach tcxingress name tc_prog dev lo # bpftool net tc: lo(1) tcx/ingress tc_prog prog_id 29 Test environment: ubuntu_22_04, 6.7.0-060700-generic Signed-off-by: Tao Chen --- tools/bpf/bpftool/net.c | 52 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/net.c b/tools/bpf/bpftool/net.c index 968714b4c3d4..be7fd76202f1 100644 --- a/tools/bpf/bpftool/net.c +++ b/tools/bpf/bpftool/net.c @@ -67,6 +67,8 @@ enum net_attach_type { NET_ATTACH_TYPE_XDP_GENERIC, NET_ATTACH_TYPE_XDP_DRIVER, NET_ATTACH_TYPE_XDP_OFFLOAD, + NET_ATTACH_TYPE_TCX_INGRESS, + NET_ATTACH_TYPE_TCX_EGRESS, }; static const char * const attach_type_strings[] = { @@ -74,6 +76,8 @@ static const char * const attach_type_strings[] = { [NET_ATTACH_TYPE_XDP_GENERIC] = "xdpgeneric", [NET_ATTACH_TYPE_XDP_DRIVER] = "xdpdrv", [NET_ATTACH_TYPE_XDP_OFFLOAD] = "xdpoffload", + [NET_ATTACH_TYPE_TCX_INGRESS] = "tcxingress", + [NET_ATTACH_TYPE_TCX_EGRESS] = "tcxegress", }; static const char * const attach_loc_strings[] = { @@ -647,6 +651,32 @@ static int do_attach_detach_xdp(int progfd, enum net_attach_type attach_type, return bpf_xdp_attach(ifindex, progfd, flags, NULL); } +static int get_tcx_type(enum net_attach_type attach_type) +{ + int type = 0; + + if (attach_type == NET_ATTACH_TYPE_TCX_INGRESS) + type |= BPF_TCX_INGRESS; + else if (attach_type == NET_ATTACH_TYPE_TCX_EGRESS) + type |= BPF_TCX_EGRESS; + + return type; +} + +static int do_attach_tcx(int progfd, enum net_attach_type attach_type, int ifindex) +{ + int type = get_tcx_type(attach_type); + + return bpf_prog_attach(progfd, ifindex, type, 0); +} + +static int do_detach_tcx(int targetfd, enum net_attach_type attach_type) +{ + int type = get_tcx_type(attach_type); + + return bpf_prog_detach(targetfd, type); +} + static int do_attach(int argc, char **argv) { enum net_attach_type attach_type; @@ -694,6 +724,15 @@ static int do_attach(int argc, char **argv) goto cleanup; } + /* attach tcx prog */ + if (is_prefix("tcx", attach_type_strings[attach_type])) + err = do_attach_tcx(progfd, attach_type, ifindex); + if (err) { + p_err("interface %s attach failed: %s", + attach_type_strings[attach_type], strerror(-err)); + goto cleanup; + } + if (json_output) jsonw_null(json_wtr); cleanup: @@ -732,6 +771,16 @@ static int do_detach(int argc, char **argv) return err; } + /* detach tcx prog */ + if (is_prefix("tcx", attach_type_strings[attach_type])) + err = do_detach_tcx(ifindex, attach_type); + + if (err < 0) { + p_err("interface %s detach failed: %s", + attach_type_strings[attach_type], strerror(-err)); + return err; + } + if (json_output) jsonw_null(json_wtr); @@ -928,7 +977,8 @@ static int do_help(int argc, char **argv) " %1$s %2$s help\n" "\n" " " HELP_SPEC_PROGRAM "\n" - " ATTACH_TYPE := { xdp | xdpgeneric | xdpdrv | xdpoffload }\n" + " ATTACH_TYPE := { xdp | xdpgeneric | xdpdrv | xdpoffload | tcxingress\n" + " | tcxegress}\n" " " HELP_SPEC_OPTIONS " }\n" "\n" "Note: Only xdp, tcx, tc, netkit, flow_dissector and netfilter attachments\n" From patchwork Mon Jul 15 11:37:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Chen X-Patchwork-Id: 13733349 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E738F18A950; Mon, 15 Jul 2024 11:37:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043437; cv=none; b=ptYAWXe4nX9WdnxTmvRYT+ZABllFYLkwBcX91ML1yvGXoREnJEKeZZLMTz4zc3Hwr8j6AMKy+9G2tip7hTsZGnNACLSvNH1J/frZUj6x9OBdsZ04xkXp76c3o2c0FEMcJx0SfUDj47ln1zue+kNrs3FFXSmRmd4MTAD9lENAalc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043437; c=relaxed/simple; bh=0JaMcVnEOEmHiFY49Jn8DUJcyME5czNW/5v7BXTp6F4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uk/J4LzOm7JtpTRfLW4m3ppbIBeKshXGnLfiL/Gib4bZPqtMRNlyErnUQ1w1pTH0uY8V0RsVPSEj76GujL8G+GE8HAtLGBgTVtMAGVDXIjOkkjirXctwNMpLDNCyuuRC81dYRo392eKMEwmQR9dtzheMlR0jv5ejXodjfrT29I8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Oa06z1Gl; arc=none smtp.client-ip=209.85.210.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Oa06z1Gl" Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-70211abf4cbso2842401a34.3; Mon, 15 Jul 2024 04:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721043435; x=1721648235; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YejqhzX9tzWecGEm0cvrvR+36trbcw8YNU0ydMs30LI=; b=Oa06z1GlpwKWC6eIMPZfzhgj85cJ3CXC8U6fwJZLf0rnZpp0csc1PSTcoGNLufzHCf RMEqQ/Ct9Mi9KcPjJskam7KT2VkGRxZc5/+2lQoySEdPetzfRsyL6gX15x6KrAz4xkEK g82gf9FInsCOulsP74sbUXoNWaJ29wX1CxKwoiQwqpLS1fxAgAkih2bZtqfpQSQsKOpr JCBiELCeNN2XZarHeS03fm8maPpTEKUv/uu8GRtmaEKjgF+MM2OWMHhyP1wbG/TPfLYD UcFosjOyU3jZkc8dPGVFsoJVlBLG2KgRqzpPsJIeiozkjfrld0WlXob9CTw2V49TUxzb EMyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721043435; x=1721648235; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YejqhzX9tzWecGEm0cvrvR+36trbcw8YNU0ydMs30LI=; b=qUjlUQMwRTSXNhyY0xupOFIUi3fKhD8OiqozRoHYwto5UU8ralyFkkj8+bxUam7Inm jL+a70iLS+xhR/pBAaNu25FFNLIRSTVtMaNe/4L1D1AO2cQdSeqX+Q/FDvTwIyXw8tIZ Ife2aQncUCHvk6/Iq4EtQE9pTRG5HrKAVXDQhmIYsEUchVICUc0u9WCyKuL8KQVJWJRC lFBj5eV/zyhS0spotPFAbo7rneD/hs1xVlBNYh9IdrMurTLbwbNt0A4yhvVHZ+/ZpF/U y3IS8huEel7wkIwDcHMOV9Pi3fAKm7HdPV2h1WR4+GZNxozvNML732DBLGPEKBePATN/ s9SQ== X-Forwarded-Encrypted: i=1; AJvYcCWllYJz1DfpMVbTi5kF2dr6qsIuMOOTB5pErs7TCv8EjdS+EL+DGWWpdbShuV3/Hg+rRKBZO3lYKaqT0UZuE/WAiB7qsfTtx2okFcjzpt9Y+rtQJGQuTYG17hawsav8DrFh X-Gm-Message-State: AOJu0Yx0AJAsayWwe40tMfm+yNkEvx7O1dATxcJXJsGzH9nSdSV2kqMD H0q6YCjjTBK567NFsOKEqfg0FSES8V9edlVKk0nL/k4EEkfuzKTp X-Google-Smtp-Source: AGHT+IEEk7/Npdq+bj9g/pqupEE42derNFNWaU06IKt90ve7xkaGH9H+0Q1Hi1wIineERynZREfaTg== X-Received: by 2002:a05:6870:ac28:b0:24f:d12a:5f1c with SMTP id 586e51a60fabf-25eaec3ea3fmr16212761fac.53.1721043434779; Mon, 15 Jul 2024 04:37:14 -0700 (PDT) Received: from localhost ([116.198.225.81]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eb9c93asm4118303b3a.1.2024.07.15.04.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 04:37:14 -0700 (PDT) From: Tao Chen To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , chen.dylane@gmail.com Cc: Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH bpf-next 2/3] bpftool: add bash-completion for tcx subcommand Date: Mon, 15 Jul 2024 19:37:03 +0800 Message-Id: <20240715113704.1279881-3-chen.dylane@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715113704.1279881-1-chen.dylane@gmail.com> References: <20240715113704.1279881-1-chen.dylane@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net X-Patchwork-State: RFC This commit adds bash-completion for attaching tcx program on interface. Signed-off-by: Tao Chen --- tools/bpf/bpftool/bash-completion/bpftool | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool index be99d49b8714..eb36f5305945 100644 --- a/tools/bpf/bpftool/bash-completion/bpftool +++ b/tools/bpf/bpftool/bash-completion/bpftool @@ -1079,7 +1079,7 @@ _bpftool() esac ;; net) - local ATTACH_TYPES='xdp xdpgeneric xdpdrv xdpoffload' + local ATTACH_TYPES='xdp xdpgeneric xdpdrv xdpoffload tcxingress tcxegress' case $command in show|list) [[ $prev != "$command" ]] && return 0 From patchwork Mon Jul 15 11:37:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Chen X-Patchwork-Id: 13733350 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2294018C16F; Mon, 15 Jul 2024 11:37:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043440; cv=none; b=S362yTkKHz6+OyLHhx9fNnewnVu7MMlyaDH3dInPsQSVtpeWjU7llxginWCCwfZHZKvAp1+dLZ5uP46dFzLBksBeG9tL9LejD3c8jBflY6JE7FWzvrDJJzEKOhXmdcHXLeO2O75VsJkDIYtmGy+7Elr5GE0J5d/EnKRDa0UYGTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043440; c=relaxed/simple; bh=o/a/Ba7rsdITDgqm6HVWWmOT55dq8eAXkBjCNAe4fRY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WoXOnANGrGVZwmpfuhIn0CY1+QKtFK4b6kH0f47iqX6/TVjHiaBKdjs8FPh9CxMJqopZmJNxiuyjITohEve4KNFjJZSf9v5kVvw222hOT2fOFwQDflFP+QNA7T1h9scqkMj+/63+uLNUHaV0nrbeOR2lHwSG3+g/l6Ggf6bAQYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S8IP+JyD; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S8IP+JyD" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7669d62b5bfso2392027a12.1; Mon, 15 Jul 2024 04:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721043438; x=1721648238; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lONwT0616zEWl9r58neBroQQGwP8PqCEA9oNIHLUavQ=; b=S8IP+JyDL15WoycWGivoQLqyOq0veM03pkWf1hT80nNs4xOcRHiZgW5Df9cBJC3BiY 19rFhOAdQpBeMAT/b3hfh5Mh7yah30Mdcsrk3IDJOAy5gmzqCjsynzSv19tGl7l5zz/j HFlvodLWw6mN+KOZm6xQu2JEv2ja1UGXjGqZJkQc0oTtPorXFNR8L1NcpT7YtNnMkaJa 4pzlY9u96aqZ5+vFGX1I6Y0IWB2tProet0eb7PYo43Gvh+59CQN9CYafn7j7OSjE9LH9 LFHS9A7Mp0LJwymu2koLW0Y96W6bNNjeX1DPbGvlH6z1nhtnbioXy0ngnWJ7cZ1h+Qy4 q0IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721043438; x=1721648238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lONwT0616zEWl9r58neBroQQGwP8PqCEA9oNIHLUavQ=; b=Ll8RZQQZ5pTlbXjEzlr+Kj74CqX/6Gp0UPdul+Sqo+ZLcVKIgJ0ww5VW4M76Ai3e3t 1OMym6L/Ks2DfzUYiMNT9hi1qijFDg9L8O1F9sAhA497Son9aS0IAdk5BNO38TjccX3e 5nJqI8fzhfzqvneszTTEDcJpREvnuayITiYtwzusRxpyBNAGrKUjx+0NKJeRPoYsP4hA 3eXC5DoppHttrqgREd0USQElmgZwEnlQ8bv4VmSLBW5kZUH2Jk6mQjRtjmgN4YOpkgIo kk1AuPCNloaPMxAJq+R7wtKk8K6PU2TOE2komdRn/b9IWxBXDaVLp6Hg7YNHYIa8+OTJ Ro7g== X-Forwarded-Encrypted: i=1; AJvYcCX1gIfixh+DzUu+yu2sC85TQCZtkYzJpVQFD9W6tdf6on/W24IxQ7qGpTydahL3nJaOIDdlhlK/M/27b5YYPt06+3ghOF8+6AUzGHKpkq16Tc8MNWU5P7Jf1BbK4/qxEMqB X-Gm-Message-State: AOJu0YxK1XiHEeQRhEyRX6skx5KH99KEvT+sFp3eBUx6cqVVBjVQg0bo Syhpcm8muVDIDYlBLUaQ4CLSKs7UPqh1IVerEfkMyPt6jYA8vt3ILubgz2EgE+U= X-Google-Smtp-Source: AGHT+IH1+D8DGIRAl5UGSJFZW8yfU32kY9CstdGZGksq3G5+Uhc9zJoAgHARABp5lIDmfm0RAxodEg== X-Received: by 2002:a05:6a20:9191:b0:1bd:207a:da31 with SMTP id adf61e73a8af0-1c2982285femr19750597637.23.1721043438069; Mon, 15 Jul 2024 04:37:18 -0700 (PDT) Received: from localhost ([116.198.225.81]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fc0bc5f7c0sm38877995ad.307.2024.07.15.04.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 04:37:17 -0700 (PDT) From: Tao Chen To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , chen.dylane@gmail.com Cc: Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH bpf-next 3/3] bpftool: add document for net attach/detach on tcx subcommand Date: Mon, 15 Jul 2024 19:37:04 +0800 Message-Id: <20240715113704.1279881-4-chen.dylane@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715113704.1279881-1-chen.dylane@gmail.com> References: <20240715113704.1279881-1-chen.dylane@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net X-Patchwork-State: RFC This commit adds sample output for net attach/detach on tcx subcommand. Signed-off-by: Tao Chen --- .../bpf/bpftool/Documentation/bpftool-net.rst | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/Documentation/bpftool-net.rst b/tools/bpf/bpftool/Documentation/bpftool-net.rst index 348812881297..64de7a33f176 100644 --- a/tools/bpf/bpftool/Documentation/bpftool-net.rst +++ b/tools/bpf/bpftool/Documentation/bpftool-net.rst @@ -29,7 +29,7 @@ NET COMMANDS | **bpftool** **net help** | | *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* | **name** *PROG_NAME* } -| *ATTACH_TYPE* := { **xdp** | **xdpgeneric** | **xdpdrv** | **xdpoffload** } +| *ATTACH_TYPE* := { **xdp** | **xdpgeneric** | **xdpdrv** | **xdpoffload** | **tcxingress** | **tcxegress** } DESCRIPTION =========== @@ -69,6 +69,8 @@ bpftool net attach *ATTACH_TYPE* *PROG* dev *NAME* [ overwrite ] **xdpgeneric** - Generic XDP. runs at generic XDP hook when packet already enters receive path as skb; **xdpdrv** - Native XDP. runs earliest point in driver's receive path; **xdpoffload** - Offload XDP. runs directly on NIC on each packet reception; + **tcxingress** - Ingress TC. runs on ingress net traffic; + **tcxegress** - Egress TC. runs on egress net traffic; bpftool net detach *ATTACH_TYPE* dev *NAME* Detach bpf program attached to network interface *NAME* with type specified @@ -178,3 +180,21 @@ EXAMPLES :: xdp: + +| +| **# bpf net attach tcxingress name tc_prog dev lo** +| **# bpf net** +| + +:: + tc: + lo(1) tcx/ingress tc_prog prog_id 29 + +| +| **# bpf net attach tcxingress name tc_prog dev lo** +| **# bpf net detach tcxingress dev lo** +| **# bpf net** +| + +:: + tc: