multipath-tcp / mptcp_net-next

Development version of the Upstream MultiPath TCP Linux kernel 🐧
https://mptcp.dev
Other
290 stars 41 forks source link

sk_is_mptcp() only works with struct tcp_sock * #453

Closed mjmartineau closed 9 months ago

mjmartineau commented 1 year ago

sk_is_mptcp() looks like it can be called using any struct sock *, but it only gives valid results with struct tcp_sock *:

static inline bool sk_is_mptcp(const struct sock *sk)
{
    return tcp_sk(sk)->is_mptcp;
}

All existing callers use it correctly.

We could rename it to something like tcpsk_is_mptcp(), or keep the existing name and add a sk_is_tcp() check.

geliangtang commented 9 months ago

@mjmartineau Mat, do you mean to change it like this:

static inline bool sk_is_mptcp(const struct sock *sk) { return sk_is_tcp(sk) ? tcp_sk(sk)->is_mptcp : false;

}

mjmartineau commented 9 months ago

As noted on the mailing list (https://lore.kernel.org/mptcp/CABbSpchzSj9jn1-t_nmamRf+oH61jecwDw08mr9U1YP9dnw8Pg@mail.gmail.com/) - instead of changing this function, will depend on extra checks with CONFIG_DEBUG_NET in the mptcp code: https://lore.kernel.org/mptcp/20240201-mptcp-check-protocol-v2-2-1e253ef51990@kernel.org/

This avoids churn and extra execution overhead in the TCP code.