[PATCH 2/4] bpf: update BPF constants

Paul Chaignon paul.chaignon at gmail.com
Sun Feb 23 10:13:13 UTC 2020


* xlat/bpf_attach_flags.in (BPF_F_REPLACE): New constant introduced in
Linux commit v5.6-rc1~151^2~199^2~7^2~3.
* xlat/bpf_map_types.in (BPF_MAP_TYPE_STRUCT_OPS): New constant
introduced in Linux commit v5.6-rc1~151^2~46^2~37^2~5.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_STRUCT_OPS): New constant
introduced in Linux commit v5.6-rc1~151^2~46^2~37^2~6.
(BPF_PROG_TYPE_EXT): New constant introduced in Linux commit
v5.6-rc1~151^2~46^2~1^2~2.
* NEWS: Mention this.
* tests/bpf.c (BPF_MAP_CREATE_checks, BPF_PROG_LOAD_checks,
BPF_PROG8QUERY_checks): Update expected outputs.
* tests/kernel_version.c (print_bpf_attr, main): Likewise.

Signed-off-by: Paul Chaignon <paul.chaignon at gmail.com>
---
 NEWS                     |  1 +
 tests/bpf.c              | 24 ++++++++++++------------
 tests/kernel_version.c   |  6 +++---
 xlat/bpf_attach_flags.in |  5 +++--
 xlat/bpf_map_types.in    |  1 +
 xlat/bpf_prog_types.in   |  2 ++
 6 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/NEWS b/NEWS
index 1a4dbdda..c54b97e0 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Noteworthy changes in release ?.? (????-??-??)
 
 * Improvements
   * Enhanced decoding of BPF_MAP_CREATE bpf syscall command.
+  * Updated lists of BPF_* constants.
 
 * Bug fixes
   * Fixed build on csky abiv1 architecture.
