mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-26 06:33:19 -04:00
UPSTREAM: bpf: Add bpf_skc_to_tcp6_sock() helper
The helper is used in tracing programs to cast a socket pointer to a tcp6_sock pointer. The return value could be NULL if the casting is illegal. A new helper return type RET_PTR_TO_BTF_ID_OR_NULL is added so the verifier is able to deduce proper return types for the helper. Different from the previous BTF_ID based helpers, the bpf_skc_to_tcp6_sock() argument can be several possible btf_ids. More specifically, all possible socket data structures with sock_common appearing in the first in the memory layout. This patch only added socket types related to tcp and udp. All possible argument btf_id and return value btf_id for helper bpf_skc_to_tcp6_sock() are pre-calculcated and cached. In the future, it is even possible to precompute these btf_id's at kernel build time. Change-Id: I42addc1779489c7e2ba1de30a59e009b1ba21f80 Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20200623230809.3988195-1-yhs@fb.com
This commit is contained in:
parent
e4810fd04e
commit
2c45a6f681
8 changed files with 148 additions and 12 deletions
|
|
@ -3266,6 +3266,12 @@ union bpf_attr {
|
|||
* case of **BPF_CSUM_LEVEL_QUERY**, the current skb->csum_level
|
||||
* is returned or the error code -EACCES in case the skb is not
|
||||
* subject to CHECKSUM_UNNECESSARY.
|
||||
*
|
||||
* struct tcp6_sock *bpf_skc_to_tcp6_sock(void *sk)
|
||||
* Description
|
||||
* Dynamically cast a *sk* pointer to a *tcp6_sock* pointer.
|
||||
* Return
|
||||
* *sk* if casting is valid, or NULL otherwise.
|
||||
*/
|
||||
#define __BPF_FUNC_MAPPER(FN) \
|
||||
FN(unspec), \
|
||||
|
|
@ -3403,7 +3409,8 @@ union bpf_attr {
|
|||
FN(ringbuf_submit), \
|
||||
FN(ringbuf_discard), \
|
||||
FN(ringbuf_query), \
|
||||
FN(csum_level),
|
||||
FN(csum_level), \
|
||||
FN(skc_to_tcp6_sock),
|
||||
|
||||
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
|
||||
* function eBPF program intends to call
|
||||
|
|
|
|||
Loading…
Reference in a new issue