From: Yafang Shao <laoar.shao@gmail.com>
To: roman.gushchin@linux.dev, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, kafai@fb.com, songliubraving@fb.com,
yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org,
shuah@kernel.org
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH 08/14] bpf: Aggregate flags for BPF_PROG_LOAD command
Date: Sat, 19 Mar 2022 17:30:30 +0000 [thread overview]
Message-ID: <20220319173036.23352-9-laoar.shao@gmail.com> (raw)
In-Reply-To: <20220319173036.23352-1-laoar.shao@gmail.com>
It will be easy to read if we aggregate the flags for BPF_PROG_LOAD into
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
include/uapi/linux/bpf.h | 15 +++++++++------
tools/include/uapi/linux/bpf.h | 15 +++++++++------
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index e2dba6cdd88d..93ee04fb8c62 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -1065,12 +1065,14 @@ enum bpf_link_type {
#define BPF_F_ALLOW_MULTI (1U << 1)
#define BPF_F_REPLACE (1U << 2)
+/* flags for BPF_PROG_LOAD command */
+enum {
/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the
* verifier will perform strict alignment checking as if the kernel
* has been built with CONFIG_EFFICIENT_UNALIGNED_ACCESS not set,
* and NET_IP_ALIGN defined to 2.
*/
-#define BPF_F_STRICT_ALIGNMENT (1U << 0)
+ BPF_F_STRICT_ALIGNMENT = (1U << 0),
/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the
* verifier will allow any alignment whatsoever. On platforms
@@ -1084,7 +1086,7 @@ enum bpf_link_type {
* of an unaligned access the alignment check would trigger before
* the one we are interested in.
*/
-#define BPF_F_ANY_ALIGNMENT (1U << 1)
+ BPF_F_ANY_ALIGNMENT = (1U << 1),
/* BPF_F_TEST_RND_HI32 is used in BPF_PROG_LOAD command for testing purpose.
* Verifier does sub-register def/use analysis and identifies instructions whose
@@ -1102,10 +1104,10 @@ enum bpf_link_type {
* Then, if verifier is not doing correct analysis, such randomization will
* regress tests to expose bugs.
*/
-#define BPF_F_TEST_RND_HI32 (1U << 2)
+ BPF_F_TEST_RND_HI32 = (1U << 2),
/* The verifier internal test flag. Behavior is undefined */
-#define BPF_F_TEST_STATE_FREQ (1U << 3)
+ BPF_F_TEST_STATE_FREQ = (1U << 3),
/* If BPF_F_SLEEPABLE is used in BPF_PROG_LOAD command, the verifier will
* restrict map and helper usage for such programs. Sleepable BPF programs can
@@ -1113,12 +1115,13 @@ enum bpf_link_type {
* Such programs are allowed to use helpers that may sleep like
* bpf_copy_from_user().
*/
-#define BPF_F_SLEEPABLE (1U << 4)
+ BPF_F_SLEEPABLE = (1U << 4),
/* If BPF_F_XDP_HAS_FRAGS is used in BPF_PROG_LOAD command, the loaded program
* fully support xdp frags.
*/
-#define BPF_F_XDP_HAS_FRAGS (1U << 5)
+ BPF_F_XDP_HAS_FRAGS = (1U << 5),
+};
/* link_create.kprobe_multi.flags used in LINK_CREATE command for
* BPF_TRACE_KPROBE_MULTI attach type to create return probe.
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index e2dba6cdd88d..71a4d8fdc880 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -1065,12 +1065,14 @@ enum bpf_link_type {
#define BPF_F_ALLOW_MULTI (1U << 1)
#define BPF_F_REPLACE (1U << 2)
+/* flags for BPF_PROG_LOAD */
+enum {
/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the
* verifier will perform strict alignment checking as if the kernel
* has been built with CONFIG_EFFICIENT_UNALIGNED_ACCESS not set,
* and NET_IP_ALIGN defined to 2.
*/
-#define BPF_F_STRICT_ALIGNMENT (1U << 0)
+ BPF_F_STRICT_ALIGNMENT = (1U << 0),
/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the
* verifier will allow any alignment whatsoever. On platforms
@@ -1084,7 +1086,7 @@ enum bpf_link_type {
* of an unaligned access the alignment check would trigger before
* the one we are interested in.
*/
-#define BPF_F_ANY_ALIGNMENT (1U << 1)
+ BPF_F_ANY_ALIGNMENT = (1U << 1),
/* BPF_F_TEST_RND_HI32 is used in BPF_PROG_LOAD command for testing purpose.
* Verifier does sub-register def/use analysis and identifies instructions whose
@@ -1102,10 +1104,10 @@ enum bpf_link_type {
* Then, if verifier is not doing correct analysis, such randomization will
* regress tests to expose bugs.
*/
-#define BPF_F_TEST_RND_HI32 (1U << 2)
+ BPF_F_TEST_RND_HI32 = (1U << 2),
/* The verifier internal test flag. Behavior is undefined */
-#define BPF_F_TEST_STATE_FREQ (1U << 3)
+ BPF_F_TEST_STATE_FREQ = (1U << 3),
/* If BPF_F_SLEEPABLE is used in BPF_PROG_LOAD command, the verifier will
* restrict map and helper usage for such programs. Sleepable BPF programs can
@@ -1113,12 +1115,13 @@ enum bpf_link_type {
* Such programs are allowed to use helpers that may sleep like
* bpf_copy_from_user().
*/
-#define BPF_F_SLEEPABLE (1U << 4)
+ BPF_F_SLEEPABLE = (1U << 4),
/* If BPF_F_XDP_HAS_FRAGS is used in BPF_PROG_LOAD command, the loaded program
* fully support xdp frags.
*/
-#define BPF_F_XDP_HAS_FRAGS (1U << 5)
+ BPF_F_XDP_HAS_FRAGS = (1U << 5),
+};
/* link_create.kprobe_multi.flags used in LINK_CREATE command for
* BPF_TRACE_KPROBE_MULTI attach type to create return probe.
--
2.17.1
next prev parent reply other threads:[~2022-03-19 17:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-19 17:30 [PATCH 00/14] bpf: Allow not to charge bpf memory Yafang Shao
2022-03-19 17:30 ` [PATCH 01/14] bpf: Introduce no charge flag for bpf map Yafang Shao
2022-03-19 17:30 ` [PATCH 02/14] bpf: Only sys admin can set no charge flag Yafang Shao
2022-03-19 17:30 ` [PATCH 03/14] bpf: Enable no charge in map _CREATE_FLAG_MASK Yafang Shao
2022-03-19 17:30 ` [PATCH 04/14] bpf: Introduce new parameter bpf_attr in bpf_map_area_alloc Yafang Shao
2022-03-19 17:30 ` [PATCH 05/14] bpf: Allow no charge " Yafang Shao
2022-03-19 17:30 ` [PATCH 06/14] bpf: Allow no charge for allocation not at map creation time Yafang Shao
2022-03-19 17:30 ` [PATCH 07/14] bpf: Allow no charge in map specific allocation Yafang Shao
2022-03-19 17:30 ` Yafang Shao [this message]
2022-03-19 17:30 ` [PATCH 09/14] bpf: Add no charge flag for bpf prog Yafang Shao
2022-03-19 17:30 ` [PATCH 10/14] bpf: Only sys admin can set " Yafang Shao
2022-03-19 17:30 ` [PATCH 11/14] bpf: Set __GFP_ACCOUNT at the callsite of bpf_prog_alloc Yafang Shao
2022-03-19 17:30 ` [PATCH 12/14] bpf: Allow no charge for bpf prog Yafang Shao
2022-03-19 17:30 ` [PATCH 13/14] bpf: selftests: Add test case for BPF_F_NO_CHARTE Yafang Shao
2022-03-19 17:30 ` [PATCH 14/14] bpf: selftests: Add test case for BPF_F_PROG_NO_CHARGE Yafang Shao
2022-03-21 22:52 ` [PATCH 00/14] bpf: Allow not to charge bpf memory Roman Gushchin
2022-03-22 16:10 ` Yafang Shao
2022-03-22 19:10 ` Roman Gushchin
2022-03-23 1:37 ` Yafang Shao
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=20220319173036.23352-9-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=shuah@kernel.org \
--cc=songliubraving@fb.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