History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next

Daniel Borkmann says: ==================== pull-request: bpf-next 2019-04-12 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) Improve BPF verifier scalability for large programs through two optimizations: i) remove verifier states that are not useful in pruning, ii) stop walking parentage chain once first LIVE_READ is seen. Combined gives approx 20x speedup. Increase limits for accepting large programs under root, and add various stress tests, from Alexei. 2) Implement global data support in BPF. This enables static global variables for .data, .rodata and .bss sections to be properly handled which allows for more natural program development. This also opens up the possibility to optimize program workflow by compiling ELFs only once and later only rewriting section data before reload, from Daniel and with test cases and libbpf refactoring from Joe. 3) Add config option to generate BTF type info for vmlinux as part of the kernel build process. DWARF debug info is converted via pahole to BTF. Latter relies on libbpf and makes use of BTF deduplication algorithm which results in 100x savings compared to DWARF data. Resulting .BTF section is typically about 2MB in size, from Andrii. 4) Add BPF verifier support for stack access with variable offset from helpers and add various test cases along with it, from Andrey. 5) Extend bpf_skb_adjust_room() growth BPF helper to mark inner MAC header so that L2 encapsulation can be used for tc tunnels, from Alan. 6) Add support for input __sk_buff context in BPF_PROG_TEST_RUN so that users can define a subset of allowed __sk_buff fields that get fed into the test program, from Stanislav. 7) Add bpf fs multi-dimensional array tests for BTF test suite and fix up various UBSAN warnings in bpftool, from Yonghong. 8) Generate a pkg-config file for libbpf, from Luca. 9) Dump program's BTF id in bpftool, from Prashant. 10) libbpf fix to use smaller BPF log buffer size for AF_XDP's XDP program, from Magnus. 11) kallsyms related fixes for the case when symbols are not present in BPF selftests and samples, from Daniel ====================

David S. Miller committed 7 years ago

Commit bb235812 parents 78f07ad 947e8b575 files · +4603 −425Browse files

