Alexei Starovoitov says: ==================== pull-request: bpf-next 2020-05-01 (v2) The following pull-request contains BPF updates for your *net-next* tree. We've added 61 non-merge commits during the last 6 day(s) which contain a total of 153 files changed, 6739 insertions(+), 3367 deletions(-). The main changes are: 1) pulled work.sysctl from vfs tree with sysctl bpf changes. 2) bpf_link observability, from Andrii. 3) BTF-defined map in map, from Andrii. 4) asan fixes for selftests, from Andrii. 5) Allow bpf_map_lookup_elem for SOCKMAP and SOCKHASH, from Jakub. 6) production cloudflare classifier as a selftes, from Lorenz. 7) bpf_ktime_get_*_ns() helper improvements, from Maciej. 8) unprivileged bpftool feature probe, from Quentin. 9) BPF_ENABLE_STATS command, from Song. 10) enable bpf_[gs]etsockopt() helpers for sock_ops progs, from Stanislav. 11) enable a bunch of common helpers for cg-device, sysctl, sockopt progs, from Stanislav. ====================
Showing the changes to include/uapi/linux (1 of 153 files). Show all
Unified · Split
| @@ -113,6 +113,9 @@ enum bpf_cmd { · 112 unmodified lines | |||
| 113 | BPF_MAP_DELETE_BATCH, | 113 | BPF_MAP_DELETE_BATCH, |
| 114 | BPF_LINK_CREATE, | 114 | BPF_LINK_CREATE, |
| 115 | BPF_LINK_UPDATE, | 115 | BPF_LINK_UPDATE, |
| 116 | BPF_LINK_GET_FD_BY_ID, | ||
| 117 | BPF_LINK_GET_NEXT_ID, | ||
| 118 | BPF_ENABLE_STATS, | ||
| 116 | }; | 119 | }; |
| 117 | 120 | ||
| 118 | enum bpf_map_type { | 121 | enum bpf_map_type { |
| @@ -220,6 +223,15 @@ enum bpf_attach_type { · 101 unmodified lines | |||
| 220 | 223 | ||
| 221 | #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE | 224 | #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE |
| 222 | 225 | ||
| 226 | enum bpf_link_type { | ||
| 227 | BPF_LINK_TYPE_UNSPEC = 0, | ||
| 228 | BPF_LINK_TYPE_RAW_TRACEPOINT = 1, | ||
| 229 | BPF_LINK_TYPE_TRACING = 2, | ||
| 230 | BPF_LINK_TYPE_CGROUP = 3, | ||
| 231 | |||
| 232 | MAX_BPF_LINK_TYPE, | ||
| 233 | }; | ||
| 234 | |||
| 223 | /* cgroup-bpf attach flags used in BPF_PROG_ATTACH command | 235 | /* cgroup-bpf attach flags used in BPF_PROG_ATTACH command |
| 224 | * | 236 | * |
| 225 | * NONE(default): No further bpf programs allowed in the subtree. | 237 | * NONE(default): No further bpf programs allowed in the subtree. |
| @@ -379,6 +391,12 @@ enum { · 153 unmodified lines | |||
| 379 | */ | 391 | */ |
| 380 | #define BPF_F_QUERY_EFFECTIVE (1U << 0) | 392 | #define BPF_F_QUERY_EFFECTIVE (1U << 0) |
| 381 | 393 | ||
| 394 | /* type for BPF_ENABLE_STATS */ | ||
| 395 | enum bpf_stats_type { | ||
| 396 | /* enabled run_time_ns and run_cnt */ | ||
| 397 | BPF_STATS_RUN_TIME = 0, | ||
| 398 | }; | ||
| 399 | |||
| 382 | enum bpf_stack_build_id_status { | 400 | enum bpf_stack_build_id_status { |
| 383 | /* user space need an empty entry to identify end of a trace */ | 401 | /* user space need an empty entry to identify end of a trace */ |
| 384 | BPF_STACK_BUILD_ID_EMPTY = 0, | 402 | BPF_STACK_BUILD_ID_EMPTY = 0, |
| @@ -523,6 +541,7 @@ union bpf_attr { · 138 unmodified lines | |||
| 523 | __u32 prog_id; | 541 | __u32 prog_id; |
| 524 | __u32 map_id; | 542 | __u32 map_id; |
| 525 | __u32 btf_id; | 543 | __u32 btf_id; |
| 544 | __u32 link_id; | ||
| 526 | }; | 545 | }; |
| 527 | __u32 next_id; | 546 | __u32 next_id; |
| 528 | __u32 open_flags; | 547 | __u32 open_flags; |
| @@ -589,6 +608,10 @@ union bpf_attr { · 60 unmodified lines | |||
| 589 | __u32 old_prog_fd; | 608 | __u32 old_prog_fd; |
| 590 | } link_update; | 609 | } link_update; |
| 591 | 610 | ||
| 611 | struct { /* struct used by BPF_ENABLE_STATS command */ | ||
| 612 | __u32 type; | ||
| 613 | } enable_stats; | ||
| 614 | |||
| 592 | } __attribute__((aligned(8))); | 615 | } __attribute__((aligned(8))); |
| 593 | 616 | ||
| 594 | /* The description below is an attempt at providing documentation to eBPF | 617 | /* The description below is an attempt at providing documentation to eBPF |
| @@ -652,6 +675,8 @@ union bpf_attr { · 57 unmodified lines | |||
| 652 | * u64 bpf_ktime_get_ns(void) | 675 | * u64 bpf_ktime_get_ns(void) |
| 653 | * Description | 676 | * Description |
| 654 | * Return the time elapsed since system boot, in nanoseconds. | 677 | * Return the time elapsed since system boot, in nanoseconds. |
| 678 | * Does not include time the system was suspended. | ||
| 679 | * See: clock_gettime(CLOCK_MONOTONIC) | ||
| 655 | * Return | 680 | * Return |
| 656 | * Current *ktime*. | 681 | * Current *ktime*. |
| 657 | * | 682 | * |
| @@ -1562,7 +1587,7 @@ union bpf_attr { · 904 unmodified lines | |||
| 1562 | * Return | 1587 | * Return |
| 1563 | * 0 | 1588 | * 0 |
| 1564 | * | 1589 | * |
| 1565 | * int bpf_setsockopt(struct bpf_sock_ops *bpf_socket, int level, int optname, void *optval, int optlen) | 1590 | * int bpf_setsockopt(void *bpf_socket, int level, int optname, void *optval, int optlen) |
| 1566 | * Description | 1591 | * Description |
| 1567 | * Emulate a call to **setsockopt()** on the socket associated to | 1592 | * Emulate a call to **setsockopt()** on the socket associated to |
| 1568 | * *bpf_socket*, which must be a full socket. The *level* at | 1593 | * *bpf_socket*, which must be a full socket. The *level* at |
| @@ -1570,6 +1595,11 @@ union bpf_attr { · 1 unmodified line | |||
| 1570 | * must be specified, see **setsockopt(2)** for more information. | 1595 | * must be specified, see **setsockopt(2)** for more information. |
| 1571 | * The option value of length *optlen* is pointed by *optval*. | 1596 | * The option value of length *optlen* is pointed by *optval*. |
| 1572 | * | 1597 | * |
| 1598 | * *bpf_socket* should be one of the following: | ||
| 1599 | * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. | ||
| 1600 | * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT** | ||
| 1601 | * and **BPF_CGROUP_INET6_CONNECT**. | ||
| 1602 | * | ||
| 1573 | * This helper actually implements a subset of **setsockopt()**. | 1603 | * This helper actually implements a subset of **setsockopt()**. |
| 1574 | * It supports the following *level*\ s: | 1604 | * It supports the following *level*\ s: |
| 1575 | * | 1605 | * |
| @@ -1764,7 +1794,7 @@ union bpf_attr { · 188 unmodified lines | |||
| 1764 | * Return | 1794 | * Return |
| 1765 | * 0 on success, or a negative error in case of failure. | 1795 | * 0 on success, or a negative error in case of failure. |
| 1766 | * | 1796 | * |
| 1767 | * int bpf_getsockopt(struct bpf_sock_ops *bpf_socket, int level, int optname, void *optval, int optlen) | 1797 | * int bpf_getsockopt(void *bpf_socket, int level, int optname, void *optval, int optlen) |
| 1768 | * Description | 1798 | * Description |
| 1769 | * Emulate a call to **getsockopt()** on the socket associated to | 1799 | * Emulate a call to **getsockopt()** on the socket associated to |
| 1770 | * *bpf_socket*, which must be a full socket. The *level* at | 1800 | * *bpf_socket*, which must be a full socket. The *level* at |
| @@ -1773,6 +1803,11 @@ union bpf_attr { · 2 unmodified lines | |||
| 1773 | * The retrieved value is stored in the structure pointed by | 1803 | * The retrieved value is stored in the structure pointed by |
| 1774 | * *opval* and of length *optlen*. | 1804 | * *opval* and of length *optlen*. |
| 1775 | * | 1805 | * |
| 1806 | * *bpf_socket* should be one of the following: | ||
| 1807 | * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. | ||
| 1808 | * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT** | ||
| 1809 | * and **BPF_CGROUP_INET6_CONNECT**. | ||
| 1810 | * | ||
| 1776 | * This helper actually implements a subset of **getsockopt()**. | 1811 | * This helper actually implements a subset of **getsockopt()**. |
| 1777 | * It supports the following *level*\ s: | 1812 | * It supports the following *level*\ s: |
| 1778 | * | 1813 | * |
| @@ -3025,6 +3060,14 @@ union bpf_attr { · 1246 unmodified lines | |||
| 3025 | * * **-EOPNOTSUPP** Unsupported operation, for example a | 3060 | * * **-EOPNOTSUPP** Unsupported operation, for example a |
| 3026 | * call from outside of TC ingress. | 3061 | * call from outside of TC ingress. |
| 3027 | * * **-ESOCKTNOSUPPORT** Socket type not supported (reuseport). | 3062 | * * **-ESOCKTNOSUPPORT** Socket type not supported (reuseport). |
| 3063 | * | ||
| 3064 | * u64 bpf_ktime_get_boot_ns(void) | ||
| 3065 | * Description | ||
| 3066 | * Return the time elapsed since system boot, in nanoseconds. | ||
| 3067 | * Does include the time the system was suspended. | ||
| 3068 | * See: clock_gettime(CLOCK_BOOTTIME) | ||
| 3069 | * Return | ||
| 3070 | * Current *ktime*. | ||
| 3028 | */ | 3071 | */ |
| 3029 | #define __BPF_FUNC_MAPPER(FN) \ | 3072 | #define __BPF_FUNC_MAPPER(FN) \ |
| 3030 | FN(unspec), \ | 3073 | FN(unspec), \ |
| @@ -3151,7 +3194,8 @@ union bpf_attr { · 120 unmodified lines | |||
| 3151 | FN(xdp_output), \ | 3194 | FN(xdp_output), \ |
| 3152 | FN(get_netns_cookie), \ | 3195 | FN(get_netns_cookie), \ |
| 3153 | FN(get_current_ancestor_cgroup_id), \ | 3196 | FN(get_current_ancestor_cgroup_id), \ |
| 3154 | FN(sk_assign), | 3197 | FN(sk_assign), \ |
| 3198 | FN(ktime_get_boot_ns), | ||
| 3155 | 3199 | ||
| 3156 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 3200 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 3157 | * function eBPF program intends to call | 3201 | * function eBPF program intends to call |
| @@ -3598,6 +3642,25 @@ struct bpf_btf_info { · 440 unmodified lines | |||
| 3598 | __u32 id; | 3642 | __u32 id; |
| 3599 | } __attribute__((aligned(8))); | 3643 | } __attribute__((aligned(8))); |
| 3600 | 3644 | ||
| 3645 | struct bpf_link_info { | ||
| 3646 | __u32 type; | ||
| 3647 | __u32 id; | ||
| 3648 | __u32 prog_id; | ||
| 3649 | union { | ||
| 3650 | struct { | ||
| 3651 | __aligned_u64 tp_name; /* in/out: tp_name buffer ptr */ | ||
| 3652 | __u32 tp_name_len; /* in/out: tp_name buffer len */ | ||
| 3653 | } raw_tracepoint; | ||
| 3654 | struct { | ||
| 3655 | __u32 attach_type; | ||
| 3656 | } tracing; | ||
| 3657 | struct { | ||
| 3658 | __u64 cgroup_id; | ||
| 3659 | __u32 attach_type; | ||
| 3660 | } cgroup; | ||
| 3661 | }; | ||
| 3662 | } __attribute__((aligned(8))); | ||
| 3663 | |||
| 3601 | /* User bpf_sock_addr struct to access socket fields and sockaddr struct passed | 3664 | /* User bpf_sock_addr struct to access socket fields and sockaddr struct passed |
| 3602 | * by user and intended to be used by socket (e.g. to bind to, depends on | 3665 | * by user and intended to be used by socket (e.g. to bind to, depends on |
| 3603 | * attach attach type). | 3666 | * attach attach type). |