History

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

Daniel Borkmann says: ==================== pull-request: bpf-next 2018-10-21 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) Implement two new kind of BPF maps, that is, queue and stack map along with new peek, push and pop operations, from Mauricio. 2) Add support for MSG_PEEK flag when redirecting into an ingress psock sk_msg queue, and add a new helper bpf_msg_push_data() for insert data into the message, from John. 3) Allow for BPF programs of type BPF_PROG_TYPE_CGROUP_SKB to use direct packet access for __skb_buff, from Song. 4) Use more lightweight barriers for walking perf ring buffer for libbpf and perf tool as well. Also, various fixes and improvements from verifier side, from Daniel. 5) Add per-symbol visibility for DSO in libbpf and hide by default global symbols such as netlink related functions, from Andrey. 6) Two improvements to nfp's BPF offload to check vNIC capabilities in case prog is shared with multiple vNICs and to protect against mis-initializing atomic counters, from Jakub. 7) Fix for bpftool to use 4 context mode for the nfp disassembler, also from Jakub. 8) Fix a return value comparison in test_libbpf.sh and add several bpftool improvements in bash completion, documentation of bpf fs restrictions and batch mode summary print, from Quentin. 9) Fix a file resource leak in BPF selftest's load_kallsyms() helper, from Peng. 10) Fix an unused variable warning in map_lookup_and_delete_elem(), from Alexei. 11) Fix bpf_skb_adjust_room() signature in BPF UAPI helper doc, from Nicolas. 12) Add missing executables to .gitignore in BPF selftests, from Anders. ====================

David S. Miller committed 8 years ago

Commit a19c59c2 parents 92303c8 fe8eccc62 files · +2315 −394Browse files

Showing the changes to include/uapi/linux (1 of 62 files). Show all

Unified · Split

include/uapi/linux/bpf.h+48−2
@@ -103,6 +103,7 @@ enum bpf_cmd { · 102 unmodified lines
103103 BPF_BTF_LOAD,
104104 BPF_BTF_GET_FD_BY_ID,
105105 BPF_TASK_FD_QUERY,
106+ BPF_MAP_LOOKUP_AND_DELETE_ELEM,
106107 };
107108
108109 enum bpf_map_type {
@@ -128,6 +129,8 @@ enum bpf_map_type { · 19 unmodified lines
128129 BPF_MAP_TYPE_CGROUP_STORAGE,
129130 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
130131 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
132+ BPF_MAP_TYPE_QUEUE,
133+ BPF_MAP_TYPE_STACK,
131134 };
132135
133136 enum bpf_prog_type {
@@ -462,6 +465,28 @@ union bpf_attr { · 328 unmodified lines
462465 * Return
463466 * 0 on success, or a negative error in case of failure.
464467 *
468+ * int bpf_map_push_elem(struct bpf_map *map, const void *value, u64 flags)
469+ * Description
470+ * Push an element *value* in *map*. *flags* is one of:
471+ *
472+ * **BPF_EXIST**
473+ * If the queue/stack is full, the oldest element is removed to
474+ * make room for this.
475+ * Return
476+ * 0 on success, or a negative error in case of failure.
477+ *
478+ * int bpf_map_pop_elem(struct bpf_map *map, void *value)
479+ * Description
480+ * Pop an element from *map*.
481+ * Return
482+ * 0 on success, or a negative error in case of failure.
483+ *
484+ * int bpf_map_peek_elem(struct bpf_map *map, void *value)
485+ * Description
486+ * Get an element from *map* without removing it.
487+ * Return
488+ * 0 on success, or a negative error in case of failure.
489+ *
465490 * int bpf_probe_read(void *dst, u32 size, const void *src)
466491 * Description
467492 * For tracing programs, safely attempt to read *size* bytes from
@@ -1433,7 +1458,7 @@ union bpf_attr { · 965 unmodified lines
14331458 * Return
14341459 * 0 on success, or a negative error in case of failure.
14351460 *
1436− * int bpf_skb_adjust_room(struct sk_buff *skb, u32 len_diff, u32 mode, u64 flags)
1461+ * int bpf_skb_adjust_room(struct sk_buff *skb, s32 len_diff, u32 mode, u64 flags)
14371462 * Description
14381463 * Grow or shrink the room for data in the packet associated to
14391464 * *skb* by *len_diff*, and according to the selected *mode*.
@@ -2215,6 +2240,23 @@ union bpf_attr { · 775 unmodified lines
22152240 * pointer that was returned from bpf_sk_lookup_xxx\ ().
22162241 * Return
22172242 * 0 on success, or a negative error in case of failure.
2243+ *
2244+ * int bpf_msg_push_data(struct sk_buff *skb, u32 start, u32 len, u64 flags)
2245+ * Description
2246+ * For socket policies, insert *len* bytes into msg at offset
2247+ * *start*.
2248+ *
2249+ * If a program of type **BPF_PROG_TYPE_SK_MSG** is run on a
2250+ * *msg* it may want to insert metadata or options into the msg.
2251+ * This can later be read and used by any of the lower layer BPF
2252+ * hooks.
2253+ *
2254+ * This helper may fail if under memory pressure (a malloc
2255+ * fails) in these cases BPF programs will get an appropriate
2256+ * error and BPF programs will need to handle them.
2257+ *
2258+ * Return
2259+ * 0 on success, or a negative error in case of failure.
22182260 */
22192261 #define __BPF_FUNC_MAPPER(FN) \
22202262 FN(unspec), \
@@ -2303,7 +2345,11 @@ union bpf_attr { · 82 unmodified lines
23032345 FN(skb_ancestor_cgroup_id), \
23042346 FN(sk_lookup_tcp), \
23052347 FN(sk_lookup_udp), \
2306− FN(sk_release),
2348+ FN(sk_release), \
2349+ FN(map_push_elem), \
2350+ FN(map_pop_elem), \
2351+ FN(map_peek_elem), \
2352+ FN(msg_push_data),
23072353
23082354 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
23092355 * function eBPF program intends to call