History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

Pull networking updates from David Miller: 1) Allow setting bluetooth L2CAP modes via socket option, from Luiz Augusto von Dentz. 2) Add GSO partial support to igc, from Sasha Neftin. 3) Several cleanups and improvements to r8169 from Heiner Kallweit. 4) Add IF_OPER_TESTING link state and use it when ethtool triggers a device self-test. From Andrew Lunn. 5) Start moving away from custom driver versions, use the globally defined kernel version instead, from Leon Romanovsky. 6) Support GRO vis gro_cells in DSA layer, from Alexander Lobakin. 7) Allow hard IRQ deferral during NAPI, from Eric Dumazet. 8) Add sriov and vf support to hinic, from Luo bin. 9) Support Media Redundancy Protocol (MRP) in the bridging code, from Horatiu Vultur. 10) Support netmap in the nft_nat code, from Pablo Neira Ayuso. 11) Allow UDPv6 encapsulation of ESP in the ipsec code, from Sabrina Dubroca. Also add ipv6 support for espintcp. 12) Lots of ReST conversions of the networking documentation, from Mauro Carvalho Chehab. 13) Support configuration of ethtool rxnfc flows in bcmgenet driver, from Doug Berger. 14) Allow to dump cgroup id and filter by it in inet_diag code, from Dmitry Yakunin. 15) Add infrastructure to export netlink attribute policies to userspace, from Johannes Berg. 16) Several optimizations to sch_fq scheduler, from Eric Dumazet. 17) Fallback to the default qdisc if qdisc init fails because otherwise a packet scheduler init failure will make a device inoperative. From Jesper Dangaard Brouer. 18) Several RISCV bpf jit optimizations, from Luke Nelson. 19) Correct the return type of the ->ndo_start_xmit() method in several drivers, it's netdev_tx_t but many drivers were using 'int'. From Yunjian Wang. 20) Add an ethtool interface for PHY master/slave config, from Oleksij Rempel. 21) Add BPF iterators, from Yonghang Song. 22) Add cable test infrastructure, including ethool interfaces, from Andrew Lunn. Marvell PHY driver is the first to support this facility. 23) Remove zero-length arrays all over, from Gustavo A. R. Silva. 24) Calculate and maintain an explicit frame size in XDP, from Jesper Dangaard Brouer. 25) Add CAP_BPF, from Alexei Starovoitov. 26) Support terse dumps in the packet scheduler, from Vlad Buslov. 27) Support XDP_TX bulking in dpaa2 driver, from Ioana Ciornei. 28) Add devm_register_netdev(), from Bartosz Golaszewski. 29) Minimize qdisc resets, from Cong Wang. 30) Get rid of kernel_getsockopt and kernel_setsockopt in order to eliminate set_fs/get_fs calls. From Christoph Hellwig. * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (2517 commits) selftests: net: ip_defrag: ignore EPERM net_failover: fixed rollback in net_failover_open() Revert "tipc: Fix potential tipc_aead refcnt leak in tipc_crypto_rcv" Revert "tipc: Fix potential tipc_node refcnt leak in tipc_rcv" vmxnet3: allow rx flow hash ops only when rss is enabled hinic: add set_channels ethtool_ops support selftests/bpf: Add a default $(CXX) value tools/bpf: Don't use $(COMPILE.c) bpf, selftests: Use bpf_probe_read_kernel s390/bpf: Use bcr 0,%0 as tail call nop filler s390/bpf: Maintain 8-byte stack alignment selftests/bpf: Fix verifier test selftests/bpf: Fix sample_cnt shared between two threads bpf, selftests: Adapt cls_redirect to call csum_level helper bpf: Add csum_level helper for fixing up csum levels bpf: Fix up bpf_skb_adjust_room helper's skb csum setting sfc: add missing annotation for efx_ef10_try_update_nic_stats_vf() crypto/chtls: IPv6 support for inline TLS Crypto/chcr: Fixes a coccinile check error Crypto/chcr: Fixes compilations warnings ...

Linus Torvalds committed 6 years ago

Commit cb8e59c2 parents 2e63f6c 065fcfd2097 files · +151766 −46213Browse files

Showing the changes to tools/include/uapi (2 of 2097 files). Show all

Unified · Split

2 files
  1. tools/include/uapi/linux/bpf.h +344 −46
  2. tools/include/uapi/linux/if_link.h +1 −0
