Returns the owner uid of the socket inside a sk_buff. This is useful to perform per-UID accounting of network traffic or per-UID packet filtering. The socket need to be a fullsock otherwise overflowuid is returned.
Showing the changes to include/uapi/linux (1 of 3 files). Show all
Unified · Split
| @@ -465,6 +465,12 @@ union bpf_attr { · 464 unmodified lines | |||
| 465 | * @skb: pointer to skb | 465 | * @skb: pointer to skb |
| 466 | * Return: 8 Bytes non-decreasing number on success or 0 if the socket | 466 | * Return: 8 Bytes non-decreasing number on success or 0 if the socket |
| 467 | * field is missing inside sk_buff | 467 | * field is missing inside sk_buff |
| 468 | * | ||
| 469 | * u32 bpf_get_socket_uid(skb) | ||
| 470 | * Get the owner uid of the socket stored inside sk_buff. | ||
| 471 | * @skb: pointer to skb | ||
| 472 | * Return: uid of the socket owner on success or 0 if the socket pointer | ||
| 473 | * inside sk_buff is NULL | ||
| 468 | */ | 474 | */ |
| 469 | #define __BPF_FUNC_MAPPER(FN) \ | 475 | #define __BPF_FUNC_MAPPER(FN) \ |
| 470 | FN(unspec), \ | 476 | FN(unspec), \ |
| @@ -513,7 +519,8 @@ union bpf_attr { · 42 unmodified lines | |||
| 513 | FN(skb_change_head), \ | 519 | FN(skb_change_head), \ |
| 514 | FN(xdp_adjust_head), \ | 520 | FN(xdp_adjust_head), \ |
| 515 | FN(probe_read_str), \ | 521 | FN(probe_read_str), \ |
| 516 | FN(get_socket_cookie), | 522 | FN(get_socket_cookie), \ |
| 523 | FN(get_socket_uid), | ||
| 517 | 524 | ||
| 518 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 525 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 519 | * function eBPF program intends to call | 526 | * function eBPF program intends to call |