diff --git a/tests/bpf.c b/tests/bpf.c
index a462d008..2e4894a3 100644
--- a/tests/bpf.c
+++ b/tests/bpf.c
@@ -286,7 +286,7 @@ static struct bpf_attr_check BPF_MAP_CREATE_checks[] = {
 	},
 	{ /* 2 */
 		.data = { .BPF_MAP_CREATE_data = {
-			.map_type = 26,
+			.map_type = 27,
 			.key_size = 0xface1e55,
 			.value_size = 0xbadc0ded,
 			.max_entries = 0xbeefcafe,
@@ -297,7 +297,7 @@ static struct bpf_attr_check BPF_MAP_CREATE_checks[] = {
 			.map_ifindex = 3141592653,
 		} },
 		.size = offsetofend(struct BPF_MAP_CREATE_struct, map_ifindex),
-		.str = "map_type=0x1a /* BPF_MAP_TYPE_??? */"
+		.str = "map_type=0x1b /* BPF_MAP_TYPE_??? */"
 		       ", key_size=4207812181, value_size=3134983661"
 		       ", max_entries=3203386110"
 		       ", map_flags=0xfffff800 /* BPF_F_??? */"
@@ -612,7 +612,7 @@ print_BPF_PROG_LOAD_attr4(const struct bpf_attr_check *check, unsigned long addr
 	       license, IFINDEX_LO_STR);
 }
 
-static_assert(ARRAY_SIZE(bpf_prog_types_xdata) == 27,
+static_assert(ARRAY_SIZE(bpf_prog_types_xdata) == 29,
 	      "The prog_type for test 5 below needs to be updated");
 static struct bpf_attr_check BPF_PROG_LOAD_checks[] = {
 	{
@@ -623,7 +623,7 @@ static struct bpf_attr_check BPF_PROG_LOAD_checks[] = {
 	},
 	{ /* 1 */
 		.data = { .BPF_PROG_LOAD_data = {
-			.prog_type = 27,
+			.prog_type = 29,
 			.insn_cnt = 0xbadc0ded,
 			.insns = 0,
 			.license = 0,
@@ -634,7 +634,7 @@ static struct bpf_attr_check BPF_PROG_LOAD_checks[] = {
 			.prog_flags = 0,
 		} },
 		.size = offsetofend(struct BPF_PROG_LOAD_struct, prog_flags),
-		.str = "prog_type=0x1b /* BPF_PROG_TYPE_??? */"
+		.str = "prog_type=0x1d /* BPF_PROG_TYPE_??? */"
 		       ", insn_cnt=3134983661, insns=NULL, license=NULL"
 		       ", log_level=42, log_size=3141592653, log_buf=NULL"
 		       ", kern_version=KERNEL_VERSION(51966, 240, 13)"
@@ -697,7 +697,7 @@ static struct bpf_attr_check BPF_PROG_LOAD_checks[] = {
 	},
 	{ /* 5 */
 		.data = { .BPF_PROG_LOAD_data = {
-			.prog_type = 26,
+			.prog_type = 28,
 			.insn_cnt = 0xbadc0ded,
 			.insns = 0xffffffff00000000,
 			.license = 0xffffffff00000000,
@@ -709,7 +709,7 @@ static struct bpf_attr_check BPF_PROG_LOAD_checks[] = {
 			.prog_name = "fedcba987654321",
 		} },
 		.size = offsetofend(struct BPF_PROG_LOAD_struct, prog_name),
-		.str = "prog_type=BPF_PROG_TYPE_TRACING"
+		.str = "prog_type=BPF_PROG_TYPE_EXT"
 		       ", insn_cnt=3134983661"
 		       ", insns=" BIG_ADDR("0xffffffff00000000", "NULL")
 		       ", license=" BIG_ADDR("0xffffffff00000000", "NULL")
@@ -1034,7 +1034,7 @@ print_BPF_PROG_QUERY_attr4(const struct bpf_attr_check *check, unsigned long add
 	printf("query={target_fd=-1153374643"
 	       ", attach_type=0xfeedface /* BPF_??? */"
 	       ", query_flags=BPF_F_QUERY_EFFECTIVE|0xdeadf00c"
-	       ", attach_flags=BPF_F_ALLOW_MULTI|0xbeefcafc"
+	       ", attach_flags=BPF_F_ALLOW_MULTI|BPF_F_REPLACE|0xbeefcaf8"
 #if defined(INJECT_RETVAL)
 	       ", prog_ids=[0, 1, 4294967295, 2718281828], prog_cnt=4}"
 #else
@@ -1062,7 +1062,7 @@ print_BPF_PROG_QUERY_attr5(const struct bpf_attr_check *check, unsigned long add
 	printf("query={target_fd=-1153374643"
 	       ", attach_type=0xfeedface /* BPF_??? */"
 	       ", query_flags=BPF_F_QUERY_EFFECTIVE|0xdeadf00c"
-	       ", attach_flags=BPF_F_ALLOW_MULTI|0xbeefcafc"
+	       ", attach_flags=BPF_F_ALLOW_MULTI|BPF_F_REPLACE|0xbeefcaf8"
 #if defined(INJECT_RETVAL)
 	       ", prog_ids=[0, 1, 4294967295, 2718281828, ... /* %p */]"
 	       ", prog_cnt=5}",
@@ -1100,7 +1100,7 @@ static struct bpf_attr_check BPF_PROG_QUERY_checks[] = {
 			.target_fd = 3141592653U,
 			.attach_type = 26,
 			.query_flags = 0xfffffffe,
-			.attach_flags = 0xfffffffc,
+			.attach_flags = 0xfffffff8,
 			.prog_ids = 0xffffffffffffffffULL,
 			.prog_cnt = 2718281828,
 		} },
@@ -1108,7 +1108,7 @@ static struct bpf_attr_check BPF_PROG_QUERY_checks[] = {
 		.str = "query={target_fd=-1153374643"
 		       ", attach_type=0x1a /* BPF_??? */"
 		       ", query_flags=0xfffffffe /* BPF_F_QUERY_??? */"
-		       ", attach_flags=0xfffffffc /* BPF_F_??? */"
+		       ", attach_flags=0xfffffff8 /* BPF_F_??? */"
 		       ", prog_ids="
 		       BIG_ADDR("0xffffffffffffffff", "0xffffffff")
 		       ", prog_cnt=2718281828}",
@@ -1126,7 +1126,7 @@ static struct bpf_attr_check BPF_PROG_QUERY_checks[] = {
 		.str = "query={target_fd=-1153374643"
 		       ", attach_type=0xfeedface /* BPF_??? */"
 		       ", query_flags=BPF_F_QUERY_EFFECTIVE|0xdeadf00c"
-		       ", attach_flags=BPF_F_ALLOW_MULTI|0xbeefcafc"
+		       ", attach_flags=BPF_F_ALLOW_MULTI|BPF_F_REPLACE|0xbeefcaf8"
 		       ", prog_ids=" BIG_ADDR_MAYBE("0xffffffffffffffff") "[]"
 		       ", prog_cnt=0}",
 	},
diff --git a/tests/kernel_version.c b/tests/kernel_version.c
index a667b584..025e9733 100644
--- a/tests/kernel_version.c
+++ b/tests/kernel_version.c
@@ -34,9 +34,9 @@ static void
 print_bpf_attr(void)
 {
 #if XLAT_RAW
-	printf("{prog_type=0x1b"
+	printf("{prog_type=0x1d"
 #else
-	printf("{prog_type=0x1b /* BPF_PROG_TYPE_??? */"
+	printf("{prog_type=0x1d /* BPF_PROG_TYPE_??? */"
 #endif
 		", insn_cnt=3134983661"
 		", insns=NULL"
@@ -79,7 +79,7 @@ main(void)
 {
 	long ret;
 	struct BPF_PROG_LOAD_struct prog = {
-		.prog_type = 27,
+		.prog_type = 29,
 		.insn_cnt = 0xbadc0ded,
 		.insns = 0,
 		.license = 0,
diff --git a/xlat/bpf_attach_flags.in b/xlat/bpf_attach_flags.in
index a67c02b6..cee8d191 100644
--- a/xlat/bpf_attach_flags.in
+++ b/xlat/bpf_attach_flags.in
@@ -1,2 +1,3 @@
-BPF_F_ALLOW_OVERRIDE	1
-BPF_F_ALLOW_MULTI	2
+BPF_F_ALLOW_OVERRIDE	1U
+BPF_F_ALLOW_MULTI	(1U << 1)
+BPF_F_REPLACE		(1U << 2)
diff --git a/xlat/bpf_map_types.in b/xlat/bpf_map_types.in
index 0b3519c9..3aa61d3d 100644
--- a/xlat/bpf_map_types.in
+++ b/xlat/bpf_map_types.in
@@ -25,3 +25,4 @@ BPF_MAP_TYPE_QUEUE 22
 BPF_MAP_TYPE_STACK 23
 BPF_MAP_TYPE_SK_STORAGE 24
 BPF_MAP_TYPE_DEVMAP_HASH 25
+BPF_MAP_TYPE_STRUCT_OPS 26
diff --git a/xlat/bpf_prog_types.in b/xlat/bpf_prog_types.in
index 97d99081..e572311e 100644
--- a/xlat/bpf_prog_types.in
+++ b/xlat/bpf_prog_types.in
@@ -26,3 +26,5 @@ BPF_PROG_TYPE_CGROUP_SYSCTL 23
 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE 24
 BPF_PROG_TYPE_CGROUP_SOCKOPT 25
 BPF_PROG_TYPE_TRACING 26
+BPF_PROG_TYPE_STRUCT_OPS 27
+BPF_PROG_TYPE_EXT 28
-- 
2.20.1



More information about the Strace-devel mailing list