History

bpf: Add bpf_skc_to_unix_sock() helper

The helper is used in tracing programs to cast a socket pointer to a unix_sock pointer. The return value could be NULL if the casting is illegal.

Hengqi Chen committed 5 years ago

Commit 9eeb3aa1 parent 44ce0ac6 files · +42 −0Browse files

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

Unified · Split

include/uapi/linux/bpf.h+7−0
@@ -4909,6 +4909,12 @@ union bpf_attr { · 4908 unmodified lines
49094909 * Return
49104910 * The number of bytes written to the buffer, or a negative error
49114911 * in case of failure.
4912+ *
4913+ * struct unix_sock *bpf_skc_to_unix_sock(void *sk)
4914+ * Description
4915+ * Dynamically cast a *sk* pointer to a *unix_sock* pointer.
4916+ * Return
4917+ * *sk* if casting is valid, or **NULL** otherwise.
49124918 */
49134919 #define __BPF_FUNC_MAPPER(FN) \
49144920 FN(unspec), \
@@ -5089,6 +5095,7 @@ union bpf_attr { · 174 unmodified lines
50895095 FN(task_pt_regs), \
50905096 FN(get_branch_snapshot), \
50915097 FN(trace_vprintk), \
5098+ FN(skc_to_unix_sock), \
50925099 /* */
50935100
50945101 /* integer value in 'imm' field of BPF_CALL instruction selects which helper