Skip to contentSkip to conversation

mptcp: two minor improvements

PATCH In review Florian Westphal 2 participants 4 messages Apr 11, 2019 – Apr 12, 2019

Subsystems (3)
lore
Share & tools
lore

Florian Westphal

author
#0 lore raw

cover mptcp: two minor improvements

First patch makes it so CONFIG_MPTCP=n build is same as building a kernel with all mptcp patches reverted.

Second patch provides minor size reduction of tcp_sock struct by closing a 6-byte hole in mptcp rx option struct.

As usual, feel free to squash them as needed.

author
#1 lore raw

PATCH 1/2 mptcp: place is_mptcp checks under ifdef guards

After this patch, a CONFIG_MPTCP=n build is the same as a build with all mptcp patches reverted.
I moved the struct members around a bit so they cover holes in the original structs.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 include/linux/tcp.h   | 7 +++++--
 include/net/mptcp.h   | 8 ++++++++
 net/ipv4/tcp_input.c  | 6 ++++--
 net/ipv4/tcp_output.c | 2 +-
 4 files changed, 18 insertions(+), 5 deletions(-)
include/linux/tcp.h +5 -2
index 71522b08ad5e..2f4178f3d127 100644
@@ -155,7 +155,9 @@ struct tcp_request_sock {
 	const struct tcp_request_sock_ops *af_specific;
 	u64				snt_synack; /* first SYNACK sent time */
 	bool				tfo_listener;
+#if IS_ENABLED(CONFIG_MPTCP)
 	bool				is_mptcp;
+#endif
 	u32				txhash;
 	u32				rcv_isn;
 	u32				snt_isn;
@@ -413,6 +415,9 @@ struct tcp_sock {
 	u32	mtu_info; /* We received an ICMP_FRAG_NEEDED / ICMPV6_PKT_TOOBIG
 			   * while socket was owned by user.
 			   */
+#if IS_ENABLED(CONFIG_MPTCP)
+	bool	is_mptcp;
+#endif
 
 #ifdef CONFIG_TCP_MD5SIG
 /* TCP AF-Specific parts; only used by MD5 Signature support so far */
@@ -429,8 +434,6 @@ struct tcp_sock {
 	 */
 	struct request_sock *fastopen_rsk;
 	u32	*saved_syn;
-
-	bool	is_mptcp;
 };
 
 enum tsq_enum {
include/net/mptcp.h +8 -0
index 0c0839d9ab38..1050bfa71f61 100644
@@ -208,6 +208,10 @@ void mptcp_write_option_header(__be32 *ptr, struct sk_buff *skb,
 			       struct tcp_sock *tp,
 			       struct mptcp_out_options *opts);
 
+static inline bool sk_is_mptcp(const struct sock *sk)
+{
+	return tcp_sk(sk)->is_mptcp;
+}
 #else
 
 static inline void mptcp_parse_option(const unsigned char *ptr, int opsize,
@@ -248,5 +252,9 @@ static inline bool mptcp_skb_ext_exist(const struct sk_buff *skb)
 	return false;
 }
 
+static inline bool sk_is_mptcp(const struct sock *sk)
+{
+	return false;
+}
 #endif /* CONFIG_MPTCP */
 #endif /* __NET_MPTCP_H */
net/ipv4/tcp_input.c +4 -2
index a3a77b6e50ae..99b5427cadbe 100644
@@ -5643,7 +5643,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 	tcp_urg(sk, skb, th);
 
 	/* Prepare MPTCP sequence data */
-	if (tcp_sk(sk)->is_mptcp)
+	if (sk_is_mptcp(sk))
 		mptcp_attach_dss(sk, skb, &tp->rx_opt);
 
 	/* step 7: process the segment text */
@@ -5861,7 +5861,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
 		tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
 		tcp_initialize_rcv_mss(sk);
 
-		if (tp->is_mptcp)
+		if (sk_is_mptcp(sk))
 			mptcp_rcv_synsent(sk);
 
 		/* Remember, tcp_poll() does not lock socket!
@@ -6442,7 +6442,9 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
 
 	tcp_rsk(req)->af_specific = af_ops;
 	tcp_rsk(req)->ts_off = 0;
+#if IS_ENABLED(CONFIG_MPTCP)
 	tcp_rsk(req)->is_mptcp = 0;
+#endif
 
 	tcp_clear_options(&tmp_opt);
 	tmp_opt.mss_clamp = af_ops->mss_clamp;
net/ipv4/tcp_output.c +1 -1
index 6d846c785e0b..0d8f2b7e481d 100644
@@ -3769,7 +3769,7 @@ void __tcp_send_ack(struct sock *sk, u32 rcv_nxt)
 	skb_set_tcp_pure_ack(buff);
 
 	/* Send it off, this clears delayed acks for us. */
-	if (tcp_sk(sk)->is_mptcp)
+	if (sk_is_mptcp(sk))
 		pr_debug("mptcp sk=%p", sk);
 
 	__tcp_transmit_skb(sk, buff, 0, (__force gfp_t)0, rcv_nxt);
Signature · 1 line
2.21.0
author
#2 lore raw

PATCH 2/2 mptcp: reorder mptcp rx options

In reply to Florian Westphal

Saves 8 bytes by closing a hole.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 include/linux/tcp.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
include/linux/tcp.h +5 -5
index 2f4178f3d127..db0297daa33c 100644
@@ -106,11 +106,6 @@ struct tcp_options_received {
 	u16	mss_clamp;	/* Maximal mss, negotiated at connection setup */
 #if IS_ENABLED(CONFIG_MPTCP)
 	struct mptcp_options_received {
-		u8      mp_capable : 1,
-			mp_join : 1,
-			dss : 1,
-			version : 4;
-		u8      flags;
 		u64     sndr_key;
 		u64     rcvr_key;
 		u64	data_ack;
@@ -118,6 +113,11 @@ struct tcp_options_received {
 		u32	subflow_seq;
 		u16	data_len;
 		__sum16	checksum;
+		u8      mp_capable : 1,
+			mp_join : 1,
+			dss : 1,
+			version : 4;
+		u8      flags;
 		u8	use_map:1,
 			dsn64:1,
 			use_checksum:1,
Signature · 1 line
2.21.0
#3 lore raw
In reply to Florian Westphal
Quoted 7 lines · Florian Westphal

First patch makes it so CONFIG_MPTCP=n build is same as building a kernel with all mptcp patches reverted.

Second patch provides minor size reduction of tcp_sock struct by closing a 6-byte hole in mptcp rx option struct.

As usual, feel free to squash them as needed.

Thanks Florian.

I squashed the second patch in to the MPTCP patch series. Peter mentioned that he has some overlapping changes with your first patch so I haven't applied that.

--
Mat Martineau
Intel