aboutsummaryrefslogtreecommitdiffstats
path: root/tools/include
diff options
context:
space:
mode:
authorJohn Fastabend <john.fastabend@gmail.com>2018-05-14 13:00:18 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2018-05-16 16:00:12 -0400
commitb8b394faa92418521829bbd4ae9cb22fb6c504ed (patch)
treea805f73b8d2008a2aa6caece5c82e53005340559 /tools/include
parent81110384441a59cff47430f20f049e69b98c17f4 (diff)
bpf: selftest additions for SOCKHASH
This runs existing SOCKMAP tests with SOCKHASH map type. To do this we push programs into include file and build two BPF programs. One for SOCKHASH and one for SOCKMAP. We then run the entire test suite with each type. Signed-off-by: John Fastabend <john.fastabend@gmail.com> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/uapi/linux/bpf.h54
1 files changed, 52 insertions, 2 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 02e4112510f8..d94d333a8225 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -118,6 +118,7 @@ enum bpf_map_type {
118 BPF_MAP_TYPE_SOCKMAP, 118 BPF_MAP_TYPE_SOCKMAP,
119 BPF_MAP_TYPE_CPUMAP, 119 BPF_MAP_TYPE_CPUMAP,
120 BPF_MAP_TYPE_XSKMAP, 120 BPF_MAP_TYPE_XSKMAP,
121 BPF_MAP_TYPE_SOCKHASH,
121}; 122};
122 123
123enum bpf_prog_type { 124enum bpf_prog_type {
@@ -1828,7 +1829,6 @@ union bpf_attr {
1828 * Return 1829 * Return
1829 * 0 on success, or a negative error in case of failure. 1830 * 0 on success, or a negative error in case of failure.
1830 * 1831 *
1831 *
1832 * int bpf_fib_lookup(void *ctx, struct bpf_fib_lookup *params, int plen, u32 flags) 1832 * int bpf_fib_lookup(void *ctx, struct bpf_fib_lookup *params, int plen, u32 flags)
1833 * Description 1833 * Description
1834 * Do FIB lookup in kernel tables using parameters in *params*. 1834 * Do FIB lookup in kernel tables using parameters in *params*.
@@ -1855,6 +1855,53 @@ union bpf_attr {
1855 * Egress device index on success, 0 if packet needs to continue 1855 * Egress device index on success, 0 if packet needs to continue
1856 * up the stack for further processing or a negative error in case 1856 * up the stack for further processing or a negative error in case
1857 * of failure. 1857 * of failure.
1858 *
1859 * int bpf_sock_hash_update(struct bpf_sock_ops_kern *skops, struct bpf_map *map, void *key, u64 flags)
1860 * Description
1861 * Add an entry to, or update a sockhash *map* referencing sockets.
1862 * The *skops* is used as a new value for the entry associated to
1863 * *key*. *flags* is one of:
1864 *
1865 * **BPF_NOEXIST**
1866 * The entry for *key* must not exist in the map.
1867 * **BPF_EXIST**
1868 * The entry for *key* must already exist in the map.
1869 * **BPF_ANY**
1870 * No condition on the existence of the entry for *key*.
1871 *
1872 * If the *map* has eBPF programs (parser and verdict), those will
1873 * be inherited by the socket being added. If the socket is
1874 * already attached to eBPF programs, this results in an error.
1875 * Return
1876 * 0 on success, or a negative error in case of failure.
1877 *
1878 * int bpf_msg_redirect_hash(struct sk_msg_buff *msg, struct bpf_map *map, void *key, u64 flags)
1879 * Description
1880 * This helper is used in programs implementing policies at the
1881 * socket level. If the message *msg* is allowed to pass (i.e. if
1882 * the verdict eBPF program returns **SK_PASS**), redirect it to
1883 * the socket referenced by *map* (of type
1884 * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and
1885 * egress interfaces can be used for redirection. The
1886 * **BPF_F_INGRESS** value in *flags* is used to make the
1887 * distinction (ingress path is selected if the flag is present,
1888 * egress path otherwise). This is the only flag supported for now.
1889 * Return
1890 * **SK_PASS** on success, or **SK_DROP** on error.
1891 *
1892 * int bpf_sk_redirect_hash(struct sk_buff *skb, struct bpf_map *map, void *key, u64 flags)
1893 * Description
1894 * This helper is used in programs implementing policies at the
1895 * skb socket level. If the sk_buff *skb* is allowed to pass (i.e.
1896 * if the verdeict eBPF program returns **SK_PASS**), redirect it
1897 * to the socket referenced by *map* (of type
1898 * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and
1899 * egress interfaces can be used for redirection. The
1900 * **BPF_F_INGRESS** value in *flags* is used to make the
1901 * distinction (ingress path is selected if the flag is present,
1902 * egress otherwise). This is the only flag supported for now.
1903 * Return
1904 * **SK_PASS** on success, or **SK_DROP** on error.
1858 */ 1905 */
1859#define __BPF_FUNC_MAPPER(FN) \ 1906#define __BPF_FUNC_MAPPER(FN) \
1860 FN(unspec), \ 1907 FN(unspec), \
@@ -1926,7 +1973,10 @@ union bpf_attr {
1926 FN(skb_get_xfrm_state), \ 1973 FN(skb_get_xfrm_state), \
1927 FN(get_stack), \ 1974 FN(get_stack), \
1928 FN(skb_load_bytes_relative), \ 1975 FN(skb_load_bytes_relative), \
1929 FN(fib_lookup), 1976 FN(fib_lookup), \
1977 FN(sock_hash_update), \
1978 FN(msg_redirect_hash), \
1979 FN(sk_redirect_hash),
1930 1980
1931/* integer value in 'imm' field of BPF_CALL instruction selects which helper 1981/* integer value in 'imm' field of BPF_CALL instruction selects which helper
1932 * function eBPF program intends to call 1982 * function eBPF program intends to call