[RFC net-next 12/17] tls: add mptcp support for sk_poll
From: Geliang Tang <geliang@kernel.org>
Date: 2026-06-22 10:45:22
Also in:
mptcp
Subsystem:
networking [general], networking [mptcp], networking [tls], the rest · Maintainers:
"David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthieu Baerts, Mat Martineau, John Fastabend, Sabrina Dubroca, Linus Torvalds
From: Geliang Tang <redacted> The tls_sk_poll() function currently uses tcp_poll() unconditionally to obtain the base poll mask, which works only for TCP. This prevents TLS over MPTCP from working correctly with poll(). Make the poll function protocol-aware by selecting the appropriate poll function based on sk->sk_protocol. For TCP it calls tcp_poll(), for MPTCP it calls mptcp_poll() (guarded by CONFIG_MPTCP). Any other protocol returns 0. Also export mptcp_poll() symbol so that the TLS module can use it. Co-developed-by: Gang Yan <redacted> Signed-off-by: Gang Yan <redacted> Co-developed-by: Zqiang <qiang.zhang@linux.dev> Signed-off-by: Zqiang <qiang.zhang@linux.dev> Signed-off-by: Geliang Tang <redacted> --- include/net/mptcp.h | 9 +++++++++ net/mptcp/protocol.c | 5 +++-- net/tls/tls_main.c | 17 ++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index ba2257986b13..b0a172c38891 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h@@ -239,6 +239,9 @@ static inline __be32 mptcp_reset_option(const struct sk_buff *skb) } void mptcp_active_detect_blackhole(struct sock *sk, bool expired); + +__poll_t mptcp_poll(struct file *file, struct socket *sock, + struct poll_table_struct *wait); #else static inline void mptcp_init(void)
@@ -316,6 +319,12 @@ static inline struct request_sock *mptcp_subflow_reqsk_alloc(const struct reques static inline __be32 mptcp_reset_option(const struct sk_buff *skb) { return htonl(0u); } static inline void mptcp_active_detect_blackhole(struct sock *sk, bool expired) { } + +static inline __poll_t mptcp_poll(struct file *file, struct socket *sock, + struct poll_table_struct *wait) +{ + return 0; +} #endif /* CONFIG_MPTCP */ #if IS_ENABLED(CONFIG_MPTCP_IPV6)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index f4cd7a6e5770..169bd468f212 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c@@ -4446,8 +4446,8 @@ static __poll_t mptcp_check_writeable(struct mptcp_sock *msk) return 0; } -static __poll_t mptcp_poll(struct file *file, struct socket *sock, - struct poll_table_struct *wait) +__poll_t mptcp_poll(struct file *file, struct socket *sock, + struct poll_table_struct *wait) { struct sock *sk = sock->sk; struct mptcp_sock *msk;
@@ -4494,6 +4494,7 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock, return mask; } +EXPORT_SYMBOL_GPL(mptcp_poll); static struct sk_buff *mptcp_recv_skb(struct sock *sk, u32 *off) {
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index 170ccbb9d36d..fa9fda3480da 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c@@ -416,6 +416,21 @@ static void tls_sk_proto_close(struct sock *sk, long timeout) tls_ctx_free(sk, ctx); } +static __poll_t tls_proto_poll(struct file *file, struct socket *sock, + struct poll_table_struct *wait) +{ + switch (sock->sk->sk_protocol) { + case IPPROTO_TCP: + return tcp_poll(file, sock, wait); +#ifdef CONFIG_MPTCP + case IPPROTO_MPTCP: + return mptcp_poll(file, sock, wait); +#endif + default: + return 0; + } +} + static __poll_t tls_sk_poll(struct file *file, struct socket *sock, struct poll_table_struct *wait) {
@@ -426,7 +441,7 @@ static __poll_t tls_sk_poll(struct file *file, struct socket *sock, u8 shutdown; int state; - mask = tcp_poll(file, sock, wait); + mask = tls_proto_poll(file, sock, wait); state = inet_sk_state_load(sk); shutdown = READ_ONCE(sk->sk_shutdown);
--
2.53.0