]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mptcp: reduce 'overhead' from u16 to u8
authorGang Yan <yangang@kylinos.cn>
Fri, 3 Apr 2026 11:29:27 +0000 (13:29 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 7 Apr 2026 02:14:26 +0000 (19:14 -0700)
The 'overhead' in struct mptcp_data_frag can safely use u8, as it
represents 'alignment + sizeof(mptcp_data_frag)'. With a maximum
alignment of 7('ALIGN(1, sizeof(long)) - 1'), the overhead is at most
47, well below U8_MAX and validated with BUILD_BUG_ON().

This patch also adds a field named 'unused' for further extensions.

Signed-off-by: Gang Yan <yangang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20260403-net-next-mptcp-msg_eor-misc-v1-1-b0b33bea3fed@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/mptcp/protocol.c
net/mptcp/protocol.h

index 239fb9e75c7c2e97546de20f145c696b3c33f51b..79315e575d074b346dccbdc4f6c5d015e82bcd41 100644 (file)
@@ -4616,6 +4616,12 @@ void __init mptcp_proto_init(void)
        inet_register_protosw(&mptcp_protosw);
 
        BUILD_BUG_ON(sizeof(struct mptcp_skb_cb) > sizeof_field(struct sk_buff, cb));
+
+       /* struct mptcp_data_frag: 'overhead' corresponds to the alignment
+        * (ALIGN(1, sizeof(long)) - 1, so 8-1) + the struct's size
+        */
+       BUILD_BUG_ON(ALIGN(1, sizeof(long)) - 1 + sizeof(struct mptcp_data_frag)
+                    > U8_MAX);
 }
 
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
index 0bd1ee860316dd25e88beb1b9ba020abdc32f7cb..02031007100b2c61551235640daaa3eadd9f193b 100644 (file)
@@ -263,7 +263,8 @@ struct mptcp_data_frag {
        u64 data_seq;
        u16 data_len;
        u16 offset;
-       u16 overhead;
+       u8 overhead;
+       u8 __unused;
        u16 already_sent;
        struct page *page;
 };