History

Add a eBPF helper function to retrieve socket uid

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.

Chenbo Feng committed 9 years ago

Commit 6acc5c21 parent 91b82703 files · +32 −2Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/bpf.h+8−1
@@ -465,6 +465,12 @@ union bpf_attr { · 464 unmodified lines
465465 * @skb: pointer to skb
466466 * Return: 8 Bytes non-decreasing number on success or 0 if the socket
467467 * 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
468474 */
469475 #define __BPF_FUNC_MAPPER(FN) \
470476 FN(unspec), \
@@ -513,7 +519,8 @@ union bpf_attr { · 42 unmodified lines
513519 FN(skb_change_head), \
514520 FN(xdp_adjust_head), \
515521 FN(probe_read_str), \
516− FN(get_socket_cookie),
522+ FN(get_socket_cookie), \
523+ FN(get_socket_uid),
517524
518525 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
519526 * function eBPF program intends to call

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t