This patch addressed to the comments in [1] from BPF maintainer Alexei
Starovoitov:
'''
On Fri, Sep 18, 2020 at 02:10:42PM +0200, Nicolas Rybowski wrote:
> +
> +BPF_CALL_1(bpf_mptcp_sock, struct sock *, sk)
> +{
> + if (sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk)) {
> + struct mptcp_subflow_context *mptcp_sfc = mptcp_subflow_ctx(sk);
Could you add !sk check here as well?
See commit 8c33dadc3e0e ("bpf: Bpf_skc_to_* casting helpers require a NULL check on sk")
It's not strictly necessary yet, but see below.
'''
I added this !sk check as he suggested.
[1]
https://lore.kernel.org/netdev/20200922040830.3iis6xiavhvpfq3v@ast-mbp.dhcp.thefacebook.com/
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
v2:
- keep RET_PTR_TO_MPTCP_SOCK_OR_NULL. If we use RET_PTR_TO_BTF_ID_OR_NULL
instead of RET_PTR_TO_MPTCP_SOCK_OR_NULL as Alexei suggested, the
"userspace" tests developed by Nicolas will break.
---
net/mptcp/bpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
index 5332469fbb28..165edec3b276 100644
--- a/net/mptcp/bpf.c
+++ b/net/mptcp/bpf.c
@@ -56,7 +56,7 @@ u32 bpf_mptcp_sock_convert_ctx_access(enum bpf_access_type type,
BPF_CALL_1(bpf_mptcp_sock, struct sock *, sk)
{
- if (sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk)) {
+ if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk)) {
struct mptcp_subflow_context *mptcp_sfc = mptcp_subflow_ctx(sk);
return (unsigned long)mptcp_sfc->conn;
--
2.34.1