History

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

Daniel Borkmann says: ==================== pull-request: bpf-next 2022-09-05 The following pull-request contains BPF updates for your *net-next* tree. We've added 106 non-merge commits during the last 18 day(s) which contain a total of 159 files changed, 5225 insertions(+), 1358 deletions(-). There are two small merge conflicts, resolve them as follows: 1) tools/testing/selftests/bpf/DENYLIST.s390x Commit 27e23836ce22 ("selftests/bpf: Add lru_bug to s390x deny list") in bpf tree was needed to get BPF CI green on s390x, but it conflicted with newly added tests on bpf-next. Resolve by adding both hunks, result: [...] lru_bug # prog 'printk': failed to auto-attach: -524 setget_sockopt # attach unexpected error: -524 (trampoline) cb_refs # expected error message unexpected error: -524 (trampoline) cgroup_hierarchical_stats # JIT does not support calling kernel function (kfunc) htab_update # failed to attach: ERROR: strerror_r(-524)=22 (trampoline) [...] 2) net/core/filter.c Commit 1227c1771dd2 ("net: Fix data-races around sysctl_[rw]mem_(max|default).") from net tree conflicts with commit 29003875bd5b ("bpf: Change bpf_setsockopt(SOL_SOCKET) to reuse sk_setsockopt()") from bpf-next tree. Take the code as it is from bpf-next tree, result: [...] if (getopt) { if (optname == SO_BINDTODEVICE) return -EINVAL; return sk_getsockopt(sk, SOL_SOCKET, optname, KERNEL_SOCKPTR(optval), KERNEL_SOCKPTR(optlen)); } return sk_setsockopt(sk, SOL_SOCKET, optname, KERNEL_SOCKPTR(optval), *optlen); [...] The main changes are: 1) Add any-context BPF specific memory allocator which is useful in particular for BPF tracing with bonus of performance equal to full prealloc, from Alexei Starovoitov. 2) Big batch to remove duplicated code from bpf_{get,set}sockopt() helpers as an effort to reuse the existing core socket code as much as possible, from Martin KaFai Lau. 3) Extend BPF flow dissector for BPF programs to just augment the in-kernel dissector with custom logic. In other words, allow for partial replacement, from Shmulik Ladkani. 4) Add a new cgroup iterator to BPF with different traversal options, from Hao Luo. 5) Support for BPF to collect hierarchical cgroup statistics efficiently through BPF integration with the rstat framework, from Yosry Ahmed. 6) Support bpf_{g,s}et_retval() under more BPF cgroup hooks, from Stanislav Fomichev. 7) BPF hash table and local storages fixes under fully preemptible kernel, from Hou Tao. 8) Add various improvements to BPF selftests and libbpf for compilation with gcc BPF backend, from James Hilliard. 9) Fix verifier helper permissions and reference state management for synchronous callbacks, from Kumar Kartikeya Dwivedi. 10) Add support for BPF selftest's xskxceiver to also be used against real devices that support MAC loopback, from Maciej Fijalkowski. 11) Various fixes to the bpf-helpers(7) man page generation script, from Quentin Monnet. 12) Document BPF verifier's tnum_in(tnum_range(), ...) gotchas, from Shung-Hsi Yu. 13) Various minor misc improvements all over the place. * https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (106 commits) bpf: Optimize rcu_barrier usage between hash map and bpf_mem_alloc. bpf: Remove usage of kmem_cache from bpf_mem_cache. bpf: Remove prealloc-only restriction for sleepable bpf programs. bpf: Prepare bpf_mem_alloc to be used by sleepable bpf programs. bpf: Remove tracing program restriction on map types bpf: Convert percpu hash map to per-cpu bpf_mem_alloc. bpf: Add percpu allocation support to bpf_mem_alloc. bpf: Batch call_rcu callbacks instead of SLAB_TYPESAFE_BY_RCU. bpf: Adjust low/high watermarks in bpf_mem_cache bpf: Optimize call_rcu in non-preallocated hash map. bpf: Optimize element count in non-preallocated hash map. bpf: Relax the requirement to use preallocated hash maps in tracing progs. samples/bpf: Reduce syscall overhead in map_perf_test. selftests/bpf: Improve test coverage of test_maps bpf: Convert hash map to bpf_mem_alloc. bpf: Introduce any context BPF specific memory allocator. selftest/bpf: Add test for bpf_getsockopt() bpf: Change bpf_getsockopt(SOL_IPV6) to reuse do_ipv6_getsockopt() bpf: Change bpf_getsockopt(SOL_IP) to reuse do_ip_getsockopt() bpf: Change bpf_getsockopt(SOL_TCP) to reuse do_tcp_getsockopt() ... ====================

