Alexei Starovoitov says: ==================== pull-request: bpf-next 2020-10-12 The main changes are: 1) The BPF verifier improvements to track register allocation pattern, from Alexei and Yonghong. 2) libbpf relocation support for different size load/store, from Andrii. 3) bpf_redirect_peer() helper and support for inner map array with different max_entries, from Daniel. 4) BPF support for per-cpu variables, form Hao. 5) sockmap improvements, from John. ====================
Showing the changes to include/uapi/linux (1 of 73 files). Show all
Unified · Split
| @@ -356,18 +356,36 @@ enum bpf_link_type { · 355 unmodified lines | |||
| 356 | #define BPF_F_SLEEPABLE (1U << 4) | 356 | #define BPF_F_SLEEPABLE (1U << 4) |
| 357 | 357 | ||
| 358 | /* When BPF ldimm64's insn[0].src_reg != 0 then this can have | 358 | /* When BPF ldimm64's insn[0].src_reg != 0 then this can have |
| 359 | * two extensions: | 359 | * the following extensions: |
| 360 | * | 360 | * |
| 361 | * insn[0].src_reg: BPF_PSEUDO_MAP_FD BPF_PSEUDO_MAP_VALUE | 361 | * insn[0].src_reg: BPF_PSEUDO_MAP_FD |
| 362 | * insn[0].imm: map fd map fd | 362 | * insn[0].imm: map fd |
| 363 | * insn[1].imm: 0 offset into value | 363 | * insn[1].imm: 0 |
| 364 | * insn[0].off: 0 0 | 364 | * insn[0].off: 0 |
| 365 | * insn[1].off: 0 0 | 365 | * insn[1].off: 0 |
| 366 | * ldimm64 rewrite: address of map address of map[0]+offset | 366 | * ldimm64 rewrite: address of map |
| 367 | * verifier type: CONST_PTR_TO_MAP PTR_TO_MAP_VALUE | 367 | * verifier type: CONST_PTR_TO_MAP |
| 368 | */ | 368 | */ |
| 369 | #define BPF_PSEUDO_MAP_FD 1 | 369 | #define BPF_PSEUDO_MAP_FD 1 |
| 370 | /* insn[0].src_reg: BPF_PSEUDO_MAP_VALUE | ||
| 371 | * insn[0].imm: map fd | ||
| 372 | * insn[1].imm: offset into value | ||
| 373 | * insn[0].off: 0 | ||
| 374 | * insn[1].off: 0 | ||
| 375 | * ldimm64 rewrite: address of map[0]+offset | ||
| 376 | * verifier type: PTR_TO_MAP_VALUE | ||
| 377 | */ | ||
| 370 | #define BPF_PSEUDO_MAP_VALUE 2 | 378 | #define BPF_PSEUDO_MAP_VALUE 2 |
| 379 | /* insn[0].src_reg: BPF_PSEUDO_BTF_ID | ||
| 380 | * insn[0].imm: kernel btd id of VAR | ||
| 381 | * insn[1].imm: 0 | ||
| 382 | * insn[0].off: 0 | ||
| 383 | * insn[1].off: 0 | ||
| 384 | * ldimm64 rewrite: address of the kernel variable | ||
| 385 | * verifier type: PTR_TO_BTF_ID or PTR_TO_MEM, depending on whether the var | ||
| 386 | * is struct/union. | ||
| 387 | */ | ||
| 388 | #define BPF_PSEUDO_BTF_ID 3 | ||
| 371 | 389 | ||
| 372 | /* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative | 390 | /* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative |
| 373 | * offset to another bpf function | 391 | * offset to another bpf function |
| @@ -417,6 +435,9 @@ enum { · 43 unmodified lines | |||
| 417 | 435 | ||
| 418 | /* Share perf_event among processes */ | 436 | /* Share perf_event among processes */ |
| 419 | BPF_F_PRESERVE_ELEMS = (1U << 11), | 437 | BPF_F_PRESERVE_ELEMS = (1U << 11), |
| 438 | |||
| 439 | /* Create a map that is suitable to be an inner map with dynamic max entries */ | ||
| 440 | BPF_F_INNER_MAP = (1U << 12), | ||
| 420 | }; | 441 | }; |
| 421 | 442 | ||
| 422 | /* Flags for BPF_PROG_QUERY. */ | 443 | /* Flags for BPF_PROG_QUERY. */ |
| @@ -1680,7 +1701,7 @@ union bpf_attr { · 1257 unmodified lines | |||
| 1680 | * **TCP_CONGESTION**, **TCP_BPF_IW**, | 1701 | * **TCP_CONGESTION**, **TCP_BPF_IW**, |
| 1681 | * **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**, | 1702 | * **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**, |
| 1682 | * **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**, | 1703 | * **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**, |
| 1683 | * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**. | 1704 | * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**. |
| 1684 | * * **IPPROTO_IP**, which supports *optname* **IP_TOS**. | 1705 | * * **IPPROTO_IP**, which supports *optname* **IP_TOS**. |
| 1685 | * * **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**. | 1706 | * * **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**. |
| 1686 | * Return | 1707 | * Return |
| @@ -2235,7 +2256,7 @@ union bpf_attr { · 548 unmodified lines | |||
| 2235 | * Description | 2256 | * Description |
| 2236 | * This helper is used in programs implementing policies at the | 2257 | * This helper is used in programs implementing policies at the |
| 2237 | * skb socket level. If the sk_buff *skb* is allowed to pass (i.e. | 2258 | * skb socket level. If the sk_buff *skb* is allowed to pass (i.e. |
| 2238 | * if the verdeict eBPF program returns **SK_PASS**), redirect it | 2259 | * if the verdict eBPF program returns **SK_PASS**), redirect it |
| 2239 | * to the socket referenced by *map* (of type | 2260 | * to the socket referenced by *map* (of type |
| 2240 | * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and | 2261 | * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and |
| 2241 | * egress interfaces can be used for redirection. The | 2262 | * egress interfaces can be used for redirection. The |
| @@ -3661,10 +3682,59 @@ union bpf_attr { · 1419 unmodified lines | |||
| 3661 | * Redirect the packet to another net device of index *ifindex* | 3682 | * Redirect the packet to another net device of index *ifindex* |
| 3662 | * and fill in L2 addresses from neighboring subsystem. This helper | 3683 | * and fill in L2 addresses from neighboring subsystem. This helper |
| 3663 | * is somewhat similar to **bpf_redirect**\ (), except that it | 3684 | * is somewhat similar to **bpf_redirect**\ (), except that it |
| 3664 | * fills in e.g. MAC addresses based on the L3 information from | 3685 | * populates L2 addresses as well, meaning, internally, the helper |
| 3665 | * the packet. This helper is supported for IPv4 and IPv6 protocols. | 3686 | * performs a FIB lookup based on the skb's networking header to |
| 3687 | * get the address of the next hop and then relies on the neighbor | ||
| 3688 | * lookup for the L2 address of the nexthop. | ||
| 3689 | * | ||
| 3690 | * The *flags* argument is reserved and must be 0. The helper is | ||
| 3691 | * currently only supported for tc BPF program types, and enabled | ||
| 3692 | * for IPv4 and IPv6 protocols. | ||
| 3693 | * Return | ||
| 3694 | * The helper returns **TC_ACT_REDIRECT** on success or | ||
| 3695 | * **TC_ACT_SHOT** on error. | ||
| 3696 | * | ||
| 3697 | * void *bpf_per_cpu_ptr(const void *percpu_ptr, u32 cpu) | ||
| 3698 | * Description | ||
| 3699 | * Take a pointer to a percpu ksym, *percpu_ptr*, and return a | ||
| 3700 | * pointer to the percpu kernel variable on *cpu*. A ksym is an | ||
| 3701 | * extern variable decorated with '__ksym'. For ksym, there is a | ||
| 3702 | * global var (either static or global) defined of the same name | ||
| 3703 | * in the kernel. The ksym is percpu if the global var is percpu. | ||
| 3704 | * The returned pointer points to the global percpu var on *cpu*. | ||
| 3705 | * | ||
| 3706 | * bpf_per_cpu_ptr() has the same semantic as per_cpu_ptr() in the | ||
| 3707 | * kernel, except that bpf_per_cpu_ptr() may return NULL. This | ||
| 3708 | * happens if *cpu* is larger than nr_cpu_ids. The caller of | ||
| 3709 | * bpf_per_cpu_ptr() must check the returned value. | ||
| 3710 | * Return | ||
| 3711 | * A pointer pointing to the kernel percpu variable on *cpu*, or | ||
| 3712 | * NULL, if *cpu* is invalid. | ||
| 3713 | * | ||
| 3714 | * void *bpf_this_cpu_ptr(const void *percpu_ptr) | ||
| 3715 | * Description | ||
| 3716 | * Take a pointer to a percpu ksym, *percpu_ptr*, and return a | ||
| 3717 | * pointer to the percpu kernel variable on this cpu. See the | ||
| 3718 | * description of 'ksym' in **bpf_per_cpu_ptr**\ (). | ||
| 3719 | * | ||
| 3720 | * bpf_this_cpu_ptr() has the same semantic as this_cpu_ptr() in | ||
| 3721 | * the kernel. Different from **bpf_per_cpu_ptr**\ (), it would | ||
| 3722 | * never return NULL. | ||
| 3723 | * Return | ||
| 3724 | * A pointer pointing to the kernel percpu variable on this cpu. | ||
| 3725 | * | ||
| 3726 | * long bpf_redirect_peer(u32 ifindex, u64 flags) | ||
| 3727 | * Description | ||
| 3728 | * Redirect the packet to another net device of index *ifindex*. | ||
| 3729 | * This helper is somewhat similar to **bpf_redirect**\ (), except | ||
| 3730 | * that the redirection happens to the *ifindex*' peer device and | ||
| 3731 | * the netns switch takes place from ingress to ingress without | ||
| 3732 | * going through the CPU's backlog queue. | ||
| 3733 | * | ||
| 3666 | * The *flags* argument is reserved and must be 0. The helper is | 3734 | * The *flags* argument is reserved and must be 0. The helper is |
| 3667 | * currently only supported for tc BPF program types. | 3735 | * currently only supported for tc BPF program types at the ingress |
| 3736 | * hook and for veth device types. The peer device must reside in a | ||
| 3737 | * different network namespace. | ||
| 3668 | * Return | 3738 | * Return |
| 3669 | * The helper returns **TC_ACT_REDIRECT** on success or | 3739 | * The helper returns **TC_ACT_REDIRECT** on success or |
| 3670 | * **TC_ACT_SHOT** on error. | 3740 | * **TC_ACT_SHOT** on error. |
| @@ -3823,6 +3893,9 @@ union bpf_attr { · 152 unmodified lines | |||
| 3823 | FN(seq_printf_btf), \ | 3893 | FN(seq_printf_btf), \ |
| 3824 | FN(skb_cgroup_classid), \ | 3894 | FN(skb_cgroup_classid), \ |
| 3825 | FN(redirect_neigh), \ | 3895 | FN(redirect_neigh), \ |
| 3896 | FN(bpf_per_cpu_ptr), \ | ||
| 3897 | FN(bpf_this_cpu_ptr), \ | ||
| 3898 | FN(redirect_peer), \ | ||
| 3826 | /* */ | 3899 | /* */ |
| 3827 | 3900 | ||
| 3828 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 3901 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |