[RFC mptcp-next v4 02/10] tls: switch to MPTCP_SKB_CB

Geliang Tang
2025-12-12T02:27:29Z

To extend MPTCP support based on TCP TLS, corresponding MPTCP-specific
macro MPTCP_SKB_CB() has been exported into net/mptcp.h.

TLS implementation switches between the respective TCP and MPTCP macros
based on the detected protocol.

Co-developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
include/net/mptcp.h | 10 ++++++++++
net/mptcp/protocol.h | 10 ----------
net/tls/tls_strp.c | 8 ++++++--
net/tls/tls_sw.c | 4 +++-
4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index 82660374859a..050c2e820fc4 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -132,6 +132,16 @@ struct mptcp_pm_ops {
void (*release)(struct mptcp_sock *msk);
} ____cacheline_aligned_in_smp;

+struct mptcp_skb_cb {
+ u64 map_seq;
+ u64 end_seq;
+ u32 offset;
+ u8 has_rxtstamp;
+ u8 cant_coalesce;
+};
+
+#define MPTCP_SKB_CB(__skb) ((struct mptcp_skb_cb *)&((__skb)->cb[0]))
+
#ifdef CONFIG_MPTCP
void mptcp_init(void);

diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index cd5266099993..75f2fd05ece4 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -125,16 +125,6 @@
#define MPTCP_SYNC_STATE 6
#define MPTCP_SYNC_SNDBUF 7

-struct mptcp_skb_cb {
- u64 map_seq;
- u64 end_seq;
- u32 offset;
- u8 has_rxtstamp;
- u8 cant_coalesce;
-};
-
-#define MPTCP_SKB_CB(__skb) ((struct mptcp_skb_cb *)&((__skb)->cb[0]))
-
static inline bool before64(__u64 seq1, __u64 seq2)
{
return (__s64)(seq1 - seq2) < 0;
diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c
index 98e12f0ff57e..cdbcb07a52f8 100644
--- a/net/tls/tls_strp.c
+++ b/net/tls/tls_strp.c
@@ -439,7 +439,9 @@ static bool tls_strp_check_queue_ok(struct tls_strparser *strp)

first = skb_shinfo(strp->anchor)->frag_list;
skb = first;
- seq = TCP_SKB_CB(first)->seq;
+ seq = sk_is_msk(strp->sk) ?
+ MPTCP_SKB_CB(first)->map_seq :
+ TCP_SKB_CB(first)->seq;

/* Make sure there's no duplicate data in the queue,
* and the decrypted status matches.
@@ -449,7 +451,9 @@ static bool tls_strp_check_queue_ok(struct tls_strparser *strp)
len -= skb->len;
skb = skb->next;

- if (TCP_SKB_CB(skb)->seq != seq)
+ if ((sk_is_msk(strp->sk) ?
+ MPTCP_SKB_CB(skb)->map_seq :
+ TCP_SKB_CB(skb)->seq) != seq)
return false;
if (skb_cmp_decrypted(first, skb))
return false;
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 9937d4c810f2..c35c25abc40c 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -2489,7 +2489,9 @@ int tls_rx_msg_size(struct tls_strparser *strp, struct sk_buff *skb)
}

tls_device_rx_resync_new_rec(strp->sk, data_len + TLS_HEADER_SIZE,
- TCP_SKB_CB(skb)->seq + strp->stm.offset);
+ (sk_is_msk(strp->sk) ?
+ MPTCP_SKB_CB(skb)->map_seq :
+ TCP_SKB_CB(skb)->seq) + strp->stm.offset);
return data_len + TLS_HEADER_SIZE;

read_failure:
--
2.51.0