Sync the header from include/uapi/linux/bpf.h which was updated to add fib lookup helper function. This fixes selftests/bpf build failure.
Showing the changes to tools/include/uapi/linux (1 of 1 file). Show all
Unified · Split
| @@ -117,6 +117,7 @@ enum bpf_map_type { · 116 unmodified lines | ||
| 117 | 117 | BPF_MAP_TYPE_DEVMAP, |
| 118 | 118 | BPF_MAP_TYPE_SOCKMAP, |
| 119 | 119 | BPF_MAP_TYPE_CPUMAP, |
| 120 | + BPF_MAP_TYPE_XSKMAP, | |
| 120 | 121 | }; |
| 121 | 122 | |
| 122 | 123 | enum bpf_prog_type { |
| @@ -1827,6 +1828,33 @@ union bpf_attr { · 1704 unmodified lines | ||
| 1827 | 1828 | * Return |
| 1828 | 1829 | * 0 on success, or a negative error in case of failure. |
| 1829 | 1830 | * |
| 1831 | + * | |
| 1832 | + * int bpf_fib_lookup(void *ctx, struct bpf_fib_lookup *params, int plen, u32 flags) | |
| 1833 | + * Description | |
| 1834 | + * Do FIB lookup in kernel tables using parameters in *params*. | |
| 1835 | + * If lookup is successful and result shows packet is to be | |
| 1836 | + * forwarded, the neighbor tables are searched for the nexthop. | |
| 1837 | + * If successful (ie., FIB lookup shows forwarding and nexthop | |
| 1838 | + * is resolved), the nexthop address is returned in ipv4_dst, | |
| 1839 | + * ipv6_dst or mpls_out based on family, smac is set to mac | |
| 1840 | + * address of egress device, dmac is set to nexthop mac address, | |
| 1841 | + * rt_metric is set to metric from route. | |
| 1842 | + * | |
| 1843 | + * *plen* argument is the size of the passed in struct. | |
| 1844 | + * *flags* argument can be one or more BPF_FIB_LOOKUP_ flags: | |
| 1845 | + * | |
| 1846 | + * **BPF_FIB_LOOKUP_DIRECT** means do a direct table lookup vs | |
| 1847 | + * full lookup using FIB rules | |
| 1848 | + * **BPF_FIB_LOOKUP_OUTPUT** means do lookup from an egress | |
| 1849 | + * perspective (default is ingress) | |
| 1850 | + * | |
| 1851 | + * *ctx* is either **struct xdp_md** for XDP programs or | |
| 1852 | + * **struct sk_buff** tc cls_act programs. | |
| 1853 | + * | |
| 1854 | + * Return | |
| 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 | |
| 1857 | + * of failure. | |
| 1830 | 1858 | */ |
| 1831 | 1859 | #define __BPF_FUNC_MAPPER(FN) \ |
| 1832 | 1860 | FN(unspec), \ |
| @@ -1897,7 +1925,8 @@ union bpf_attr { · 64 unmodified lines | ||
| 1897 | 1925 | FN(xdp_adjust_tail), \ |
| 1898 | 1926 | FN(skb_get_xfrm_state), \ |
| 1899 | 1927 | FN(get_stack), \ |
| 1900 | − FN(skb_load_bytes_relative), | |
| 1928 | + FN(skb_load_bytes_relative), \ | |
| 1929 | + FN(fib_lookup), | |
| 1901 | 1930 | |
| 1902 | 1931 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 1903 | 1932 | * function eBPF program intends to call |
| @@ -2320,4 +2349,55 @@ struct bpf_raw_tracepoint_args { · 416 unmodified lines | ||
| 2320 | 2349 | __u64 args[0]; |
| 2321 | 2350 | }; |
| 2322 | 2351 | |
| 2352 | +/* DIRECT: Skip the FIB rules and go to FIB table associated with device | |
| 2353 | + * OUTPUT: Do lookup from egress perspective; default is ingress | |
| 2354 | + */ | |
| 2355 | +#define BPF_FIB_LOOKUP_DIRECT BIT(0) | |
| 2356 | +#define BPF_FIB_LOOKUP_OUTPUT BIT(1) | |
| 2357 | + | |
| 2358 | +struct bpf_fib_lookup { | |
| 2359 | + /* input */ | |
| 2360 | + __u8 family; /* network family, AF_INET, AF_INET6, AF_MPLS */ | |
| 2361 | + | |
| 2362 | + /* set if lookup is to consider L4 data - e.g., FIB rules */ | |
| 2363 | + __u8 l4_protocol; | |
| 2364 | + __be16 sport; | |
| 2365 | + __be16 dport; | |
| 2366 | + | |
| 2367 | + /* total length of packet from network header - used for MTU check */ | |
| 2368 | + __u16 tot_len; | |
| 2369 | + __u32 ifindex; /* L3 device index for lookup */ | |
| 2370 | + | |
| 2371 | + union { | |
| 2372 | + /* inputs to lookup */ | |
| 2373 | + __u8 tos; /* AF_INET */ | |
| 2374 | + __be32 flowlabel; /* AF_INET6 */ | |
| 2375 | + | |
| 2376 | + /* output: metric of fib result */ | |
| 2377 | + __u32 rt_metric; | |
| 2378 | + }; | |
| 2379 | + | |
| 2380 | + union { | |
| 2381 | + __be32 mpls_in; | |
| 2382 | + __be32 ipv4_src; | |
| 2383 | + __u32 ipv6_src[4]; /* in6_addr; network order */ | |
| 2384 | + }; | |
| 2385 | + | |
| 2386 | + /* input to bpf_fib_lookup, *dst is destination address. | |
| 2387 | + * output: bpf_fib_lookup sets to gateway address | |
| 2388 | + */ | |
| 2389 | + union { | |
| 2390 | + /* return for MPLS lookups */ | |
| 2391 | + __be32 mpls_out[4]; /* support up to 4 labels */ | |
| 2392 | + __be32 ipv4_dst; | |
| 2393 | + __u32 ipv6_dst[4]; /* in6_addr; network order */ | |
| 2394 | + }; | |
| 2395 | + | |
| 2396 | + /* output */ | |
| 2397 | + __be16 h_vlan_proto; | |
| 2398 | + __be16 h_vlan_TCI; | |
| 2399 | + __u8 smac[6]; /* ETH_ALEN */ | |
| 2400 | + __u8 dmac[6]; /* ETH_ALEN */ | |
| 2401 | +}; | |
| 2402 | + | |
| 2323 | 2403 | #endif /* _UAPI__LINUX_BPF_H__ */ |