Paolo Abeni committed 4 years ago

Commit 2786bcf2 parents 03fdb11 274052a159 files · +5225 −1358Browse files

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

Unified · Split

tools/include/uapi/linux/bpf.h+69−14
@@ -87,10 +87,29 @@ struct bpf_cgroup_storage_key { · 86 unmodified lines
8787 __u32 attach_type; /* program attach type (enum bpf_attach_type) */
8888 };
8989
90+enum bpf_cgroup_iter_order {
91+ BPF_CGROUP_ITER_ORDER_UNSPEC = 0,
92+ BPF_CGROUP_ITER_SELF_ONLY, /* process only a single object. */
93+ BPF_CGROUP_ITER_DESCENDANTS_PRE, /* walk descendants in pre-order. */
94+ BPF_CGROUP_ITER_DESCENDANTS_POST, /* walk descendants in post-order. */
95+ BPF_CGROUP_ITER_ANCESTORS_UP, /* walk ancestors upward. */
96+};
97+
9098 union bpf_iter_link_info {
9199 struct {
92100 __u32 map_fd;
93101 } map;
102+ struct {
103+ enum bpf_cgroup_iter_order order;
104+
105+ /* At most one of cgroup_fd and cgroup_id can be non-zero. If
106+ * both are zero, the walk starts from the default cgroup v2
107+ * root. For walking v1 hierarchy, one should always explicitly
108+ * specify cgroup_fd.
109+ */
110+ __u32 cgroup_fd;
111+ __u64 cgroup_id;
112+ } cgroup;
94113 };
95114
96115 /* BPF syscall commands, see bpf(2) man-page for more details. */
@@ -4437,7 +4456,7 @@ union bpf_attr { · 4340 unmodified lines
44374456 *
44384457 * **-EEXIST** if the option already exists.
44394458 *
4440− * **-EFAULT** on failrue to parse the existing header options.
4459+ * **-EFAULT** on failure to parse the existing header options.
44414460 *
44424461 * **-EPERM** if the helper cannot be used under the current
44434462 * *skops*\ **->op**.
@@ -4646,7 +4665,7 @@ union bpf_attr { · 202 unmodified lines
46464665 * a *map* with *task* as the **key**. From this
46474666 * perspective, the usage is not much different from
46484667 * **bpf_map_lookup_elem**\ (*map*, **&**\ *task*) except this
4649− * helper enforces the key must be an task_struct and the map must also
4668+ * helper enforces the key must be a task_struct and the map must also
46504669 * be a **BPF_MAP_TYPE_TASK_STORAGE**.
46514670 *
46524671 * Underneath, the value is stored locally at *task* instead of
@@ -4704,7 +4723,7 @@ union bpf_attr { · 51 unmodified lines
47044723 *
47054724 * long bpf_ima_inode_hash(struct inode *inode, void *dst, u32 size)
47064725 * Description
4707− * Returns the stored IMA hash of the *inode* (if it's avaialable).
4726+ * Returns the stored IMA hash of the *inode* (if it's available).
47084727 * If the hash is larger than *size*, then only *size*
47094728 * bytes will be copied to *dst*
47104729 * Return
@@ -4728,12 +4747,12 @@ union bpf_attr { · 17 unmodified lines
47284747 *
47294748 * The argument *len_diff* can be used for querying with a planned
47304749 * size change. This allows to check MTU prior to changing packet
4731− * ctx. Providing an *len_diff* adjustment that is larger than the
4750+ * ctx. Providing a *len_diff* adjustment that is larger than the
47324751 * actual packet size (resulting in negative packet size) will in
4733− * principle not exceed the MTU, why it is not considered a
4734− * failure. Other BPF-helpers are needed for performing the
4735− * planned size change, why the responsability for catch a negative
4736− * packet size belong in those helpers.
4752+ * principle not exceed the MTU, which is why it is not considered
4753+ * a failure. Other BPF helpers are needed for performing the
4754+ * planned size change; therefore the responsibility for catching
4755+ * a negative packet size belongs in those helpers.
47374756 *
47384757 * Specifying *ifindex* zero means the MTU check is performed
47394758 * against the current net device. This is practical if this isn't
@@ -5085,17 +5104,29 @@ union bpf_attr { · 345 unmodified lines
50855104 *
50865105 * int bpf_get_retval(void)
50875106 * Description
5088− * Get the syscall's return value that will be returned to userspace.
5107+ * Get the BPF program's return value that will be returned to the upper layers.
50895108 *
5090− * This helper is currently supported by cgroup programs only.
5109+ * This helper is currently supported by cgroup programs and only by the hooks
5110+ * where BPF program's return value is returned to the userspace via errno.
50915111 * Return
5092− * The syscall's return value.
5112+ * The BPF program's return value.
50935113 *
50945114 * int bpf_set_retval(int retval)
50955115 * Description
5096− * Set the syscall's return value that will be returned to userspace.
5116+ * Set the BPF program's return value that will be returned to the upper layers.
5117+ *
5118+ * This helper is currently supported by cgroup programs and only by the hooks
5119+ * where BPF program's return value is returned to the userspace via errno.
5120+ *
5121+ * Note that there is the following corner case where the program exports an error
5122+ * via bpf_set_retval but signals success via 'return 1':
5123+ *
5124+ * bpf_set_retval(-EPERM);
5125+ * return 1;
5126+ *
5127+ * In this case, the BPF program's return value will use helper's -EPERM. This
5128+ * still holds true for cgroup/bind{4,6} which supports extra 'return 3' success case.
50975129 *
5098− * This helper is currently supported by cgroup programs only.
50995130 * Return
51005131 * 0 on success, or a negative error in case of failure.
51015132 *
@@ -5628,6 +5659,11 @@ enum { · 526 unmodified lines
56285659 BPF_F_SEQ_NUMBER = (1ULL << 3),
56295660 };
56305661
5662+/* BPF_FUNC_skb_get_tunnel_key flags. */
5663+enum {
5664+ BPF_F_TUNINFO_FLAGS = (1ULL << 4),
5665+};
5666+
56315667 /* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and
56325668 * BPF_FUNC_perf_event_read_value flags.
56335669 */
@@ -5817,7 +5853,10 @@ struct bpf_tunnel_key { · 183 unmodified lines
58175853 };
58185854 __u8 tunnel_tos;
58195855 __u8 tunnel_ttl;
5820− __u16 tunnel_ext; /* Padding, future use. */
5856+ union {
5857+ __u16 tunnel_ext; /* compat */
5858+ __be16 tunnel_flags;
5859+ };
58215860 __u32 tunnel_label;
58225861 union {
58235862 __u32 local_ipv4;
@@ -5861,6 +5900,11 @@ enum bpf_ret_code { · 37 unmodified lines
58615900 * represented by BPF_REDIRECT above).
58625901 */
58635902 BPF_LWT_REROUTE = 128,
5903+ /* BPF_FLOW_DISSECTOR_CONTINUE: used by BPF_PROG_TYPE_FLOW_DISSECTOR
5904+ * to indicate that no custom dissection was performed, and
5905+ * fallback to standard dissector is requested.
5906+ */
5907+ BPF_FLOW_DISSECTOR_CONTINUE = 129,
58645908 };
58655909
58665910 struct bpf_sock {
@@ -6159,11 +6203,22 @@ struct bpf_link_info { · 292 unmodified lines
61596203 struct {
61606204 __aligned_u64 target_name; /* in/out: target_name buffer ptr */
61616205 __u32 target_name_len; /* in/out: target_name buffer len */
6206+
6207+ /* If the iter specific field is 32 bits, it can be put
6208+ * in the first or second union. Otherwise it should be
6209+ * put in the second union.
6210+ */
61626211 union {
61636212 struct {
61646213 __u32 map_id;
61656214 } map;
61666215 };
6216+ union {
6217+ struct {
6218+ __u64 cgroup_id;
6219+ __u32 order;
6220+ } cgroup;
6221+ };
61676222 } iter;
61686223 struct {
61696224 __u32 netns_ino;