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
4909 * Return4909 * Return
4910 * The number of bytes written to the buffer, or a negative error4910 * The number of bytes written to the buffer, or a negative error
4911 * in case of failure.4911 * 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.
4912 */4918 */
4913#define __BPF_FUNC_MAPPER(FN) \4919#define __BPF_FUNC_MAPPER(FN) \
4914 FN(unspec), \4920 FN(unspec), \
@@ -5089,6 +5095,7 @@ union bpf_attr { · 174 unmodified lines
5089 FN(task_pt_regs), \5095 FN(task_pt_regs), \
5090 FN(get_branch_snapshot), \5096 FN(get_branch_snapshot), \
5091 FN(trace_vprintk), \5097 FN(trace_vprintk), \
5098 FN(skc_to_unix_sock), \
5092 /* */5099 /* */
5093 5100
5094/* integer value in 'imm' field of BPF_CALL instruction selects which helper5101/* integer value in 'imm' field of BPF_CALL instruction selects which helper