History

bpf: Add bpf_skc_to_{tcp, tcp_timewait, tcp_request}_sock() helpers

Three more helpers are added to cast a sock_common pointer to an tcp_sock, tcp_timewait_sock or a tcp_request_sock for tracing programs.

Yonghong Song committed 6 years ago

Commit 478cfbd1 parent af7ec136 files · +121 −2Browse files

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

Unified · Split

include/uapi/linux/bpf.h+22−1
@@ -3261,6 +3261,24 @@ union bpf_attr { · 3260 unmodified lines
32613261 * Dynamically cast a *sk* pointer to a *tcp6_sock* pointer.
32623262 * Return
32633263 * *sk* if casting is valid, or NULL otherwise.
3264+ *
3265+ * struct tcp_sock *bpf_skc_to_tcp_sock(void *sk)
3266+ * Description
3267+ * Dynamically cast a *sk* pointer to a *tcp_sock* pointer.
3268+ * Return
3269+ * *sk* if casting is valid, or NULL otherwise.
3270+ *
3271+ * struct tcp_timewait_sock *bpf_skc_to_tcp_timewait_sock(void *sk)
3272+ * Description
3273+ * Dynamically cast a *sk* pointer to a *tcp_timewait_sock* pointer.
3274+ * Return
3275+ * *sk* if casting is valid, or NULL otherwise.
3276+ *
3277+ * struct tcp_request_sock *bpf_skc_to_tcp_request_sock(void *sk)
3278+ * Description
3279+ * Dynamically cast a *sk* pointer to a *tcp_request_sock* pointer.
3280+ * Return
3281+ * *sk* if casting is valid, or NULL otherwise.
32643282 */
32653283 #define __BPF_FUNC_MAPPER(FN) \
32663284 FN(unspec), \
@@ -3399,7 +3417,10 @@ union bpf_attr { · 132 unmodified lines
33993417 FN(ringbuf_discard), \
34003418 FN(ringbuf_query), \
34013419 FN(csum_level), \
3402− FN(skc_to_tcp6_sock),
3420+ FN(skc_to_tcp6_sock), \
3421+ FN(skc_to_tcp_sock), \
3422+ FN(skc_to_tcp_timewait_sock), \
3423+ FN(skc_to_tcp_request_sock),
34033424
34043425 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
34053426 * function eBPF program intends to call