bpf_get_socket_cookie() helper can be used to identify skb that correspond to the same socket. Though socket cookie can be useful in many other use-cases where socket is available in program context. Specifically BPF_PROG_TYPE_CGROUP_SOCK_ADDR and BPF_PROG_TYPE_SOCK_OPS programs can benefit from it so that one of them can augment a value in a map prepared earlier by other program for the same socket. The patch adds support to call bpf_get_socket_cookie() from BPF_PROG_TYPE_CGROUP_SOCK_ADDR and BPF_PROG_TYPE_SOCK_OPS. It doesn't introduce new helpers. Instead it reuses same helper name bpf_get_socket_cookie() but adds support to this helper to accept `struct bpf_sock_addr` and `struct bpf_sock_ops`. Documentation in bpf.h is changed in a way that should not break automatic generation of markdown.
Showing the changes to include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -1371,6 +1371,20 @@ union bpf_attr { · 1370 unmodified lines | ||
| 1371 | 1371 | * A 8-byte long non-decreasing number on success, or 0 if the |
| 1372 | 1372 | * socket field is missing inside *skb*. |
| 1373 | 1373 | * |
| 1374 | + * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx) | |
| 1375 | + * Description | |
| 1376 | + * Equivalent to bpf_get_socket_cookie() helper that accepts | |
| 1377 | + * *skb*, but gets socket from **struct bpf_sock_addr** contex. | |
| 1378 | + * Return | |
| 1379 | + * A 8-byte long non-decreasing number. | |
| 1380 | + * | |
| 1381 | + * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx) | |
| 1382 | + * Description | |
| 1383 | + * Equivalent to bpf_get_socket_cookie() helper that accepts | |
| 1384 | + * *skb*, but gets socket from **struct bpf_sock_ops** contex. | |
| 1385 | + * Return | |
| 1386 | + * A 8-byte long non-decreasing number. | |
| 1387 | + * | |
| 1374 | 1388 | * u32 bpf_get_socket_uid(struct sk_buff *skb) |
| 1375 | 1389 | * Return |
| 1376 | 1390 | * The owner UID of the socket associated to *skb*. If the socket |