Skip to content

Commit cb9c28e

Browse files
pbholeborkmann
authored andcommitted
bpf: sync tools bpf.h uapi header
Sync the header from include/uapi/linux/bpf.h which was updated to add fib lookup helper function. This fixes selftests/bpf build failure. Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 91bc07c commit cb9c28e

File tree

1 file changed

+81
-1
lines changed
  • tools/include/uapi/linux

1 file changed

+81
-1
lines changed

tools/include/uapi/linux/bpf.h

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ enum bpf_map_type {
117117
BPF_MAP_TYPE_DEVMAP,
118118
BPF_MAP_TYPE_SOCKMAP,
119119
BPF_MAP_TYPE_CPUMAP,
120+
BPF_MAP_TYPE_XSKMAP,
120121
};
121122

122123
enum bpf_prog_type {
@@ -1827,6 +1828,33 @@ union bpf_attr {
18271828
* Return
18281829
* 0 on success, or a negative error in case of failure.
18291830
*
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.
18301858
*/
18311859
#define __BPF_FUNC_MAPPER(FN) \
18321860
FN(unspec), \
@@ -1897,7 +1925,8 @@ union bpf_attr {
18971925
FN(xdp_adjust_tail), \
18981926
FN(skb_get_xfrm_state), \
18991927
FN(get_stack), \
1900-
FN(skb_load_bytes_relative),
1928+
FN(skb_load_bytes_relative), \
1929+
FN(fib_lookup),
19011930

19021931
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
19031932
* function eBPF program intends to call
@@ -2320,4 +2349,55 @@ struct bpf_raw_tracepoint_args {
23202349
__u64 args[0];
23212350
};
23222351

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+
23232403
#endif /* _UAPI__LINUX_BPF_H__ */

0 commit comments

Comments
 (0)