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
105 BPF_BTF_GET_FD_BY_ID,105 BPF_BTF_GET_FD_BY_ID,
106 BPF_TASK_FD_QUERY,106 BPF_TASK_FD_QUERY,
107 BPF_MAP_LOOKUP_AND_DELETE_ELEM,107 BPF_MAP_LOOKUP_AND_DELETE_ELEM,
108 BPF_MAP_FREEZE,
108};109};
109 110
110enum bpf_map_type {111enum bpf_map_type {
@@ -255,8 +256,19 @@ enum bpf_attach_type { · 144 unmodified lines
255 */256 */
256#define BPF_F_ANY_ALIGNMENT (1U << 1)257#define BPF_F_ANY_ALIGNMENT (1U << 1)
257 258
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 */
259#define BPF_PSEUDO_MAP_FD 1270#define BPF_PSEUDO_MAP_FD 1
271#define BPF_PSEUDO_MAP_VALUE 2
260 272
261/* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative273/* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative
262 * offset to another bpf function274 * offset to another bpf function
@@ -283,7 +295,7 @@ enum bpf_attach_type { · 20 unmodified lines
283 295
284#define BPF_OBJ_NAME_LEN 16U296#define BPF_OBJ_NAME_LEN 16U
285 297
286/* Flags for accessing BPF object */298/* Flags for accessing BPF object from syscall side. */
287#define BPF_F_RDONLY (1U << 3)299#define BPF_F_RDONLY (1U << 3)
288#define BPF_F_WRONLY (1U << 4)300#define BPF_F_WRONLY (1U << 4)
289 301
@@ -293,6 +305,10 @@ enum bpf_attach_type { · 3 unmodified lines
293/* Zero-initialize hash function seed. This should only be used for testing. */305/* Zero-initialize hash function seed. This should only be used for testing. */
294#define BPF_F_ZERO_SEED (1U << 6)306#define BPF_F_ZERO_SEED (1U << 6)
295 307
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
296/* flags for BPF_PROG_QUERY */312/* flags for BPF_PROG_QUERY */
297#define BPF_F_QUERY_EFFECTIVE (1U << 0)313#define BPF_F_QUERY_EFFECTIVE (1U << 0)
298 314
@@ -396,6 +412,13 @@ union bpf_attr { · 97 unmodified lines
396 __aligned_u64 data_out;412 __aligned_u64 data_out;
397 __u32 repeat;413 __u32 repeat;
398 __u32 duration;414 __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;
399 } test;422 } test;
400 423
401 struct { /* anonymous struct used by BPF_*_GET_*_ID */424 struct { /* anonymous struct used by BPF_*_GET_*_ID */
@@ -1500,6 +1523,10 @@ union bpf_attr { · 1098 unmodified lines
1500 * * **BPF_F_ADJ_ROOM_ENCAP_L4_UDP **:1523 * * **BPF_F_ADJ_ROOM_ENCAP_L4_UDP **:
1501 * Use with ENCAP_L3 flags to further specify the tunnel type.1524 * Use with ENCAP_L3 flags to further specify the tunnel type.
1502 *1525 *
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 *
1503 * A call to this helper is susceptible to change the underlaying1530 * A call to this helper is susceptible to change the underlaying
1504 * packet buffer. Therefore, at load time, all checks on pointers1531 * packet buffer. Therefore, at load time, all checks on pointers
1505 * previously done by the verifier are invalidated and must be1532 * previously done by the verifier are invalidated and must be
@@ -2641,10 +2668,16 @@ enum bpf_func_id { · 1135 unmodified lines
2641/* BPF_FUNC_skb_adjust_room flags. */2668/* BPF_FUNC_skb_adjust_room flags. */
2642#define BPF_F_ADJ_ROOM_FIXED_GSO (1ULL << 0)2669#define BPF_F_ADJ_ROOM_FIXED_GSO (1ULL << 0)
2643 2670
2671#define BPF_ADJ_ROOM_ENCAP_L2_MASK 0xff
2672#define BPF_ADJ_ROOM_ENCAP_L2_SHIFT 56
2673
2644#define BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 (1ULL << 1)2674#define BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 (1ULL << 1)
2645#define BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 (1ULL << 2)2675#define BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 (1ULL << 2)
2646#define BPF_F_ADJ_ROOM_ENCAP_L4_GRE (1ULL << 3)2676#define BPF_F_ADJ_ROOM_ENCAP_L4_GRE (1ULL << 3)
2647#define BPF_F_ADJ_ROOM_ENCAP_L4_UDP (1ULL << 4)2677#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)
2648 2681
2649/* Mode for BPF_FUNC_skb_adjust_room helper. */2682/* Mode for BPF_FUNC_skb_adjust_room helper. */
2650enum bpf_adj_room_mode {2683enum bpf_adj_room_mode {
include/uapi/linux/btf.h+28−4
@@ -39,11 +39,11 @@ struct btf_type { · 38 unmodified lines
39 * struct, union and fwd39 * struct, union and fwd
40 */40 */
41 __u32 info;41 __u32 info;
42 /* "size" is used by INT, ENUM, STRUCT and UNION.42 /* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC.
43 * "size" tells the size of the type it is describing.43 * "size" tells the size of the type it is describing.
44 *44 *
45 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,45 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
46 * FUNC and FUNC_PROTO.46 * FUNC, FUNC_PROTO and VAR.
47 * "type" is a type_id referring to another type.47 * "type" is a type_id referring to another type.
48 */48 */
49 union {49 union {
@@ -70,8 +70,10 @@ struct btf_type { · 20 unmodified lines
70#define BTF_KIND_RESTRICT 11 /* Restrict */70#define BTF_KIND_RESTRICT 11 /* Restrict */
71#define BTF_KIND_FUNC 12 /* Function */71#define BTF_KIND_FUNC 12 /* Function */
72#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */72#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */
73#define BTF_KIND_MAX 1373#define BTF_KIND_VAR 14 /* Variable */
74#define NR_BTF_KINDS 1474#define BTF_KIND_DATASEC 15 /* Section */
75#define BTF_KIND_MAX BTF_KIND_DATASEC
76#define NR_BTF_KINDS (BTF_KIND_MAX + 1)
75 77
76/* For some specific BTF_KIND, "struct btf_type" is immediately78/* For some specific BTF_KIND, "struct btf_type" is immediately
77 * followed by extra data.79 * followed by extra data.
@@ -138,4 +140,26 @@ struct btf_param { · 60 unmodified lines
138 __u32 type;140 __u32 type;
139};141};
140 142
143enum {
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 */
151struct 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 */
159struct btf_var_secinfo {
160 __u32 type;
161 __u32 offset;
162 __u32 size;
163};
164
141#endif /* _UAPI__LINUX_BTF_H__ */165#endif /* _UAPI__LINUX_BTF_H__ */