From: Yonghong Song Date: Tue, 2 May 2023 18:05:43 +0000 (-0700) Subject: bpf: Emit struct bpf_tcp_sock type in vmlinux BTF X-Git-Tag: v6.6.17~4555^2~269^2~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf6882aebd0ea67558764d44ddeffc7d253c6eb8;p=platform%2Fkernel%2Flinux-rpi.git bpf: Emit struct bpf_tcp_sock type in vmlinux BTF In one of our internal testing, we found a case where - uapi struct bpf_tcp_sock is in vmlinux.h where vmlinux.h is not generated from the testing kernel - struct bpf_tcp_sock is not in vmlinux BTF The above combination caused bpf load failure as the following memory access struct bpf_tcp_sock *tcp_sock = ...; ... tcp_sock->snd_cwnd ... needs CORE relocation but the relocation cannot be resolved since the kernel BTF does not have corresponding type. Similar to other previous cases (nf_conn___init, tcp6_sock, mctcp_sock, etc.), add the type to vmlinux BTF with BTF_EMIT_TYPE macro. Signed-off-by: Yonghong Song Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20230502180543.1832140-1-yhs@fb.com --- diff --git a/net/core/filter.c b/net/core/filter.c index d9ce04c..451b0ec 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -6916,6 +6916,8 @@ u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type, FIELD)); \ } while (0) + BTF_TYPE_EMIT(struct bpf_tcp_sock); + switch (si->off) { case offsetof(struct bpf_tcp_sock, rtt_min): BUILD_BUG_ON(sizeof_field(struct tcp_sock, rtt_min) !=