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
87 __u32 attach_type; /* program attach type (enum bpf_attach_type) */87 __u32 attach_type; /* program attach type (enum bpf_attach_type) */
88};88};
89 89
90enum 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
90union bpf_iter_link_info {98union bpf_iter_link_info {
91 struct {99 struct {
92 __u32 map_fd;100 __u32 map_fd;
93 } map;101 } 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;
94};113};
95 114
96/* BPF syscall commands, see bpf(2) man-page for more details. */115/* BPF syscall commands, see bpf(2) man-page for more details. */
@@ -4437,7 +4456,7 @@ union bpf_attr { · 4340 unmodified lines
4437 *4456 *
4438 * **-EEXIST** if the option already exists.4457 * **-EEXIST** if the option already exists.
4439 *4458 *
4440 * **-EFAULT** on failrue to parse the existing header options.4459 * **-EFAULT** on failure to parse the existing header options.
4441 *4460 *
4442 * **-EPERM** if the helper cannot be used under the current4461 * **-EPERM** if the helper cannot be used under the current
4443 * *skops*\ **->op**.4462 * *skops*\ **->op**.
@@ -4646,7 +4665,7 @@ union bpf_attr { · 202 unmodified lines
4646 * a *map* with *task* as the **key**. From this4665 * a *map* with *task* as the **key**. From this
4647 * perspective, the usage is not much different from4666 * perspective, the usage is not much different from
4648 * **bpf_map_lookup_elem**\ (*map*, **&**\ *task*) except this4667 * **bpf_map_lookup_elem**\ (*map*, **&**\ *task*) except this
4649 * helper enforces the key must be an task_struct and the map must also4668 * helper enforces the key must be a task_struct and the map must also
4650 * be a **BPF_MAP_TYPE_TASK_STORAGE**.4669 * be a **BPF_MAP_TYPE_TASK_STORAGE**.
4651 *4670 *
4652 * Underneath, the value is stored locally at *task* instead of4671 * Underneath, the value is stored locally at *task* instead of
@@ -4704,7 +4723,7 @@ union bpf_attr { · 51 unmodified lines
4704 *4723 *
4705 * long bpf_ima_inode_hash(struct inode *inode, void *dst, u32 size)4724 * long bpf_ima_inode_hash(struct inode *inode, void *dst, u32 size)
4706 * Description4725 * 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).
4708 * If the hash is larger than *size*, then only *size*4727 * If the hash is larger than *size*, then only *size*
4709 * bytes will be copied to *dst*4728 * bytes will be copied to *dst*
4710 * Return4729 * Return
@@ -4728,12 +4747,12 @@ union bpf_attr { · 17 unmodified lines
4728 *4747 *
4729 * The argument *len_diff* can be used for querying with a planned4748 * The argument *len_diff* can be used for querying with a planned
4730 * size change. This allows to check MTU prior to changing packet4749 * size change. This allows to check MTU prior to changing packet
4731 * ctx. Providing an *len_diff* adjustment that is larger than the4750 * ctx. Providing a *len_diff* adjustment that is larger than the
4732 * actual packet size (resulting in negative packet size) will in4751 * actual packet size (resulting in negative packet size) will in
4733 * principle not exceed the MTU, why it is not considered a4752 * principle not exceed the MTU, which is why it is not considered
4734 * failure. Other BPF-helpers are needed for performing the4753 * a failure. Other BPF helpers are needed for performing the
4735 * planned size change, why the responsability for catch a negative4754 * planned size change; therefore the responsibility for catching
4736 * packet size belong in those helpers.4755 * a negative packet size belongs in those helpers.
4737 *4756 *
4738 * Specifying *ifindex* zero means the MTU check is performed4757 * Specifying *ifindex* zero means the MTU check is performed
4739 * against the current net device. This is practical if this isn't4758 * against the current net device. This is practical if this isn't
@@ -5085,17 +5104,29 @@ union bpf_attr { · 345 unmodified lines
5085 *5104 *
5086 * int bpf_get_retval(void)5105 * int bpf_get_retval(void)
5087 * Description5106 * 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.
5089 *5108 *
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.
5091 * Return5111 * Return
5092 * The syscall's return value.5112 * The BPF program's return value.
5093 *5113 *
5094 * int bpf_set_retval(int retval)5114 * int bpf_set_retval(int retval)
5095 * Description5115 * 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.
5097 *5129 *
5098 * This helper is currently supported by cgroup programs only.
5099 * Return5130 * Return
5100 * 0 on success, or a negative error in case of failure.5131 * 0 on success, or a negative error in case of failure.
5101 *5132 *
@@ -5628,6 +5659,11 @@ enum { · 526 unmodified lines
5628 BPF_F_SEQ_NUMBER = (1ULL << 3),5659 BPF_F_SEQ_NUMBER = (1ULL << 3),
5629};5660};
5630 5661
5662/* BPF_FUNC_skb_get_tunnel_key flags. */
5663enum {
5664 BPF_F_TUNINFO_FLAGS = (1ULL << 4),
5665};
5666
5631/* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and5667/* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and
5632 * BPF_FUNC_perf_event_read_value flags.5668 * BPF_FUNC_perf_event_read_value flags.
5633 */5669 */
@@ -5817,7 +5853,10 @@ struct bpf_tunnel_key { · 183 unmodified lines
5817 };5853 };
5818 __u8 tunnel_tos;5854 __u8 tunnel_tos;
5819 __u8 tunnel_ttl;5855 __u8 tunnel_ttl;
5820 __u16 tunnel_ext; /* Padding, future use. */5856 union {
5857 __u16 tunnel_ext; /* compat */
5858 __be16 tunnel_flags;
5859 };
5821 __u32 tunnel_label;5860 __u32 tunnel_label;
5822 union {5861 union {
5823 __u32 local_ipv4;5862 __u32 local_ipv4;
@@ -5861,6 +5900,11 @@ enum bpf_ret_code { · 37 unmodified lines
5861 * represented by BPF_REDIRECT above).5900 * represented by BPF_REDIRECT above).
5862 */5901 */
5863 BPF_LWT_REROUTE = 128,5902 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,
5864};5908};
5865 5909
5866struct bpf_sock {5910struct bpf_sock {
@@ -6159,11 +6203,22 @@ struct bpf_link_info { · 292 unmodified lines
6159 struct {6203 struct {
6160 __aligned_u64 target_name; /* in/out: target_name buffer ptr */6204 __aligned_u64 target_name; /* in/out: target_name buffer ptr */
6161 __u32 target_name_len; /* in/out: target_name buffer len */6205 __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 */
6162 union {6211 union {
6163 struct {6212 struct {
6164 __u32 map_id;6213 __u32 map_id;
6165 } map;6214 } map;
6166 };6215 };
6216 union {
6217 struct {
6218 __u64 cgroup_id;
6219 __u32 order;
6220 } cgroup;
6221 };
6167 } iter;6222 } iter;
6168 struct {6223 struct {
6169 __u32 netns_ino;6224 __u32 netns_ino;