tools/include/uapi/linux/bpf.h+344−46
@@ -73,7 +73,7 @@ struct bpf_insn { · 72 unmodified lines
73/* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */73/* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
74struct bpf_lpm_trie_key {74struct bpf_lpm_trie_key {
75 __u32 prefixlen; /* up to 32 for AF_INET, 128 for AF_INET6 */75 __u32 prefixlen; /* up to 32 for AF_INET, 128 for AF_INET6 */
76 __u8 data[]; /* Arbitrary size */76 __u8 data[0]; /* Arbitrary size */
77};77};
78 78
79struct bpf_cgroup_storage_key {79struct bpf_cgroup_storage_key {
@@ -113,6 +113,10 @@ enum bpf_cmd { · 33 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,
119 BPF_ITER_CREATE,
116};120};
117 121
118enum bpf_map_type {122enum bpf_map_type {
@@ -143,6 +147,7 @@ enum bpf_map_type { · 24 unmodified lines
143 BPF_MAP_TYPE_SK_STORAGE,147 BPF_MAP_TYPE_SK_STORAGE,
144 BPF_MAP_TYPE_DEVMAP_HASH,148 BPF_MAP_TYPE_DEVMAP_HASH,
145 BPF_MAP_TYPE_STRUCT_OPS,149 BPF_MAP_TYPE_STRUCT_OPS,
150 BPF_MAP_TYPE_RINGBUF,
146};151};
147 152
148/* Note that tracing related programs such as153/* Note that tracing related programs such as
@@ -215,11 +220,28 @@ enum bpf_attach_type { · 66 unmodified lines
215 BPF_TRACE_FEXIT,220 BPF_TRACE_FEXIT,
216 BPF_MODIFY_RETURN,221 BPF_MODIFY_RETURN,
217 BPF_LSM_MAC,222 BPF_LSM_MAC,
223 BPF_TRACE_ITER,
224 BPF_CGROUP_INET4_GETPEERNAME,
225 BPF_CGROUP_INET6_GETPEERNAME,
226 BPF_CGROUP_INET4_GETSOCKNAME,
227 BPF_CGROUP_INET6_GETSOCKNAME,
228 BPF_XDP_DEVMAP,
218 __MAX_BPF_ATTACH_TYPE229 __MAX_BPF_ATTACH_TYPE
219};230};
220 231
221#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE232#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
222 233
234enum bpf_link_type {
235 BPF_LINK_TYPE_UNSPEC = 0,
236 BPF_LINK_TYPE_RAW_TRACEPOINT = 1,
237 BPF_LINK_TYPE_TRACING = 2,
238 BPF_LINK_TYPE_CGROUP = 3,
239 BPF_LINK_TYPE_ITER = 4,
240 BPF_LINK_TYPE_NETNS = 5,
241
242 MAX_BPF_LINK_TYPE,
243};
244
223/* cgroup-bpf attach flags used in BPF_PROG_ATTACH command245/* cgroup-bpf attach flags used in BPF_PROG_ATTACH command
224 *246 *
225 * NONE(default): No further bpf programs allowed in the subtree.247 * NONE(default): No further bpf programs allowed in the subtree.
@@ -379,6 +401,12 @@ enum { · 153 unmodified lines
379 */401 */
380#define BPF_F_QUERY_EFFECTIVE (1U << 0)402#define BPF_F_QUERY_EFFECTIVE (1U << 0)
381 403
404/* type for BPF_ENABLE_STATS */
405enum bpf_stats_type {
406 /* enabled run_time_ns and run_cnt */
407 BPF_STATS_RUN_TIME = 0,
408};
409
382enum bpf_stack_build_id_status {410enum bpf_stack_build_id_status {
383 /* user space need an empty entry to identify end of a trace */411 /* user space need an empty entry to identify end of a trace */
384 BPF_STACK_BUILD_ID_EMPTY = 0,412 BPF_STACK_BUILD_ID_EMPTY = 0,
@@ -523,6 +551,7 @@ union bpf_attr { · 138 unmodified lines
523 __u32 prog_id;551 __u32 prog_id;
524 __u32 map_id;552 __u32 map_id;
525 __u32 btf_id;553 __u32 btf_id;
554 __u32 link_id;
526 };555 };
527 __u32 next_id;556 __u32 next_id;
528 __u32 open_flags;557 __u32 open_flags;
@@ -589,6 +618,15 @@ union bpf_attr { · 60 unmodified lines
589 __u32 old_prog_fd;618 __u32 old_prog_fd;
590 } link_update;619 } link_update;
591 620
621 struct { /* struct used by BPF_ENABLE_STATS command */
622 __u32 type;
623 } enable_stats;
624
625 struct { /* struct used by BPF_ITER_CREATE command */
626 __u32 link_fd;
627 __u32 flags;
628 } iter_create;
629
592} __attribute__((aligned(8)));630} __attribute__((aligned(8)));
593 631
594/* The description below is an attempt at providing documentation to eBPF632/* The description below is an attempt at providing documentation to eBPF
@@ -644,14 +682,16 @@ union bpf_attr { · 49 unmodified lines
644 * For tracing programs, safely attempt to read *size* bytes from682 * For tracing programs, safely attempt to read *size* bytes from
645 * kernel space address *unsafe_ptr* and store the data in *dst*.683 * kernel space address *unsafe_ptr* and store the data in *dst*.
646 *684 *
647 * Generally, use bpf_probe_read_user() or bpf_probe_read_kernel()685 * Generally, use **bpf_probe_read_user**\ () or
648 * instead.686 * **bpf_probe_read_kernel**\ () instead.
649 * Return687 * Return
650 * 0 on success, or a negative error in case of failure.688 * 0 on success, or a negative error in case of failure.
651 *689 *
652 * u64 bpf_ktime_get_ns(void)690 * u64 bpf_ktime_get_ns(void)
653 * Description691 * Description
654 * Return the time elapsed since system boot, in nanoseconds.692 * Return the time elapsed since system boot, in nanoseconds.
693 * Does not include time the system was suspended.
694 * See: **clock_gettime**\ (**CLOCK_MONOTONIC**)
655 * Return695 * Return
656 * Current *ktime*.696 * Current *ktime*.
657 *697 *
@@ -1510,11 +1550,11 @@ union bpf_attr { · 852 unmodified lines
1510 * int bpf_probe_read_str(void *dst, u32 size, const void *unsafe_ptr)1550 * int bpf_probe_read_str(void *dst, u32 size, const void *unsafe_ptr)
1511 * Description1551 * Description
1512 * Copy a NUL terminated string from an unsafe kernel address1552 * Copy a NUL terminated string from an unsafe kernel address
1513 * *unsafe_ptr* to *dst*. See bpf_probe_read_kernel_str() for1553 * *unsafe_ptr* to *dst*. See **bpf_probe_read_kernel_str**\ () for
1514 * more details.1554 * more details.
1515 *1555 *
1516 * Generally, use bpf_probe_read_user_str() or bpf_probe_read_kernel_str()1556 * Generally, use **bpf_probe_read_user_str**\ () or
1517 * instead.1557 * **bpf_probe_read_kernel_str**\ () instead.
1518 * Return1558 * Return
1519 * On success, the strictly positive length of the string,1559 * On success, the strictly positive length of the string,
1520 * including the trailing NUL character. On error, a negative1560 * including the trailing NUL character. On error, a negative
@@ -1542,7 +1582,7 @@ union bpf_attr { · 21 unmodified lines
1542 *1582 *
1543 * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx)1583 * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx)
1544 * Description1584 * Description
1545 * Equivalent to bpf_get_socket_cookie() helper that accepts1585 * Equivalent to **bpf_get_socket_cookie**\ () helper that accepts
1546 * *skb*, but gets socket from **struct bpf_sock_ops** context.1586 * *skb*, but gets socket from **struct bpf_sock_ops** context.
1547 * Return1587 * Return
1548 * A 8-byte long non-decreasing number.1588 * A 8-byte long non-decreasing number.
@@ -1562,7 +1602,7 @@ union bpf_attr { · 13 unmodified lines
1562 * Return1602 * Return
1563 * 01603 * 0
1564 *1604 *
1565 * int bpf_setsockopt(struct bpf_sock_ops *bpf_socket, int level, int optname, void *optval, int optlen)1605 * int bpf_setsockopt(void *bpf_socket, int level, int optname, void *optval, int optlen)
1566 * Description1606 * Description
1567 * Emulate a call to **setsockopt()** on the socket associated to1607 * Emulate a call to **setsockopt()** on the socket associated to
1568 * *bpf_socket*, which must be a full socket. The *level* at1608 * *bpf_socket*, which must be a full socket. The *level* at
@@ -1570,6 +1610,12 @@ union bpf_attr { · 1 unmodified line
1570 * must be specified, see **setsockopt(2)** for more information.1610 * must be specified, see **setsockopt(2)** for more information.
1571 * The option value of length *optlen* is pointed by *optval*.1611 * The option value of length *optlen* is pointed by *optval*.
1572 *1612 *
1613 * *bpf_socket* should be one of the following:
1614 *
1615 * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**.
1616 * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT**
1617 * and **BPF_CGROUP_INET6_CONNECT**.
1618 *
1573 * This helper actually implements a subset of **setsockopt()**.1619 * This helper actually implements a subset of **setsockopt()**.
1574 * It supports the following *level*\ s:1620 * It supports the following *level*\ s:
1575 *1621 *
@@ -1589,6 +1635,13 @@ union bpf_attr { · 13 unmodified lines
1589 * Grow or shrink the room for data in the packet associated to1635 * Grow or shrink the room for data in the packet associated to
1590 * *skb* by *len_diff*, and according to the selected *mode*.1636 * *skb* by *len_diff*, and according to the selected *mode*.
1591 *1637 *
1638 * By default, the helper will reset any offloaded checksum
1639 * indicator of the skb to CHECKSUM_NONE. This can be avoided
1640 * by the following flag:
1641 *
1642 * * **BPF_F_ADJ_ROOM_NO_CSUM_RESET**: Do not reset offloaded
1643 * checksum data of the skb to CHECKSUM_NONE.
1644 *
1592 * There are two supported modes at this time:1645 * There are two supported modes at this time:
1593 *1646 *
1594 * * **BPF_ADJ_ROOM_MAC**: Adjust room at the mac layer1647 * * **BPF_ADJ_ROOM_MAC**: Adjust room at the mac layer
@@ -1634,12 +1687,12 @@ union bpf_attr { · 39 unmodified lines
1634 *1687 *
1635 * The lower two bits of *flags* are used as the return code if1688 * The lower two bits of *flags* are used as the return code if
1636 * the map lookup fails. This is so that the return value can be1689 * the map lookup fails. This is so that the return value can be
1637 * one of the XDP program return codes up to XDP_TX, as chosen by1690 * one of the XDP program return codes up to **XDP_TX**, as chosen
1638 * the caller. Any higher bits in the *flags* argument must be1691 * by the caller. Any higher bits in the *flags* argument must be
1639 * unset.1692 * unset.
1640 *1693 *
1641 * See also bpf_redirect(), which only supports redirecting to an1694 * See also **bpf_redirect**\ (), which only supports redirecting
1642 * ifindex, but doesn't require a map to do so.1695 * to an ifindex, but doesn't require a map to do so.
1643 * Return1696 * Return
1644 * **XDP_REDIRECT** on success, or the value of the two lower bits1697 * **XDP_REDIRECT** on success, or the value of the two lower bits
1645 * of the *flags* argument on error.1698 * of the *flags* argument on error.
@@ -1747,7 +1800,7 @@ union bpf_attr { · 101 unmodified lines
1747 * the time running for event since last normalization. The1800 * the time running for event since last normalization. The
1748 * enabled and running times are accumulated since the perf event1801 * enabled and running times are accumulated since the perf event
1749 * open. To achieve scaling factor between two invocations of an1802 * open. To achieve scaling factor between two invocations of an
1750 * eBPF program, users can can use CPU id as the key (which is1803 * eBPF program, users can use CPU id as the key (which is
1751 * typical for perf array usage model) to remember the previous1804 * typical for perf array usage model) to remember the previous
1752 * value and do the calculation inside the eBPF program.1805 * value and do the calculation inside the eBPF program.
1753 * Return1806 * Return
@@ -1764,7 +1817,7 @@ union bpf_attr { · 10 unmodified lines
1764 * Return1817 * Return
1765 * 0 on success, or a negative error in case of failure.1818 * 0 on success, or a negative error in case of failure.
1766 *1819 *
1767 * int bpf_getsockopt(struct bpf_sock_ops *bpf_socket, int level, int optname, void *optval, int optlen)1820 * int bpf_getsockopt(void *bpf_socket, int level, int optname, void *optval, int optlen)
1768 * Description1821 * Description
1769 * Emulate a call to **getsockopt()** on the socket associated to1822 * Emulate a call to **getsockopt()** on the socket associated to
1770 * *bpf_socket*, which must be a full socket. The *level* at1823 * *bpf_socket*, which must be a full socket. The *level* at
@@ -1773,6 +1826,12 @@ union bpf_attr { · 2 unmodified lines
1773 * The retrieved value is stored in the structure pointed by1826 * The retrieved value is stored in the structure pointed by
1774 * *opval* and of length *optlen*.1827 * *opval* and of length *optlen*.
1775 *1828 *
1829 * *bpf_socket* should be one of the following:
1830 *
1831 * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**.
1832 * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT**
1833 * and **BPF_CGROUP_INET6_CONNECT**.
1834 *
1776 * This helper actually implements a subset of **getsockopt()**.1835 * This helper actually implements a subset of **getsockopt()**.
1777 * It supports the following *level*\ s:1836 * It supports the following *level*\ s:
1778 *1837 *
@@ -1790,7 +1849,7 @@ union bpf_attr { · 11 unmodified lines
1790 * The first argument is the context *regs* on which the kprobe1849 * The first argument is the context *regs* on which the kprobe
1791 * works.1850 * works.
1792 *1851 *
1793 * This helper works by setting setting the PC (program counter)1852 * This helper works by setting the PC (program counter)
1794 * to an override function which is run in place of the original1853 * to an override function which is run in place of the original
1795 * probed function. This means the probed function is not run at1854 * probed function. This means the probed function is not run at
1796 * all. The replacement function just returns with the required1855 * all. The replacement function just returns with the required
@@ -1959,18 +2018,19 @@ union bpf_attr { · 162 unmodified lines
1959 *2018 *
1960 * This helper works for IPv4 and IPv6, TCP and UDP sockets. The2019 * This helper works for IPv4 and IPv6, TCP and UDP sockets. The
1961 * domain (*addr*\ **->sa_family**) must be **AF_INET** (or2020 * domain (*addr*\ **->sa_family**) must be **AF_INET** (or
1962 * **AF_INET6**). Looking for a free port to bind to can be2021 * **AF_INET6**). It's advised to pass zero port (**sin_port**
1963 * expensive, therefore binding to port is not permitted by the2022 * or **sin6_port**) which triggers IP_BIND_ADDRESS_NO_PORT-like
1964 * helper: *addr*\ **->sin_port** (or **sin6_port**, respectively)2023 * behavior and lets the kernel efficiently pick up an unused
1965 * must be set to zero.2024 * port as long as 4-tuple is unique. Passing non-zero port might
2025 * lead to degraded performance.
1966 * Return2026 * Return
1967 * 0 on success, or a negative error in case of failure.2027 * 0 on success, or a negative error in case of failure.
1968 *2028 *
1969 * int bpf_xdp_adjust_tail(struct xdp_buff *xdp_md, int delta)2029 * int bpf_xdp_adjust_tail(struct xdp_buff *xdp_md, int delta)
1970 * Description2030 * Description
1971 * Adjust (move) *xdp_md*\ **->data_end** by *delta* bytes. It is2031 * Adjust (move) *xdp_md*\ **->data_end** by *delta* bytes. It is
1972 * only possible to shrink the packet as of this writing,2032 * possible to both shrink and grow the packet tail.
1973 * therefore *delta* must be a negative integer.2033 * Shrink done via *delta* being a negative integer.
1974 *2034 *
1975 * A call to this helper is susceptible to change the underlying2035 * A call to this helper is susceptible to change the underlying
1976 * packet buffer. Therefore, at load time, all checks on pointers2036 * packet buffer. Therefore, at load time, all checks on pointers
@@ -2256,7 +2316,7 @@ union bpf_attr { · 279 unmodified lines
2256 * **bpf_rc_keydown**\ () again with the same values, or calling2316 * **bpf_rc_keydown**\ () again with the same values, or calling
2257 * **bpf_rc_repeat**\ ().2317 * **bpf_rc_repeat**\ ().
2258 *2318 *
2259 * Some protocols include a toggle bit, in case the button was2319 * Some protocols include a toggle bit, in case the button was
2260 * released and pressed again between consecutive scancodes.2320 * released and pressed again between consecutive scancodes.
2261 *2321 *
2262 * The *ctx* should point to the lirc sample as passed into2322 * The *ctx* should point to the lirc sample as passed into
@@ -2602,7 +2662,6 @@ union bpf_attr { · 339 unmodified lines
2602 *2662 *
2603 * *th* points to the start of the TCP header, while *th_len*2663 * *th* points to the start of the TCP header, while *th_len*
2604 * contains **sizeof**\ (**struct tcphdr**).2664 * contains **sizeof**\ (**struct tcphdr**).
2605 *
2606 * Return2665 * Return
2607 * 0 if *iph* and *th* are a valid SYN cookie ACK, or a negative2666 * 0 if *iph* and *th* are a valid SYN cookie ACK, or a negative
2608 * error otherwise.2667 * error otherwise.
@@ -2785,7 +2844,6 @@ union bpf_attr { · 176 unmodified lines
2785 *2844 *
2786 * *th* points to the start of the TCP header, while *th_len*2845 * *th* points to the start of the TCP header, while *th_len*
2787 * contains the length of the TCP header.2846 * contains the length of the TCP header.
2788 *
2789 * Return2847 * Return
2790 * On success, lower 32 bits hold the generated SYN cookie in2848 * On success, lower 32 bits hold the generated SYN cookie in
2791 * followed by 16 bits which hold the MSS value for that cookie,2849 * followed by 16 bits which hold the MSS value for that cookie,
@@ -2868,7 +2926,7 @@ union bpf_attr { · 76 unmodified lines
2868 * // size, after checking its boundaries.2926 * // size, after checking its boundaries.
2869 * }2927 * }
2870 *2928 *
2871 * In comparison, using **bpf_probe_read_user()** helper here2929 * In comparison, using **bpf_probe_read_user**\ () helper here
2872 * instead to read the string would require to estimate the length2930 * instead to read the string would require to estimate the length
2873 * at compile time, and would often result in copying more memory2931 * at compile time, and would often result in copying more memory
2874 * than necessary.2932 * than necessary.
@@ -2886,14 +2944,14 @@ union bpf_attr { · 11 unmodified lines
2886 * int bpf_probe_read_kernel_str(void *dst, u32 size, const void *unsafe_ptr)2944 * int bpf_probe_read_kernel_str(void *dst, u32 size, const void *unsafe_ptr)
2887 * Description2945 * Description
2888 * Copy a NUL terminated string from an unsafe kernel address *unsafe_ptr*2946 * Copy a NUL terminated string from an unsafe kernel address *unsafe_ptr*
2889 * to *dst*. Same semantics as with bpf_probe_read_user_str() apply.2947 * to *dst*. Same semantics as with **bpf_probe_read_user_str**\ () apply.
2890 * Return2948 * Return
2891 * On success, the strictly positive length of the string, including2949 * On success, the strictly positive length of the string, including
2892 * the trailing NUL character. On error, a negative value.2950 * the trailing NUL character. On error, a negative value.
2893 *2951 *
2894 * int bpf_tcp_send_ack(void *tp, u32 rcv_nxt)2952 * int bpf_tcp_send_ack(void *tp, u32 rcv_nxt)
2895 * Description2953 * Description
2896 * Send out a tcp-ack. *tp* is the in-kernel struct tcp_sock.2954 * Send out a tcp-ack. *tp* is the in-kernel struct **tcp_sock**.
2897 * *rcv_nxt* is the ack_seq to be sent out.2955 * *rcv_nxt* is the ack_seq to be sent out.
2898 * Return2956 * Return
2899 * 0 on success, or a negative error in case of failure.2957 * 0 on success, or a negative error in case of failure.
@@ -2921,19 +2979,19 @@ union bpf_attr { · 21 unmodified lines
2921 * int bpf_read_branch_records(struct bpf_perf_event_data *ctx, void *buf, u32 size, u64 flags)2979 * int bpf_read_branch_records(struct bpf_perf_event_data *ctx, void *buf, u32 size, u64 flags)
2922 * Description2980 * Description
2923 * For an eBPF program attached to a perf event, retrieve the2981 * For an eBPF program attached to a perf event, retrieve the
2924 * branch records (struct perf_branch_entry) associated to *ctx*2982 * branch records (**struct perf_branch_entry**) associated to *ctx*
2925 * and store it in the buffer pointed by *buf* up to size2983 * and store it in the buffer pointed by *buf* up to size
2926 * *size* bytes.2984 * *size* bytes.
2927 * Return2985 * Return
2928 * On success, number of bytes written to *buf*. On error, a2986 * On success, number of bytes written to *buf*. On error, a
2929 * negative value.2987 * negative value.
2930 *2988 *
2931 * The *flags* can be set to **BPF_F_GET_BRANCH_RECORDS_SIZE** to2989 * The *flags* can be set to **BPF_F_GET_BRANCH_RECORDS_SIZE** to
2932 * instead return the number of bytes required to store all the2990 * instead return the number of bytes required to store all the
2933 * branch entries. If this flag is set, *buf* may be NULL.2991 * branch entries. If this flag is set, *buf* may be NULL.
2934 *2992 *
2935 * **-EINVAL** if arguments invalid or **size** not a multiple2993 * **-EINVAL** if arguments invalid or **size** not a multiple
2936 * of sizeof(struct perf_branch_entry).2994 * of **sizeof**\ (**struct perf_branch_entry**\ ).
2937 *2995 *
2938 * **-ENOENT** if architecture does not support branch records.2996 * **-ENOENT** if architecture does not support branch records.
2939 *2997 *
@@ -2941,8 +2999,8 @@ union bpf_attr { · 1 unmodified line
2941 * Description2999 * Description
2942 * Returns 0 on success, values for *pid* and *tgid* as seen from the current3000 * Returns 0 on success, values for *pid* and *tgid* as seen from the current
2943 * *namespace* will be returned in *nsdata*.3001 * *namespace* will be returned in *nsdata*.
2944 *3002 * Return
2945 * On failure, the returned value is one of the following:3003 * 0 on success, or one of the following in case of failure:
2946 *3004 *
2947 * **-EINVAL** if dev and inum supplied don't match dev_t and inode number3005 * **-EINVAL** if dev and inum supplied don't match dev_t and inode number
2948 * with nsfs of current task, or if dev conversion to dev_t lost high bits.3006 * with nsfs of current task, or if dev conversion to dev_t lost high bits.
@@ -2981,8 +3039,8 @@ union bpf_attr { · 32 unmodified lines
2981 * a global identifier that can be assumed unique. If *ctx* is3039 * a global identifier that can be assumed unique. If *ctx* is
2982 * NULL, then the helper returns the cookie for the initial3040 * NULL, then the helper returns the cookie for the initial
2983 * network namespace. The cookie itself is very similar to that3041 * network namespace. The cookie itself is very similar to that
2984 * of bpf_get_socket_cookie() helper, but for network namespaces3042 * of **bpf_get_socket_cookie**\ () helper, but for network
2985 * instead of sockets.3043 * namespaces instead of sockets.
2986 * Return3044 * Return
2987 * A 8-byte long opaque number.3045 * A 8-byte long opaque number.
2988 *3046 *
@@ -3017,14 +3075,183 @@ union bpf_attr { · 28 unmodified lines
3017 *3075 *
3018 * The *flags* argument must be zero.3076 * The *flags* argument must be zero.
3019 * Return3077 * Return
3020 * 0 on success, or a negative errno in case of failure.3078 * 0 on success, or a negative error in case of failure:
3021 *3079 *
3022 * * **-EINVAL** Unsupported flags specified.3080 * **-EINVAL** if specified *flags* are not supported.
3023 * * **-ENOENT** Socket is unavailable for assignment.3081 *
3024 * * **-ENETUNREACH** Socket is unreachable (wrong netns).3082 * **-ENOENT** if the socket is unavailable for assignment.
3025 * * **-EOPNOTSUPP** Unsupported operation, for example a3083 *
3026 * call from outside of TC ingress.3084 * **-ENETUNREACH** if the socket is unreachable (wrong netns).
3027 * * **-ESOCKTNOSUPPORT** Socket type not supported (reuseport).3085 *
3086 * **-EOPNOTSUPP** if the operation is not supported, for example
3087 * a call from outside of TC ingress.
3088 *
3089 * **-ESOCKTNOSUPPORT** if the socket type is not supported
3090 * (reuseport).
3091 *
3092 * u64 bpf_ktime_get_boot_ns(void)
3093 * Description
3094 * Return the time elapsed since system boot, in nanoseconds.
3095 * Does include the time the system was suspended.
3096 * See: **clock_gettime**\ (**CLOCK_BOOTTIME**)
3097 * Return
3098 * Current *ktime*.
3099 *
3100 * int bpf_seq_printf(struct seq_file *m, const char *fmt, u32 fmt_size, const void *data, u32 data_len)
3101 * Description
3102 * **bpf_seq_printf**\ () uses seq_file **seq_printf**\ () to print
3103 * out the format string.
3104 * The *m* represents the seq_file. The *fmt* and *fmt_size* are for
3105 * the format string itself. The *data* and *data_len* are format string
3106 * arguments. The *data* are a **u64** array and corresponding format string
3107 * values are stored in the array. For strings and pointers where pointees
3108 * are accessed, only the pointer values are stored in the *data* array.
3109 * The *data_len* is the size of *data* in bytes.
3110 *
3111 * Formats **%s**, **%p{i,I}{4,6}** requires to read kernel memory.
3112 * Reading kernel memory may fail due to either invalid address or
3113 * valid address but requiring a major memory fault. If reading kernel memory
3114 * fails, the string for **%s** will be an empty string, and the ip
3115 * address for **%p{i,I}{4,6}** will be 0. Not returning error to
3116 * bpf program is consistent with what **bpf_trace_printk**\ () does for now.
3117 * Return
3118 * 0 on success, or a negative error in case of failure:
3119 *
3120 * **-EBUSY** if per-CPU memory copy buffer is busy, can try again
3121 * by returning 1 from bpf program.
3122 *
3123 * **-EINVAL** if arguments are invalid, or if *fmt* is invalid/unsupported.
3124 *
3125 * **-E2BIG** if *fmt* contains too many format specifiers.
3126 *
3127 * **-EOVERFLOW** if an overflow happened: The same object will be tried again.
3128 *
3129 * int bpf_seq_write(struct seq_file *m, const void *data, u32 len)
3130 * Description
3131 * **bpf_seq_write**\ () uses seq_file **seq_write**\ () to write the data.
3132 * The *m* represents the seq_file. The *data* and *len* represent the
3133 * data to write in bytes.
3134 * Return
3135 * 0 on success, or a negative error in case of failure:
3136 *
3137 * **-EOVERFLOW** if an overflow happened: The same object will be tried again.
3138 *
3139 * u64 bpf_sk_cgroup_id(struct bpf_sock *sk)
3140 * Description
3141 * Return the cgroup v2 id of the socket *sk*.
3142 *
3143 * *sk* must be a non-**NULL** pointer to a full socket, e.g. one
3144 * returned from **bpf_sk_lookup_xxx**\ (),
3145 * **bpf_sk_fullsock**\ (), etc. The format of returned id is
3146 * same as in **bpf_skb_cgroup_id**\ ().
3147 *
3148 * This helper is available only if the kernel was compiled with
3149 * the **CONFIG_SOCK_CGROUP_DATA** configuration option.
3150 * Return
3151 * The id is returned or 0 in case the id could not be retrieved.
3152 *
3153 * u64 bpf_sk_ancestor_cgroup_id(struct bpf_sock *sk, int ancestor_level)
3154 * Description
3155 * Return id of cgroup v2 that is ancestor of cgroup associated
3156 * with the *sk* at the *ancestor_level*. The root cgroup is at
3157 * *ancestor_level* zero and each step down the hierarchy
3158 * increments the level. If *ancestor_level* == level of cgroup
3159 * associated with *sk*, then return value will be same as that
3160 * of **bpf_sk_cgroup_id**\ ().
3161 *
3162 * The helper is useful to implement policies based on cgroups
3163 * that are upper in hierarchy than immediate cgroup associated
3164 * with *sk*.
3165 *
3166 * The format of returned id and helper limitations are same as in
3167 * **bpf_sk_cgroup_id**\ ().
3168 * Return
3169 * The id is returned or 0 in case the id could not be retrieved.
3170 *
3171 * void *bpf_ringbuf_output(void *ringbuf, void *data, u64 size, u64 flags)
3172 * Description
3173 * Copy *size* bytes from *data* into a ring buffer *ringbuf*.
3174 * If BPF_RB_NO_WAKEUP is specified in *flags*, no notification of
3175 * new data availability is sent.
3176 * IF BPF_RB_FORCE_WAKEUP is specified in *flags*, notification of
3177 * new data availability is sent unconditionally.
3178 * Return
3179 * 0, on success;
3180 * < 0, on error.
3181 *
3182 * void *bpf_ringbuf_reserve(void *ringbuf, u64 size, u64 flags)
3183 * Description
3184 * Reserve *size* bytes of payload in a ring buffer *ringbuf*.
3185 * Return
3186 * Valid pointer with *size* bytes of memory available; NULL,
3187 * otherwise.
3188 *
3189 * void bpf_ringbuf_submit(void *data, u64 flags)
3190 * Description
3191 * Submit reserved ring buffer sample, pointed to by *data*.
3192 * If BPF_RB_NO_WAKEUP is specified in *flags*, no notification of
3193 * new data availability is sent.
3194 * IF BPF_RB_FORCE_WAKEUP is specified in *flags*, notification of
3195 * new data availability is sent unconditionally.
3196 * Return
3197 * Nothing. Always succeeds.
3198 *
3199 * void bpf_ringbuf_discard(void *data, u64 flags)
3200 * Description
3201 * Discard reserved ring buffer sample, pointed to by *data*.
3202 * If BPF_RB_NO_WAKEUP is specified in *flags*, no notification of
3203 * new data availability is sent.
3204 * IF BPF_RB_FORCE_WAKEUP is specified in *flags*, notification of
3205 * new data availability is sent unconditionally.
3206 * Return
3207 * Nothing. Always succeeds.
3208 *
3209 * u64 bpf_ringbuf_query(void *ringbuf, u64 flags)
3210 * Description
3211 * Query various characteristics of provided ring buffer. What
3212 * exactly is queries is determined by *flags*:
3213 * - BPF_RB_AVAIL_DATA - amount of data not yet consumed;
3214 * - BPF_RB_RING_SIZE - the size of ring buffer;
3215 * - BPF_RB_CONS_POS - consumer position (can wrap around);
3216 * - BPF_RB_PROD_POS - producer(s) position (can wrap around);
3217 * Data returned is just a momentary snapshots of actual values
3218 * and could be inaccurate, so this facility should be used to
3219 * power heuristics and for reporting, not to make 100% correct
3220 * calculation.
3221 * Return
3222 * Requested value, or 0, if flags are not recognized.
3223 *
3224 * int bpf_csum_level(struct sk_buff *skb, u64 level)
3225 * Description
3226 * Change the skbs checksum level by one layer up or down, or
3227 * reset it entirely to none in order to have the stack perform
3228 * checksum validation. The level is applicable to the following
3229 * protocols: TCP, UDP, GRE, SCTP, FCOE. For example, a decap of
3230 * | ETH | IP | UDP | GUE | IP | TCP | into | ETH | IP | TCP |
3231 * through **bpf_skb_adjust_room**\ () helper with passing in
3232 * **BPF_F_ADJ_ROOM_NO_CSUM_RESET** flag would require one call
3233 * to **bpf_csum_level**\ () with **BPF_CSUM_LEVEL_DEC** since
3234 * the UDP header is removed. Similarly, an encap of the latter
3235 * into the former could be accompanied by a helper call to
3236 * **bpf_csum_level**\ () with **BPF_CSUM_LEVEL_INC** if the
3237 * skb is still intended to be processed in higher layers of the
3238 * stack instead of just egressing at tc.
3239 *
3240 * There are three supported level settings at this time:
3241 *
3242 * * **BPF_CSUM_LEVEL_INC**: Increases skb->csum_level for skbs
3243 * with CHECKSUM_UNNECESSARY.
3244 * * **BPF_CSUM_LEVEL_DEC**: Decreases skb->csum_level for skbs
3245 * with CHECKSUM_UNNECESSARY.
3246 * * **BPF_CSUM_LEVEL_RESET**: Resets skb->csum_level to 0 and
3247 * sets CHECKSUM_NONE to force checksum validation by the stack.
3248 * * **BPF_CSUM_LEVEL_QUERY**: No-op, returns the current
3249 * skb->csum_level.
3250 * Return
3251 * 0 on success, or a negative error in case of failure. In the
3252 * case of **BPF_CSUM_LEVEL_QUERY**, the current skb->csum_level
3253 * is returned or the error code -EACCES in case the skb is not
3254 * subject to CHECKSUM_UNNECESSARY.
3028 */3255 */
3029#define __BPF_FUNC_MAPPER(FN) \3256#define __BPF_FUNC_MAPPER(FN) \
3030 FN(unspec), \3257 FN(unspec), \
@@ -3151,7 +3378,18 @@ union bpf_attr { · 120 unmodified lines
3151 FN(xdp_output), \3378 FN(xdp_output), \
3152 FN(get_netns_cookie), \3379 FN(get_netns_cookie), \
3153 FN(get_current_ancestor_cgroup_id), \3380 FN(get_current_ancestor_cgroup_id), \
3154 FN(sk_assign),3381 FN(sk_assign), \
3382 FN(ktime_get_boot_ns), \
3383 FN(seq_printf), \
3384 FN(seq_write), \
3385 FN(sk_cgroup_id), \
3386 FN(sk_ancestor_cgroup_id), \
3387 FN(ringbuf_output), \
3388 FN(ringbuf_reserve), \
3389 FN(ringbuf_submit), \
3390 FN(ringbuf_discard), \
3391 FN(ringbuf_query), \
3392 FN(csum_level),
3155 3393
3156/* integer value in 'imm' field of BPF_CALL instruction selects which helper3394/* integer value in 'imm' field of BPF_CALL instruction selects which helper
3157 * function eBPF program intends to call3395 * function eBPF program intends to call
@@ -3228,6 +3466,14 @@ enum { · 70 unmodified lines
3228 BPF_F_CURRENT_NETNS = (-1L),3466 BPF_F_CURRENT_NETNS = (-1L),
3229};3467};
3230 3468
3469/* BPF_FUNC_csum_level level values. */
3470enum {
3471 BPF_CSUM_LEVEL_QUERY,
3472 BPF_CSUM_LEVEL_INC,
3473 BPF_CSUM_LEVEL_DEC,
3474 BPF_CSUM_LEVEL_RESET,
3475};
3476
3231/* BPF_FUNC_skb_adjust_room flags. */3477/* BPF_FUNC_skb_adjust_room flags. */
3232enum {3478enum {
3233 BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0),3479 BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0),
@@ -3235,6 +3481,7 @@ enum { · 1 unmodified line
3235 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2),3481 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2),
3236 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3),3482 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3),
3237 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),3483 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),
3484 BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5),
3238};3485};
3239 3486
3240enum {3487enum {
@@ -3261,6 +3508,29 @@ enum { · 20 unmodified lines
3261 BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0),3508 BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0),
3262};3509};
3263 3510
3511/* BPF_FUNC_bpf_ringbuf_commit, BPF_FUNC_bpf_ringbuf_discard, and
3512 * BPF_FUNC_bpf_ringbuf_output flags.
3513 */
3514enum {
3515 BPF_RB_NO_WAKEUP = (1ULL << 0),
3516 BPF_RB_FORCE_WAKEUP = (1ULL << 1),
3517};
3518
3519/* BPF_FUNC_bpf_ringbuf_query flags */
3520enum {
3521 BPF_RB_AVAIL_DATA = 0,
3522 BPF_RB_RING_SIZE = 1,
3523 BPF_RB_CONS_POS = 2,
3524 BPF_RB_PROD_POS = 3,
3525};
3526
3527/* BPF ring buffer constants */
3528enum {
3529 BPF_RINGBUF_BUSY_BIT = (1U << 31),
3530 BPF_RINGBUF_DISCARD_BIT = (1U << 30),
3531 BPF_RINGBUF_HDR_SZ = 8,
3532};
3533
3264/* Mode for BPF_FUNC_skb_adjust_room helper. */3534/* Mode for BPF_FUNC_skb_adjust_room helper. */
3265enum bpf_adj_room_mode {3535enum bpf_adj_room_mode {
3266 BPF_ADJ_ROOM_NET,3536 BPF_ADJ_ROOM_NET,
@@ -3393,6 +3663,7 @@ struct bpf_sock { · 126 unmodified lines
3393 __u32 dst_ip4;3663 __u32 dst_ip4;
3394 __u32 dst_ip6[4];3664 __u32 dst_ip6[4];
3395 __u32 state;3665 __u32 state;
3666 __s32 rx_queue_mapping;
3396};3667};
3397 3668
3398struct bpf_tcp_sock {3669struct bpf_tcp_sock {
@@ -3486,6 +3757,8 @@ struct xdp_md { · 87 unmodified lines
3486 /* Below access go through struct xdp_rxq_info */3757 /* Below access go through struct xdp_rxq_info */
3487 __u32 ingress_ifindex; /* rxq->dev->ifindex */3758 __u32 ingress_ifindex; /* rxq->dev->ifindex */
3488 __u32 rx_queue_index; /* rxq->queue_index */3759 __u32 rx_queue_index; /* rxq->queue_index */
3760
3761 __u32 egress_ifindex; /* txq->dev->ifindex */
3489};3762};
3490 3763
3491enum sk_action {3764enum sk_action {
@@ -3508,6 +3781,8 @@ struct sk_msg_md { · 16 unmodified lines
3508 __u32 remote_port; /* Stored in network byte order */3781 __u32 remote_port; /* Stored in network byte order */
3509 __u32 local_port; /* stored in host byte order */3782 __u32 local_port; /* stored in host byte order */
3510 __u32 size; /* Total size of sk_msg */3783 __u32 size; /* Total size of sk_msg */
3784
3785 __bpf_md_ptr(struct bpf_sock *, sk); /* current socket */
3511};3786};
3512 3787
3513struct sk_reuseport_md {3788struct sk_reuseport_md {
@@ -3598,6 +3873,29 @@ struct bpf_btf_info { · 84 unmodified lines
3598 __u32 id;3873 __u32 id;
3599} __attribute__((aligned(8)));3874} __attribute__((aligned(8)));
3600 3875
3876struct bpf_link_info {
3877 __u32 type;
3878 __u32 id;
3879 __u32 prog_id;
3880 union {
3881 struct {
3882 __aligned_u64 tp_name; /* in/out: tp_name buffer ptr */
3883 __u32 tp_name_len; /* in/out: tp_name buffer len */
3884 } raw_tracepoint;
3885 struct {
3886 __u32 attach_type;
3887 } tracing;
3888 struct {
3889 __u64 cgroup_id;
3890 __u32 attach_type;
3891 } cgroup;
3892 struct {
3893 __u32 netns_ino;
3894 __u32 attach_type;
3895 } netns;
3896 };
3897} __attribute__((aligned(8)));
3898
3601/* User bpf_sock_addr struct to access socket fields and sockaddr struct passed3899/* 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 on3900 * by user and intended to be used by socket (e.g. to bind to, depends on
3603 * attach attach type).3901 * attach attach type).
@@ -3610,7 +3908,7 @@ struct bpf_sock_addr { · 6 unmodified lines
3610 __u32 user_ip6[4]; /* Allows 1,2,4,8-byte read and 4,8-byte write.3908 __u32 user_ip6[4]; /* Allows 1,2,4,8-byte read and 4,8-byte write.
3611 * Stored in network byte order.3909 * Stored in network byte order.
3612 */3910 */
3613 __u32 user_port; /* Allows 4-byte read and write.3911 __u32 user_port; /* Allows 1,2,4-byte read and 4-byte write.
3614 * Stored in network byte order3912 * Stored in network byte order
3615 */3913 */
3616 __u32 family; /* Allows 4-byte read, but no write */3914 __u32 family; /* Allows 4-byte read, but no write */
tools/include/uapi/linux/if_link.h+1−0
@@ -343,6 +343,7 @@ enum { · 342 unmodified lines
343 IFLA_BRPORT_NEIGH_SUPPRESS,343 IFLA_BRPORT_NEIGH_SUPPRESS,
344 IFLA_BRPORT_ISOLATED,344 IFLA_BRPORT_ISOLATED,
345 IFLA_BRPORT_BACKUP_PORT,345 IFLA_BRPORT_BACKUP_PORT,
346 IFLA_BRPORT_MRP_RING_OPEN,
346 __IFLA_BRPORT_MAX347 __IFLA_BRPORT_MAX
347};348};
348#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)349#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)