MPTCP Linux Development
 help / color / mirror / Atom feed
* [PATCH mptcp-next] mptcp: shrink struct mptcp_options_received
@ 2026-09-04  3:08 Quanye Yang via B4 Relay
  2026-09-04 10:09 ` Matthieu Baerts
  0 siblings, 1 reply; 2+ messages in thread
From: Quanye Yang via B4 Relay @ 2026-09-04  3:08 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Quanye Yang

From: Quanye Yang <quanyeyang@proton.me>

struct mptcp_options_received is allocated on the stack while parsing
incoming MPTCP options.

The sender key, MP_JOIN fields, ADD_ADDR fields and MP_FAIL sequence
number are mutually exclusive, as enforced by mptcp_parse_option().
Place them in an anonymous union while keeping the existing field
access unchanged.

This reduces the structure size from 136 to 88 bytes on x86_64.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/625
Signed-off-by: Quanye Yang <quanyeyang@proton.me>
---
 net/mptcp/protocol.h | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 739f9006c1e1..6646c428dbdf 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -142,7 +142,6 @@ static inline bool before64(__u64 seq1, __u64 seq2)
 #define after64(seq2, seq1)	before64(seq1, seq2)
 
 struct mptcp_options_received {
-	u64	sndr_key;
 	u64	rcvr_key;
 	u64	data_ack;
 	u64	data_seq;
@@ -166,14 +165,22 @@ struct mptcp_options_received {
 		    __unused:1;
 	);
 	u8	join_id;
-	u32	token;
-	u32	nonce;
-	u64	thmac;
-	u8	hmac[MPTCPOPT_HMAC_LEN];
-	struct mptcp_addr_info addr;
 	struct mptcp_rm_list rm_list;
-	u64	ahmac;
-	u64	fail_seq;
+	/* Options below are mutually exclusive, see mptcp_parse_option() */
+	union {
+		u64 sndr_key;
+		struct {
+			u32 token;
+			u32 nonce;
+			u64 thmac;
+			u8 hmac[MPTCPOPT_HMAC_LEN];
+		};
+		struct {
+			struct mptcp_addr_info addr;
+			u64 ahmac;
+		};
+		u64 fail_seq;
+	};
 };
 
 static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field)

---
base-commit: 10d57dc355c99e071a198e50c45503bce944dd5c
change-id: 20260904-mptcp-shrink-opt-rx-ef8581f125df
prerequisite-message-id: <20260903-mptcp-mib-inval-opt-v1-0-84a553c552b6@kernel.org>
prerequisite-patch-id: 7f8decba16ce568283eaa86b23cd93b183aaa675
prerequisite-patch-id: c8fedc4ff2b5997f716dac0c30ec7620ecf11fc0
prerequisite-patch-id: 5abea779f2b0af347cd88d6b65bfc3b9eefff405

Best regards,
--  
Quanye Yang <quanyeyang@proton.me>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-04 10:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  3:08 [PATCH mptcp-next] mptcp: shrink struct mptcp_options_received Quanye Yang via B4 Relay
2026-09-04 10:09 ` Matthieu Baerts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox