@@ -356,18 +356,36 @@ enum bpf_link_type {
356356#define BPF_F_SLEEPABLE (1U << 4)
357357
358358/* When BPF ldimm64's insn[0].src_reg != 0 then this can have
359- * two extensions:
360- *
361- * insn[0].src_reg: BPF_PSEUDO_MAP_FD BPF_PSEUDO_MAP_VALUE
362- * insn[0].imm: map fd map fd
363- * insn[1].imm: 0 offset into value
364- * insn[0].off: 0 0
365- * insn[1].off: 0 0
366- * ldimm64 rewrite: address of map address of map[0]+offset
367- * verifier type: CONST_PTR_TO_MAP PTR_TO_MAP_VALUE
359+ * the following extensions:
360+ *
361+ * insn[0].src_reg: BPF_PSEUDO_MAP_FD
362+ * insn[0].imm: map fd
363+ * insn[1].imm: 0
364+ * insn[0].off: 0
365+ * insn[1].off: 0
366+ * ldimm64 rewrite: address of map
367+ * verifier type: CONST_PTR_TO_MAP
368368 */
369369#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+ */
370378#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
371389
372390/* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative
373391 * offset to another bpf function
@@ -417,6 +435,9 @@ enum {
417435
418436/* Share perf_event among processes */
419437 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 ),
420441};
421442
422443/* Flags for BPF_PROG_QUERY. */
@@ -1680,7 +1701,7 @@ union bpf_attr {
16801701 * **TCP_CONGESTION**, **TCP_BPF_IW**,
16811702 * **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**,
16821703 * **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**,
1683- * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**.
1704+ * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT **.
16841705 * * **IPPROTO_IP**, which supports *optname* **IP_TOS**.
16851706 * * **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**.
16861707 * Return
@@ -2235,7 +2256,7 @@ union bpf_attr {
22352256 * Description
22362257 * This helper is used in programs implementing policies at the
22372258 * 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
22392260 * to the socket referenced by *map* (of type
22402261 * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and
22412262 * egress interfaces can be used for redirection. The
@@ -3661,10 +3682,59 @@ union bpf_attr {
36613682 * Redirect the packet to another net device of index *ifindex*
36623683 * and fill in L2 addresses from neighboring subsystem. This helper
36633684 * is somewhat similar to **bpf_redirect**\ (), except that it
3664- * fills in e.g. MAC addresses based on the L3 information from
3665- * the packet. This helper is supported for IPv4 and IPv6 protocols.
3685+ * populates L2 addresses as well, meaning, internally, the helper
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+ *
36663734 * 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.
36683738 * Return
36693739 * The helper returns **TC_ACT_REDIRECT** on success or
36703740 * **TC_ACT_SHOT** on error.
@@ -3823,6 +3893,9 @@ union bpf_attr {
38233893 FN(seq_printf_btf), \
38243894 FN(skb_cgroup_classid), \
38253895 FN(redirect_neigh), \
3896+ FN(bpf_per_cpu_ptr), \
3897+ FN(bpf_this_cpu_ptr), \
3898+ FN(redirect_peer), \
38263899 /* */
38273900
38283901/* integer value in 'imm' field of BPF_CALL instruction selects which helper
0 commit comments