From: Gang Yan <yangang@kylinos.cn>
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>
---
net/mptcp/protocol.c | 4 ++++
net/mptcp/protocol.h | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 46fedfa05a54..01690a84ea6d 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -4624,6 +4624,10 @@ 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));
+ /* ensure 'overhead' (alignment + sizeof(struct mptcp_data_frag)) fits in u8.
+ * 'ALIGN(1, sizeof(long)) - 1' represents the maximum of alignment.
+ */
+ BUILD_BUG_ON(ALIGN(1, sizeof(long)) - 1 + sizeof(struct mptcp_data_frag) > U8_MAX);
}
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index f5d4d7d030f2..afdead91a4d7 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -264,7 +264,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;
};
--
2.43.0