Showing the changes to include/uapi/linux (2 of 75 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/bpf.h +35 −2
  2. include/uapi/linux/btf.h +28 −4
include/uapi/linux/bpf.h+35−2
@@ -105,6 +105,7 @@ enum bpf_cmd { · 104 unmodified lines
105105 BPF_BTF_GET_FD_BY_ID,
106106 BPF_TASK_FD_QUERY,
107107 BPF_MAP_LOOKUP_AND_DELETE_ELEM,
108+ BPF_MAP_FREEZE,
108109 };
109110
110111 enum bpf_map_type {
@@ -255,8 +256,19 @@ enum bpf_attach_type { · 144 unmodified lines
255256 */
256257 #define BPF_F_ANY_ALIGNMENT (1U << 1)
257258
258−/* when bpf_ldimm64->src_reg == BPF_PSEUDO_MAP_FD, bpf_ldimm64->imm == fd */
259+/* When BPF ldimm64's insn[0].src_reg != 0 then this can have
260+ * two extensions:
261+ *
262+ * insn[0].src_reg: BPF_PSEUDO_MAP_FD BPF_PSEUDO_MAP_VALUE
263+ * insn[0].imm: map fd map fd
264+ * insn[1].imm: 0 offset into value
265+ * insn[0].off: 0 0
266+ * insn[1].off: 0 0
267+ * ldimm64 rewrite: address of map address of map[0]+offset
268+ * verifier type: CONST_PTR_TO_MAP PTR_TO_MAP_VALUE
269+ */
259270 #define BPF_PSEUDO_MAP_FD 1
271+#define BPF_PSEUDO_MAP_VALUE 2
260272
261273 /* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative
262274 * offset to another bpf function
@@ -283,7 +295,7 @@ enum bpf_attach_type { · 20 unmodified lines
283295
284296 #define BPF_OBJ_NAME_LEN 16U
285297
286−/* Flags for accessing BPF object */
298+/* Flags for accessing BPF object from syscall side. */
287299 #define BPF_F_RDONLY (1U << 3)
288300 #define BPF_F_WRONLY (1U << 4)
289301
@@ -293,6 +305,10 @@ enum bpf_attach_type { · 3 unmodified lines
293305 /* Zero-initialize hash function seed. This should only be used for testing. */
294306 #define BPF_F_ZERO_SEED (1U << 6)
295307
308+/* Flags for accessing BPF object from program side. */
309+#define BPF_F_RDONLY_PROG (1U << 7)
310+#define BPF_F_WRONLY_PROG (1U << 8)
311+
296312 /* flags for BPF_PROG_QUERY */
297313 #define BPF_F_QUERY_EFFECTIVE (1U << 0)
298314
@@ -396,6 +412,13 @@ union bpf_attr { · 97 unmodified lines
396412 __aligned_u64 data_out;
397413 __u32 repeat;
398414 __u32 duration;
415+ __u32 ctx_size_in; /* input: len of ctx_in */
416+ __u32 ctx_size_out; /* input/output: len of ctx_out
417+ * returns ENOSPC if ctx_out
418+ * is too small.
419+ */
420+ __aligned_u64 ctx_in;
421+ __aligned_u64 ctx_out;
399422 } test;
400423
401424 struct { /* anonymous struct used by BPF_*_GET_*_ID */
@@ -1500,6 +1523,10 @@ union bpf_attr { · 1098 unmodified lines
15001523 * * **BPF_F_ADJ_ROOM_ENCAP_L4_UDP **:
15011524 * Use with ENCAP_L3 flags to further specify the tunnel type.
15021525 *
1526+ * * **BPF_F_ADJ_ROOM_ENCAP_L2(len) **:
1527+ * Use with ENCAP_L3/L4 flags to further specify the tunnel
1528+ * type; **len** is the length of the inner MAC header.
1529+ *
15031530 * A call to this helper is susceptible to change the underlaying
15041531 * packet buffer. Therefore, at load time, all checks on pointers
15051532 * previously done by the verifier are invalidated and must be
@@ -2641,10 +2668,16 @@ enum bpf_func_id { · 1135 unmodified lines
26412668 /* BPF_FUNC_skb_adjust_room flags. */
26422669 #define BPF_F_ADJ_ROOM_FIXED_GSO (1ULL << 0)
26432670
2671+#define BPF_ADJ_ROOM_ENCAP_L2_MASK 0xff
2672+#define BPF_ADJ_ROOM_ENCAP_L2_SHIFT 56
2673+
26442674 #define BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 (1ULL << 1)
26452675 #define BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 (1ULL << 2)
26462676 #define BPF_F_ADJ_ROOM_ENCAP_L4_GRE (1ULL << 3)
26472677 #define BPF_F_ADJ_ROOM_ENCAP_L4_UDP (1ULL << 4)
2678+#define BPF_F_ADJ_ROOM_ENCAP_L2(len) (((__u64)len & \
2679+ BPF_ADJ_ROOM_ENCAP_L2_MASK) \
2680+ << BPF_ADJ_ROOM_ENCAP_L2_SHIFT)
26482681
26492682 /* Mode for BPF_FUNC_skb_adjust_room helper. */
26502683 enum bpf_adj_room_mode {
include/uapi/linux/btf.h+28−4
@@ -39,11 +39,11 @@ struct btf_type { · 38 unmodified lines
3939 * struct, union and fwd
4040 */
4141 __u32 info;
42− /* "size" is used by INT, ENUM, STRUCT and UNION.
42+ /* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC.
4343 * "size" tells the size of the type it is describing.
4444 *
4545 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
46− * FUNC and FUNC_PROTO.
46+ * FUNC, FUNC_PROTO and VAR.
4747 * "type" is a type_id referring to another type.
4848 */
4949 union {
@@ -70,8 +70,10 @@ struct btf_type { · 20 unmodified lines
7070 #define BTF_KIND_RESTRICT 11 /* Restrict */
7171 #define BTF_KIND_FUNC 12 /* Function */
7272 #define BTF_KIND_FUNC_PROTO 13 /* Function Proto */
73−#define BTF_KIND_MAX 13
74−#define NR_BTF_KINDS 14
73+#define BTF_KIND_VAR 14 /* Variable */
74+#define BTF_KIND_DATASEC 15 /* Section */
75+#define BTF_KIND_MAX BTF_KIND_DATASEC
76+#define NR_BTF_KINDS (BTF_KIND_MAX + 1)
7577
7678 /* For some specific BTF_KIND, "struct btf_type" is immediately
7779 * followed by extra data.
@@ -138,4 +140,26 @@ struct btf_param { · 60 unmodified lines
138140 __u32 type;
139141 };
140142
143+enum {
144+ BTF_VAR_STATIC = 0,
145+ BTF_VAR_GLOBAL_ALLOCATED,
146+};
147+
148+/* BTF_KIND_VAR is followed by a single "struct btf_var" to describe
149+ * additional information related to the variable such as its linkage.
150+ */
151+struct btf_var {
152+ __u32 linkage;
153+};
154+
155+/* BTF_KIND_DATASEC is followed by multiple "struct btf_var_secinfo"
156+ * to describe all BTF_KIND_VAR types it contains along with it's
157+ * in-section offset as well as size.
158+ */
159+struct btf_var_secinfo {
160+ __u32 type;
161+ __u32 offset;
162+ __u32 size;
163+};
164+
141165 #endif /* _UAPI__LINUX_BTF_H__ */