aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-06-05 12:42:19 -0400
committerDavid S. Miller <davem@davemloft.net>2018-06-05 12:42:19 -0400
commitfd129f8941cf2309def29b5c8a23b62faff0c9d0 (patch)
tree6ad8afbb59eaf14cfa9f0c4bad498254e6ff1e66 /include/uapi/linux
parenta6fa9087fc280bba8a045d11d9b5d86cbf9a3a83 (diff)
parent9fa06104a235f64d6a2bf3012cc9966e8e4be5eb (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Daniel Borkmann says: ==================== pull-request: bpf-next 2018-06-05 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) Add a new BPF hook for sendmsg similar to existing hooks for bind and connect: "This allows to override source IP (including the case when it's set via cmsg(3)) and destination IP:port for unconnected UDP (slow path). TCP and connected UDP (fast path) are not affected. This makes UDP support complete, that is, connected UDP is handled by connect hooks, unconnected by sendmsg ones.", from Andrey. 2) Rework of the AF_XDP API to allow extending it in future for type writer model if necessary. In this mode a memory window is passed to hardware and multiple frames might be filled into that window instead of just one that is the case in the current fixed frame-size model. With the new changes made this can be supported without having to add a new descriptor format. Also, core bits for the zero-copy support for AF_XDP have been merged as agreed upon, where i40e bits will be routed via Jeff later on. Various improvements to documentation and sample programs included as well, all from Björn and Magnus. 3) Given BPF's flexibility, a new program type has been added to implement infrared decoders. Quote: "The kernel IR decoders support the most widely used IR protocols, but there are many protocols which are not supported. [...] There is a 'long tail' of unsupported IR protocols, for which lircd is need to decode the IR. IR encoding is done in such a way that some simple circuit can decode it; therefore, BPF is ideal. [...] user-space can define a decoder in BPF, attach it to the rc device through the lirc chardev.", from Sean. 4) Several improvements and fixes to BPF core, among others, dumping map and prog IDs into fdinfo which is a straight forward way to correlate BPF objects used by applications, removing an indirect call and therefore retpoline in all map lookup/update/delete calls by invoking the callback directly for 64 bit archs, adding a new bpf_skb_cgroup_id() BPF helper for tc BPF programs to have an efficient way of looking up cgroup v2 id for policy or other use cases. Fixes to make sure we zero tunnel/xfrm state that hasn't been filled, to allow context access wrt pt_regs in 32 bit archs for tracing, and last but not least various test cases for fixes that landed in bpf earlier, from Daniel. 5) Get rid of the ndo_xdp_flush API and extend the ndo_xdp_xmit with a XDP_XMIT_FLUSH flag instead which allows to avoid one indirect call as flushing is now merged directly into ndo_xdp_xmit(), from Jesper. 6) Add a new bpf_get_current_cgroup_id() helper that can be used in tracing to retrieve the cgroup id from the current process in order to allow for e.g. aggregation of container-level events, from Yonghong. 7) Two follow-up fixes for BTF to reject invalid input values and related to that also two test cases for BPF kselftests, from Martin. 8) Various API improvements to the bpf_fib_lookup() helper, that is, dropping MPLS bits which are not fully hashed out yet, rejecting invalid helper flags, returning error for unsupported address families as well as renaming flowlabel to flowinfo, from David. 9) Various fixes and improvements to sockmap BPF kselftests in particular in proper error detection and data verification, from Prashant. 10) Two arm32 BPF JIT improvements. One is to fix imm range check with regards to whether immediate fits into 24 bits, and a naming cleanup to get functions related to rsh handling consistent to those handling lsh, from Wang. 11) Two compile warning fixes in BPF, one for BTF and a false positive to silent gcc in stack_map_get_build_id_offset(), from Arnd. 12) Add missing seg6.h header into tools include infrastructure in order to fix compilation of BPF kselftests, from Mathieu. 13) Several formatting cleanups in the BPF UAPI helper description that also fix an error during rst2man compilation, from Quentin. 14) Hide an unused variable in sk_msg_convert_ctx_access() when IPv6 is not built into the kernel, from Yue. 15) Remove a useless double assignment in dev_map_enqueue(), from Colin. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/bpf.h136
-rw-r--r--include/uapi/linux/if_xdp.h16
2 files changed, 117 insertions, 35 deletions
</
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 671486133988..59b19b6a40d7 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -143,6 +143,7 @@ enum bpf_prog_type {
143 BPF_PROG_TYPE_RAW_TRACEPOINT, 143 BPF_PROG_TYPE_RAW_TRACEPOINT,
144 BPF_PROG_TYPE_CGROUP_SOCK_ADDR, 144 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
145 BPF_PROG_TYPE_LWT_SEG6LOCAL, 145 BPF_PROG_TYPE_LWT_SEG6LOCAL,
146 BPF_PROG_TYPE_LIRC_MODE2,
146}; 147};
147 148
148enum bpf_attach_type { 149enum bpf_attach_type {
@@ -160,6 +161,9 @@ enum bpf_attach_type {
160 BPF_CGROUP_INET6_CONNECT, 161 BPF_CGROUP_INET6_CONNECT,
161 BPF_CGROUP_INET4_POST_BIND, 162 BPF_CGROUP_INET4_POST_BIND,
162 BPF_CGROUP_INET6_POST_BIND, 163 BPF_CGROUP_INET6_POST_BIND,
164 BPF_CGROUP_UDP4_SENDMSG,
165 BPF_CGROUP_UDP6_SENDMSG,
166 BPF_LIRC_MODE2,
163 __MAX_BPF_ATTACH_TYPE 167 __MAX_BPF_ATTACH_TYPE
164}; 168};
165 169
@@ -1008,7 +1012,6 @@ union bpf_attr {
1008 * :: 1012 * ::
1009 * 1013 *
1010 * # sysctl kernel.perf_event_max_stack=<new value> 1014 * # sysctl kernel.perf_event_max_stack=<new value>
1011 *
1012 * Return 1015 * Return
1013 * The positive or null stack id on success, or a negative error 1016 * The positive or null stack id on success, or a negative error
1014 * in case of failure. 1017 * in case of failure.
@@ -1819,10 +1822,9 @@ union bpf_attr {
1819 * :: 1822 * ::
1820 * 1823 *
1821 * # sysctl kernel.perf_event_max_stack=<new value> 1824 * # sysctl kernel.perf_event_max_stack=<new value>
1822 *
1823 * Return 1825 * Return
1824 * a non-negative value equal to or less than size on success, or 1826 * A non-negative value equal to or less than *size* on success,
1825 * a negative error in case of failure. 1827 * or a negative error in case of failure.
1826 * 1828 *
1827 * int skb_load_bytes_relative(const struct sk_buff *skb, u32 offset, void *to, u32 len, u32 start_header) 1829 * int skb_load_bytes_relative(const struct sk_buff *skb, u32 offset, void *to, u32 len, u32 start_header)
1828 * Description 1830 * Description
@@ -1843,7 +1845,6 @@ union bpf_attr {
1843 * in socket filters where *skb*\ **->data** does not always point 1845 * in socket filters where *skb*\ **->data** does not always point
1844 * to the start of the mac header and where "direct packet access" 1846 * to the start of the mac header and where "direct packet access"
1845 * is not available. 1847 * is not available.
1846 *
1847 * Return 1848 * Return
1848 * 0 on success, or a negative error in case of failure. 1849 * 0 on success, or a negative error in case of failure.
1849 * 1850 *
@@ -1853,22 +1854,24 @@ union bpf_attr {
1853 * If lookup is successful and result shows packet is to be 1854 * If lookup is successful and result shows packet is to be
1854 * forwarded, the neighbor tables are searched for the nexthop. 1855 * forwarded, the neighbor tables are searched for the nexthop.
1855 * If successful (ie., FIB lookup shows forwarding and nexthop 1856 * If successful (ie., FIB lookup shows forwarding and nexthop
1856 * is resolved), the nexthop address is returned in ipv4_dst, 1857 * is resolved), the nexthop address is returned in ipv4_dst
1857 * ipv6_dst or mpls_out based on family, smac is set to mac 1858 * or ipv6_dst based on family, smac is set to mac address of
1858 * address of egress device, dmac is set to nexthop mac address, 1859 * egress device, dmac is set to nexthop mac address, rt_metric
1859 * rt_metric is set to metric from route. 1860 * is set to metric from route (IPv4/IPv6 only).
1860 * 1861 *
1861 * *plen* argument is the size of the passed in struct. 1862 * *plen* argument is the size of the passed in struct.
1862 * *flags* argument can be one or more BPF_FIB_LOOKUP_ flags: 1863 * *flags* argument can be a combination of one or more of the
1864 * following values:
1863 * 1865 *
1864 * **BPF_FIB_LOOKUP_DIRECT** means do a direct table lookup vs 1866 * **BPF_FIB_LOOKUP_DIRECT**
1865 * full lookup using FIB rules 1867 * Do a direct table lookup vs full lookup using FIB
1866 * **BPF_FIB_LOOKUP_OUTPUT** means do lookup from an egress 1868 * rules.
1867 * perspective (default is ingress) 1869 * **BPF_FIB_LOOKUP_OUTPUT**
1870 * Perform lookup from an egress perspective (default is
1871 * ingress).
1868 * 1872 *
1869 * *ctx* is either **struct xdp_md** for XDP programs or 1873 * *ctx* is either **struct xdp_md** for XDP programs or
1870 * **struct sk_buff** tc cls_act programs. 1874 * **struct sk_buff** tc cls_act programs.
1871 *
1872 * Return 1875 * Return
1873 * Egress device index on success, 0 if packet needs to continue 1876 * Egress device index on success, 0 if packet needs to continue
1874 * up the stack for further processing or a negative error in case 1877 * up the stack for further processing or a negative error in case
@@ -2004,6 +2007,74 @@ union bpf_attr {
2004 * direct packet access. 2007 * direct packet access.
2005 * Return 2008 * Return
2006 * 0 on success, or a negative error in case of failure. 2009 * 0 on success, or a negative error in case of failure.
2010 *
2011 * int bpf_rc_keydown(void *ctx, u32 protocol, u64 scancode, u32 toggle)
2012 * Description
2013 * This helper is used in programs implementing IR decoding, to
2014 * report a successfully decoded key press with *scancode*,
2015 * *toggle* value in the given *protocol*. The scancode will be
2016 * translated to a keycode using the rc keymap, and reported as
2017 * an input key down event. After a period a key up event is
2018 * generated. This period can be extended by calling either
2019 * **bpf_rc_keydown** () again with the same values, or calling
2020 * **bpf_rc_repeat** ().
2021 *
2022 * Some protocols include a toggle bit, in case the button was
2023 * released and pressed again between consecutive scancodes.
2024 *
2025 * The *ctx* should point to the lirc sample as passed into
2026 * the program.
2027 *
2028 * The *protocol* is the decoded protocol number (see
2029 * **enum rc_proto** for some predefined values).
2030 *
2031 * This helper is only available is the kernel was compiled with
2032 * the **CONFIG_BPF_LIRC_MODE2** configuration option set to
2033 * "**y**".
2034 *
2035 * Return
2036 * 0
2037 *
2038 * int bpf_rc_repeat(void *ctx)
2039 * Description
2040 * This helper is used in programs implementing IR decoding, to
2041 * report a successfully decoded repeat key message. This delays
2042 * the generation of a key up event for previously generated
2043 * key down event.
2044 *
2045 * Some IR protocols like NEC have a special IR message for
2046 * repeating last button, for when a button is held down.
2047 *
2048 * The *ctx* should point to the lirc sample as passed into
2049 * the program.
2050 *
2051 * This helper is only available is the kernel was compiled with
2052 * the **CONFIG_BPF_LIRC_MODE2** configuration option set to
2053 * "**y**".
2054 *
2055 * Return
2056 * 0
2057 *
2058 * uint64_t bpf_skb_cgroup_id(struct sk_buff *skb)
2059 * Description
2060 * Return the cgroup v2 id of the socket associated with the *skb*.
2061 * This is roughly similar to the **bpf_get_cgroup_classid**\ ()
2062 * helper for cgroup v1 by providing a tag resp. identifier that
2063 * can be matched on or used for map lookups e.g. to implement
2064 * policy. The cgroup v2 id of a given path in the hierarchy is
2065 * exposed in user space through the f_handle API in order to get
2066 * to the same 64-bit id.
2067 *
2068 * This helper can be used on TC egress path, but not on ingress,
2069 * and is available only if the kernel was compiled with the
2070 * **CONFIG_SOCK_CGROUP_DATA** configuration option.
2071 * Return
2072 * The id is returned or 0 in case the id could not be retrieved.
2073 *
2074 * u64 bpf_get_current_cgroup_id(void)
2075 * Return
2076 * A 64-bit integer containing the current cgroup id based
2077 * on the cgroup within which the current task is running.
2007 */ 2078 */
2008#define __BPF_FUNC_MAPPER(FN) \ 2079#define __BPF_FUNC_MAPPER(FN) \
2009 FN(unspec), \ 2080 FN(unspec), \
@@ -2082,7 +2153,11 @@ union bpf_attr {
2082 FN(lwt_push_encap), \ 2153 FN(lwt_push_encap), \
2083 FN(lwt_seg6_store_bytes), \ 2154 FN(lwt_seg6_store_bytes), \
2084 FN(lwt_seg6_adjust_srh), \ 2155 FN(lwt_seg6_adjust_srh), \