This patch proposes to extend the sk_lookup() BPF API to the XDP hookpoint. The sk_lookup() helper supports a lookup on incoming packet to find the corresponding socket that will receive this packet. Current support for this BPF API is at the tc hookpoint. This patch will extend this API at XDP hookpoint. A XDP program can map the incoming packet to the 5-tuple parameter and invoke the API to find the corresponding socket structure.
Showing the changes to include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -2201,6 +2201,8 @@ union bpf_attr { · 2200 unmodified lines | |||
| 2201 | * **CONFIG_NET** configuration option. | 2201 | * **CONFIG_NET** configuration option. |
| 2202 | * Return | 2202 | * Return |
| 2203 | * Pointer to *struct bpf_sock*, or NULL in case of failure. | 2203 | * Pointer to *struct bpf_sock*, or NULL in case of failure. |
| 2204 | * For sockets with reuseport option, *struct bpf_sock* | ||
| 2205 | * return is from reuse->socks[] using hash of the packet. | ||
| 2204 | * | 2206 | * |
| 2205 | * struct bpf_sock *bpf_sk_lookup_udp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u32 netns, u64 flags) | 2207 | * struct bpf_sock *bpf_sk_lookup_udp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u32 netns, u64 flags) |
| 2206 | * Description | 2208 | * Description |
| @@ -2233,6 +2235,8 @@ union bpf_attr { · 26 unmodified lines | |||
| 2233 | * **CONFIG_NET** configuration option. | 2235 | * **CONFIG_NET** configuration option. |
| 2234 | * Return | 2236 | * Return |
| 2235 | * Pointer to *struct bpf_sock*, or NULL in case of failure. | 2237 | * Pointer to *struct bpf_sock*, or NULL in case of failure. |
| 2238 | * For sockets with reuseport option, *struct bpf_sock* | ||
| 2239 | * return is from reuse->socks[] using hash of the packet. | ||
| 2236 | * | 2240 | * |
| 2237 | * int bpf_sk_release(struct bpf_sock *sk) | 2241 | * int bpf_sk_release(struct bpf_sock *sk) |
| 2238 | * Description | 2242 | * Description |