Skip to contentSkip to conversation

bpf: Add missing header to the library

PATCH Superseded Mickaël Salaün 3 participants 17 messages Feb 5, 2017 – Feb 6, 2017

Subsystems (6)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 bpf: Add missing header to the library

Including stddef.h is needed to define size_t.

Cc Alexei Starovoitov <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Wang Nan <[email protected]>
---
 tools/lib/bpf/bpf.h | 1 +
 1 file changed, 1 insertion(+)
tools/lib/bpf/bpf.h +1 -0
index a2f9853dd882..df6e186da788 100644
@@ -22,6 +22,7 @@
 #define __BPF_BPF_H
 
 #include <linux/bpf.h>
+#include <stddef.h>
 
 int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
 		   int max_entries, __u32 map_flags);
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/7 samples/bpf: Ignore already processed ELF sections

Add a missing check for the map fixup loop.

Cc Alexei Starovoitov <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Daniel Borkmann <[email protected]>
---
 samples/bpf/bpf_load.c | 2 ++
 1 file changed, 2 insertions(+)
samples/bpf/bpf_load.c +2 -0
index 396e204888b3..e04fe09d7c2e 100644
@@ -328,6 +328,8 @@ int load_bpf_file(char *path)
 
 	/* load programs that need map fixup (relocations) */
 	for (i = 1; i < ehdr.e_shnum; i++) {
+		if (processed_sec[i])
+			continue;
 
 		if (get_sec(elf, i, &ehdr, &shname, &shdr, &data))
 			continue;
Signature · 1 line
2.11.0
#2 lore raw

PATCH 3/7 samples/bpf: Reset global variables

In reply to Mickaël Salaün

Before loading a new ELF, clean previous kernel version, license and processed sections.

Cc Alexei Starovoitov <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc David S. Miller <[email protected]>
---
 samples/bpf/bpf_load.c | 5 +++++
 1 file changed, 5 insertions(+)
samples/bpf/bpf_load.c +5 -0
index e04fe09d7c2e..b86ee54da2d1 100644
@@ -277,6 +277,11 @@ int load_bpf_file(char *path)
 	Elf_Data *data, *data_prog, *symbols = NULL;
 	char *shname, *shname_prog;
 
+	/* reset global variables */
+	kern_version = 0;
+	memset(license, 0, sizeof(license));
+	memset(processed_sec, 0, sizeof(processed_sec));
+
 	if (elf_version(EV_CURRENT) == EV_NONE)
 		return 1;
 
Signature · 1 line
2.11.0
#3 lore raw

PATCH 4/7 tools: Sync {,tools/}include/uapi/linux/bpf.h

In reply to Mickaël Salaün

The tools version of this header is out of date; update it to the latest version from kernel header.

Cc Alexei Starovoitov <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc David S. Miller <[email protected]>
---
 tools/include/uapi/linux/bpf.h | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
tools/include/uapi/linux/bpf.h +22 -1
index 0eb0e87dbe9f..e07fd5a324e6 100644
@@ -63,6 +63,12 @@ struct bpf_insn {
 	__s32	imm;		/* signed immediate constant */
 };
 
+/* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
+struct bpf_lpm_trie_key {
+	__u32	prefixlen;	/* up to 32 for AF_INET, 128 for AF_INET6 */
+	__u8	data[0];	/* Arbitrary size */
+};
+
 /* BPF syscall commands, see bpf(2) man-page for details. */
 enum bpf_cmd {
 	BPF_MAP_CREATE,
@@ -89,6 +95,7 @@ enum bpf_map_type {
 	BPF_MAP_TYPE_CGROUP_ARRAY,
 	BPF_MAP_TYPE_LRU_HASH,
 	BPF_MAP_TYPE_LRU_PERCPU_HASH,
+	BPF_MAP_TYPE_LPM_TRIE,
 };
 
 enum bpf_prog_type {
@@ -430,6 +437,18 @@ union bpf_attr {
  *     @xdp_md: pointer to xdp_md
  *     @delta: An positive/negative integer to be added to xdp_md.data
  *     Return: 0 on success or negative on error
+ *
+ * int bpf_probe_read_str(void *dst, int size, const void *unsafe_ptr)
+ *     Copy a NUL terminated string from unsafe address. In case the string
+ *     length is smaller than size, the target is not padded with further NUL
+ *     bytes. In case the string length is larger than size, just count-1
+ *     bytes are copied and the last byte is set to NUL.
+ *     @dst: destination address
+ *     @size: maximum number of bytes to copy, including the trailing NUL
+ *     @unsafe_ptr: unsafe address
+ *     Return:
+ *       > 0 length of the string including the trailing NUL on success
+ *       < 0 error
  */
 #define __BPF_FUNC_MAPPER(FN)		\
 	FN(unspec),			\
@@ -476,7 +495,8 @@ union bpf_attr {
 	FN(set_hash_invalid),		\
 	FN(get_numa_node_id),		\
 	FN(skb_change_head),		\
-	FN(xdp_adjust_head),
+	FN(xdp_adjust_head),		\
+	FN(probe_read_str),
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
  * function eBPF program intends to call
@@ -502,6 +522,7 @@ enum bpf_func_id {
 /* BPF_FUNC_l4_csum_replace flags. */
 #define BPF_F_PSEUDO_HDR		(1ULL << 4)
 #define BPF_F_MARK_MANGLED_0		(1ULL << 5)
+#define BPF_F_MARK_ENFORCE		(1ULL << 6)
 
 /* BPF_FUNC_clone_redirect and BPF_FUNC_redirect flags. */
 #define BPF_F_INGRESS			(1ULL << 0)
Signature · 1 line
2.11.0
#5 lore raw

PATCH 5/7 bpf: Simplify bpf_load_program() error handling in the library

In reply to Mickaël Salaün

Do not call a second time bpf(2) when a program load failed.

Cc Alexei Starovoitov <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Wang Nan <[email protected]>
---
 tools/lib/bpf/bpf.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
tools/lib/bpf/bpf.c +6 -12
index 3ddb58a36d3c..fda3f494f1cd 100644
@@ -73,7 +73,6 @@ int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,
 		     size_t insns_cnt, char *license,
 		     __u32 kern_version, char *log_buf, size_t log_buf_sz)
 {
-	int fd;
 	union bpf_attr attr;
 
 	bzero(&attr, sizeof(attr));
@@ -81,20 +80,15 @@ int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,
 	attr.insn_cnt = (__u32)insns_cnt;
 	attr.insns = ptr_to_u64(insns);
 	attr.license = ptr_to_u64(license);
-	attr.log_buf = ptr_to_u64(NULL);
-	attr.log_size = 0;
-	attr.log_level = 0;
+	attr.log_buf = ptr_to_u64(log_buf);
+	attr.log_size = log_buf_sz;
 	attr.kern_version = kern_version;
 
-	fd = sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
-	if (fd >= 0 || !log_buf || !log_buf_sz)
-		return fd;
+	if (log_buf && log_buf_sz > 0) {
+		attr.log_level = 1;
+		log_buf[0] = 0;
+	}
 
-	/* Try again with log */
-	attr.log_buf = ptr_to_u64(log_buf);
-	attr.log_size = log_buf_sz;
-	attr.log_level = 1;
-	log_buf[0] = 0;
 	return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
 }
 
Signature · 1 line
2.11.0
#6 lore raw

PATCH 6/7 bpf: Use the bpf_load_program() from the library

In reply to Mickaël Salaün

Replace bpf_prog_load() with bpf_load_program() calls.

Use the tools include directory instead of the installed one to allow builds from other kernels.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Shuah Khan <[email protected]>
---
 tools/testing/selftests/bpf/Makefile        |  6 +++++-
 tools/testing/selftests/bpf/bpf_sys.h       | 21 ---------------------
 tools/testing/selftests/bpf/test_tag.c      |  6 ++++--
 tools/testing/selftests/bpf/test_verifier.c |  8 +++++---
 4 files changed, 14 insertions(+), 27 deletions(-)
tools/testing/selftests/bpf/Makefile +5 -1
index 769a6cb42b4b..712861492278 100644
@@ -1,12 +1,16 @@
-CFLAGS += -Wall -O2 -I../../../../usr/include
+CFLAGS += -Wall -O2 -I../../../include/uapi -I../../../lib
 
 test_objs = test_verifier test_tag test_maps test_lru_map test_lpm_map
 
 TEST_PROGS := $(test_objs) test_kmod.sh
 TEST_FILES := $(test_objs)
+LIBBPF := ../../../lib/bpf/bpf.o
 
 all: $(test_objs)
 
+test_verifier: $(LIBBPF)
+test_tag: $(LIBBPF)
+
 include ../lib.mk
 
 clean:
tools/testing/selftests/bpf/bpf_sys.h +0 -21
index 6b4565f2a3f2..e7bbe3e5402e 100644
@@ -84,25 +84,4 @@ static inline int bpf_map_create(enum bpf_map_type type, uint32_t size_key,
 	return bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
 }
 
-static inline int bpf_prog_load(enum bpf_prog_type type,
-				const struct bpf_insn *insns, size_t size_insns,
-				const char *license, char *log, size_t size_log)
-{
-	union bpf_attr attr = {};
-
-	attr.prog_type = type;
-	attr.insns = bpf_ptr_to_u64(insns);
-	attr.insn_cnt = size_insns / sizeof(struct bpf_insn);
-	attr.license = bpf_ptr_to_u64(license);
-
-	if (size_log > 0) {
-		attr.log_buf = bpf_ptr_to_u64(log);
-		attr.log_size = size_log;
-		attr.log_level = 1;
-		log[0] = 0;
-	}
-
-	return bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
-}
-
 #endif /* __BPF_SYS__ */
tools/testing/selftests/bpf/test_tag.c +4 -2
index 5f7c602f47d1..b77dc4b03e77 100644
@@ -16,6 +16,8 @@
 #include <linux/bpf.h>
 #include <linux/if_alg.h>
 
+#include <bpf/bpf.h>
+
 #include "../../../include/linux/filter.h"
 
 #include "bpf_sys.h"
@@ -55,8 +57,8 @@ static int bpf_try_load_prog(int insns, int fd_map,
 	int fd_prog;
 
 	bpf_filler(insns, fd_map);
-	fd_prog = bpf_prog_load(BPF_PROG_TYPE_SCHED_CLS, prog, insns *
-				sizeof(struct bpf_insn), "", NULL, 0);
+	fd_prog = bpf_load_program(BPF_PROG_TYPE_SCHED_CLS, prog, insns, "", 0,
+			NULL, 0);
 	assert(fd_prog > 0);
 	if (fd_map > 0)
 		bpf_filler(insns, 0);
tools/testing/selftests/bpf/test_verifier.c +5 -3
index 0d0912c7f03c..04a549e54f61 100644
@@ -23,6 +23,8 @@
 #include <linux/bpf_perf_event.h>
 #include <linux/bpf.h>
 
+#include <bpf/bpf.h>
+
 #include "../../../include/linux/filter.h"
 
 #include "bpf_sys.h"
@@ -4456,9 +4458,9 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
 
 	do_test_fixup(test, prog, &fd_f1, &fd_f2, &fd_f3);
 
-	fd_prog = bpf_prog_load(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
-				prog, prog_len * sizeof(struct bpf_insn),
-				"GPL", bpf_vlog, sizeof(bpf_vlog));
+	fd_prog = bpf_load_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
+				prog, prog_len, "GPL", 0, bpf_vlog,
+				sizeof(bpf_vlog));
 
 	expected_ret = unpriv && test->result_unpriv != UNDEF ?
 		       test->result_unpriv : test->result;
Signature · 1 line
2.11.0
#13 lore raw

PATCH 7/7 bpf: Always test unprivileged programs

In reply to Mickaël Salaün

If selftests are run as root, then execute the unprivileged checks as well. This switch from 240 to 364 tests.

The test numbers are suffixed with "/u" when executed as unprivileged or with "/p" when executed as privileged.

The geteuid() check is replaced with a capability check.

Handling capabilities require the libcap dependency.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Shuah Khan <[email protected]>
---
 tools/testing/selftests/bpf/Makefile        |  2 +-
 tools/testing/selftests/bpf/test_verifier.c | 68 ++++++++++++++++++++++++++---
 2 files changed, 64 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/Makefile +1 -1
index 712861492278..30bb40261692 100644
@@ -1,4 +1,4 @@
-CFLAGS += -Wall -O2 -I../../../include/uapi -I../../../lib
+CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I../../../lib
 
 test_objs = test_verifier test_tag test_maps test_lru_map test_lpm_map
 
tools/testing/selftests/bpf/test_verifier.c +63 -5

93 lines not on this page · raw message

Signature · 1 line
2.11.0
maintainer
#7 lore raw

Re: [PATCH net-next v1 6/7] bpf: Use the bpf_load_program() from the library

In reply to Mickaël Salaün
Quoted 9 lines · Mickaël Salaün

Replace bpf_prog_load() with bpf_load_program() calls.

Use the tools include directory instead of the installed one to allow builds from other kernels.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Shuah Khan <[email protected]>
Quoted 6 lines
---
  tools/testing/selftests/bpf/Makefile        |  6 +++++-
  tools/testing/selftests/bpf/bpf_sys.h       | 21 ---------------------
  tools/testing/selftests/bpf/test_tag.c      |  6 ++++--
  tools/testing/selftests/bpf/test_verifier.c |  8 +++++---
  4 files changed, 14 insertions(+), 27 deletions(-)

No objections, but if so, can't we add the remaining missing pieces to bpf lib, so we can remove bpf_sys.h altogether?

Thanks,
Daniel

maintainer Acked-by on v1 7/7
#14 lore raw

Re: [PATCH net-next v1 7/7] bpf: Always test unprivileged programs

In reply to Mickaël Salaün
Quoted 6 lines · Mickaël Salaün

If selftests are run as root, then execute the unprivileged checks as well. This switch from 240 to 364 tests.

The test numbers are suffixed with "/u" when executed as unprivileged or with "/p" when executed as privileged.

Quoted 8 lines

The geteuid() check is replaced with a capability check.

Handling capabilities require the libcap dependency.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Shuah Khan <[email protected]>

Very useful! Could probably also go as stand-alone to net-next, but how you prefer.

Acked-by on v1 7/7
#15 lore raw

Re: [PATCH net-next v1 7/7] bpf: Always test unprivileged programs

In reply to Mickaël Salaün
Quoted 7 lines · Mickaël Salaün
tools/testing/selftests/bpf/test_verifier.c +5 -2
-		if (unpriv && test->prog_type)
-			continue;
+		if (!test->prog_type) {
+			if (!unpriv)
+				set_admin(false);
+			printf("#%d/u %s ", i, test->descr);
+			do_test_single(test, true, &passes, &errors);

tools/testing/selftests/bpf/test_verifier.c static int do_test(bool unpriv, unsigned int from, unsigned int to) · line 4573

Quoted 10 lines
tools/testing/selftests/bpf/test_verifier.c +7 -2
+			if (!unpriv)
+				set_admin(true);
+		}
 
-		printf("#%d %s ", i, test->descr);
-		do_test_single(test, unpriv, &passes, &errors);
+		if (!unpriv) {
+			printf("#%d/p %s ", i, test->descr);
+			do_test_single(test, false, &passes, &errors);
+		}

great idea.

as far as other patches.. we need to figure out how to avoid conflicts between net-next and Arnaldo's tree where Joe's patches went.

Mickael,
can you see some way of splitting the patch set between trees? Like above test_verfier.c improvement needs to go into net-next. The rest can go via perf

#8 lore raw

Re: [PATCH net-next v1 6/7] bpf: Use the bpf_load_program() from the library

In reply to Daniel Borkmann
Quoted 17 lines · Daniel Borkmann
Quoted 9 lines · Mickaël Salaün

Replace bpf_prog_load() with bpf_load_program() calls.

Use the tools include directory instead of the installed one to allow builds from other kernels.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Shuah Khan <[email protected]>
Quoted 6 lines
---
  tools/testing/selftests/bpf/Makefile        |  6 +++++-
  tools/testing/selftests/bpf/bpf_sys.h       | 21 ---------------------
  tools/testing/selftests/bpf/test_tag.c      |  6 ++++--
  tools/testing/selftests/bpf/test_verifier.c |  8 +++++---
  4 files changed, 14 insertions(+), 27 deletions(-)
Quoted 6 lines

No objections, but if so, can't we add the remaining missing pieces to bpf lib, so we can remove bpf_sys.h altogether?

Thanks,
Daniel

OK, I'll send a new patch replacing bpf_sys.h entirely.

Mickaël

maintainer
#9 lore raw

Re: [PATCH net-next v1 6/7] bpf: Use the bpf_load_program() from the library

Quoted 18 lines · Mickaël Salaün
Quoted 17 lines · Daniel Borkmann
Quoted 15 lines · Mickaël Salaün

Replace bpf_prog_load() with bpf_load_program() calls.

Use the tools include directory instead of the installed one to allow builds from other kernels.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Shuah Khan <[email protected]>
---
   tools/testing/selftests/bpf/Makefile        |  6 +++++-
   tools/testing/selftests/bpf/bpf_sys.h       | 21 ---------------------
   tools/testing/selftests/bpf/test_tag.c      |  6 ++++--
   tools/testing/selftests/bpf/test_verifier.c |  8 +++++---
   4 files changed, 14 insertions(+), 27 deletions(-)
Quoted 4 lines
Quoted 2 lines

No objections, but if so, can't we add the remaining missing pieces to bpf lib, so we can remove bpf_sys.h altogether?

OK, I'll send a new patch replacing bpf_sys.h entirely.

Sounds great, thanks!

#16 lore raw

Re: [PATCH net-next v1 7/7] bpf: Always test unprivileged programs

In reply to Alexei Starovoitov
Quoted 19 lines · Alexei Starovoitov
Quoted 7 lines · Mickaël Salaün
tools/testing/selftests/bpf/test_verifier.c +5 -2
-        if (unpriv && test->prog_type)
-            continue;
+        if (!test->prog_type) {
+            if (!unpriv)
+                set_admin(false);
+            printf("#%d/u %s ", i, test->descr);
+            do_test_single(test, true, &passes, &errors);

tools/testing/selftests/bpf/test_verifier.c static int do_test(bool unpriv, unsigned int from, unsigned int to) · line 4573

Quoted 10 lines
tools/testing/selftests/bpf/test_verifier.c +7 -2
+            if (!unpriv)
+                set_admin(true);
+        }
 
-        printf("#%d %s ", i, test->descr);
-        do_test_single(test, unpriv, &passes, &errors);
+        if (!unpriv) {
+            printf("#%d/p %s ", i, test->descr);
+            do_test_single(test, false, &passes, &errors);
+        }
Quoted 5 lines

great idea.

as far as other patches.. we need to figure out how to avoid conflicts between net-next and Arnaldo's tree where Joe's patches went.

A merge between this series and Arnaldo's tree works fine. The only dependency is between patches 6 and 7.

Quoted 7 lines

Mickael,
can you see some way of splitting the patch set between trees? Like above test_verfier.c improvement needs to go into net-next. The rest can go via perf

OK, I'll send a first series with the patches from 1 to 5 for the perf tree and a second series with the 6th and 7th patches (touching tools/testing/selftests/bpf only) to net-next.

#4 lore raw

Re: [PATCH net-next v1 4/7] tools: Sync {,tools/}include/uapi/linux/bpf.h

In reply to Mickaël Salaün

This patch only make sense in net-next, however.

Quoted 75 lines · Mickaël Salaün

The tools version of this header is out of date; update it to the latest version from kernel header.

Cc Alexei Starovoitov <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc David S. Miller <[email protected]>
---
 tools/include/uapi/linux/bpf.h | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
tools/include/uapi/linux/bpf.h +22 -1
index 0eb0e87dbe9f..e07fd5a324e6 100644
@@ -63,6 +63,12 @@ struct bpf_insn {
 	__s32	imm;		/* signed immediate constant */
 };
 
+/* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
+struct bpf_lpm_trie_key {
+	__u32	prefixlen;	/* up to 32 for AF_INET, 128 for AF_INET6 */
+	__u8	data[0];	/* Arbitrary size */
+};
+
 /* BPF syscall commands, see bpf(2) man-page for details. */
 enum bpf_cmd {
 	BPF_MAP_CREATE,
@@ -89,6 +95,7 @@ enum bpf_map_type {
 	BPF_MAP_TYPE_CGROUP_ARRAY,
 	BPF_MAP_TYPE_LRU_HASH,
 	BPF_MAP_TYPE_LRU_PERCPU_HASH,
+	BPF_MAP_TYPE_LPM_TRIE,
 };
 
 enum bpf_prog_type {
@@ -430,6 +437,18 @@ union bpf_attr {
  *     @xdp_md: pointer to xdp_md
  *     @delta: An positive/negative integer to be added to xdp_md.data
  *     Return: 0 on success or negative on error
+ *
+ * int bpf_probe_read_str(void *dst, int size, const void *unsafe_ptr)
+ *     Copy a NUL terminated string from unsafe address. In case the string
+ *     length is smaller than size, the target is not padded with further NUL
+ *     bytes. In case the string length is larger than size, just count-1
+ *     bytes are copied and the last byte is set to NUL.
+ *     @dst: destination address
+ *     @size: maximum number of bytes to copy, including the trailing NUL
+ *     @unsafe_ptr: unsafe address
+ *     Return:
+ *       > 0 length of the string including the trailing NUL on success
+ *       < 0 error
  */
 #define __BPF_FUNC_MAPPER(FN)		\
 	FN(unspec),			\
@@ -476,7 +495,8 @@ union bpf_attr {
 	FN(set_hash_invalid),		\
 	FN(get_numa_node_id),		\
 	FN(skb_change_head),		\
-	FN(xdp_adjust_head),
+	FN(xdp_adjust_head),		\
+	FN(probe_read_str),
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
  * function eBPF program intends to call
@@ -502,6 +522,7 @@ enum bpf_func_id {
 /* BPF_FUNC_l4_csum_replace flags. */
 #define BPF_F_PSEUDO_HDR		(1ULL << 4)
 #define BPF_F_MARK_MANGLED_0		(1ULL << 5)
+#define BPF_F_MARK_ENFORCE		(1ULL << 6)
 
 /* BPF_FUNC_clone_redirect and BPF_FUNC_redirect flags. */
 #define BPF_F_INGRESS			(1ULL << 0)
#10 lore raw

Re: [PATCH net-next v1 6/7] bpf: Use the bpf_load_program() from the library

In reply to Daniel Borkmann
Quoted 20 lines · Daniel Borkmann
Quoted 19 lines · Mickaël Salaün
Quoted 18 lines · Daniel Borkmann
Quoted 16 lines · Mickaël Salaün

Replace bpf_prog_load() with bpf_load_program() calls.

Use the tools include directory instead of the installed one to allow builds from other kernels.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Shuah Khan <[email protected]>
---
   tools/testing/selftests/bpf/Makefile        |  6 +++++-
   tools/testing/selftests/bpf/bpf_sys.h       | 21
---------------------
   tools/testing/selftests/bpf/test_tag.c      |  6 ++++--
   tools/testing/selftests/bpf/test_verifier.c |  8 +++++---
   4 files changed, 14 insertions(+), 27 deletions(-)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

No objections, but if so, can't we add the remaining missing pieces to bpf lib, so we can remove bpf_sys.h altogether?

OK, I'll send a new patch replacing bpf_sys.h entirely.

Sounds great, thanks!

Do you prefer a big patch or one for each replaced function?

maintainer
#11 lore raw

Re: [PATCH net-next v1 6/7] bpf: Use the bpf_load_program() from the library

Quoted 21 lines · Mickaël Salaün
Quoted 20 lines · Daniel Borkmann
Quoted 19 lines · Mickaël Salaün
Quoted 18 lines · Daniel Borkmann
Quoted 16 lines · Mickaël Salaün

Replace bpf_prog_load() with bpf_load_program() calls.

Use the tools include directory instead of the installed one to allow builds from other kernels.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Shuah Khan <[email protected]>
---
    tools/testing/selftests/bpf/Makefile        |  6 +++++-
    tools/testing/selftests/bpf/bpf_sys.h       | 21
---------------------
    tools/testing/selftests/bpf/test_tag.c      |  6 ++++--
    tools/testing/selftests/bpf/test_verifier.c |  8 +++++---
    4 files changed, 14 insertions(+), 27 deletions(-)
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

No objections, but if so, can't we add the remaining missing pieces to bpf lib, so we can remove bpf_sys.h altogether?

OK, I'll send a new patch replacing bpf_sys.h entirely.

Sounds great, thanks!

Do you prefer a big patch or one for each replaced function?

I think it makes sense to split it into two: i) this patch as-is for the prog part, and ii) rest for maps.

#12 lore raw

Re: [PATCH net-next v1 6/7] bpf: Use the bpf_load_program() from the library

Quoted 25 lines · Daniel Borkmann
Quoted 24 lines · Mickaël Salaün
Quoted 23 lines · Daniel Borkmann
Quoted 22 lines · Mickaël Salaün
Quoted 20 lines · Daniel Borkmann
Quoted 9 lines · Mickaël Salaün

Replace bpf_prog_load() with bpf_load_program() calls.

Use the tools include directory instead of the installed one to allow builds from other kernels.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Shuah Khan <[email protected]>
Quoted 7 lines
---
    tools/testing/selftests/bpf/Makefile        |  6 +++++-
    tools/testing/selftests/bpf/bpf_sys.h       | 21
---------------------
    tools/testing/selftests/bpf/test_tag.c      |  6 ++++--
    tools/testing/selftests/bpf/test_verifier.c |  8 +++++---
    4 files changed, 14 insertions(+), 27 deletions(-)

No objections, but if so, can't we add the remaining missing pieces to bpf lib, so we can remove bpf_sys.h altogether?

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

OK, I'll send a new patch replacing bpf_sys.h entirely.

Sounds great, thanks!

Do you prefer a big patch or one for each replaced function?

I think it makes sense to split it into two: i) this patch as-is for the prog part, and ii) rest for maps.

Hum, I already split them to ease the review. I'm going to send this series now.