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
3261 * Dynamically cast a *sk* pointer to a *tcp6_sock* pointer.3261 * Dynamically cast a *sk* pointer to a *tcp6_sock* pointer.
3262 * Return3262 * Return
3263 * *sk* if casting is valid, or NULL otherwise.3263 * *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.
3264 */3282 */
3265#define __BPF_FUNC_MAPPER(FN) \3283#define __BPF_FUNC_MAPPER(FN) \
3266 FN(unspec), \3284 FN(unspec), \
@@ -3399,7 +3417,10 @@ union bpf_attr { · 132 unmodified lines
3399 FN(ringbuf_discard), \3417 FN(ringbuf_discard), \
3400 FN(ringbuf_query), \3418 FN(ringbuf_query), \
3401 FN(csum_level), \3419 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),
3403 3424
3404/* integer value in 'imm' field of BPF_CALL instruction selects which helper3425/* integer value in 'imm' field of BPF_CALL instruction selects which helper
3405 * function eBPF program intends to call3426 * function eBPF program intends to call