Skip to contentSkip to conversation

tcp: remove unnecessary update for tp->write_seq in tcp_connect()

PATCH Superseded xin.guo 2 participants 3 messages Oct 5, 2024 – Oct 6, 2024

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

xin.guo

author
#0 lore raw

PATCH v2 1/1 tcp: remove unnecessary update for tp->write_seq in tcp_connect()

From: "xin.guo" <[email protected]>

Commit 783237e8daf13("net-tcp: Fast Open client - sending SYN-data") introduces tcp_connect_queue_skb() and it would overwrite tcp->write_seq, so it is no need to update tp->write_seq before invoking tcp_connect_queue_skb()

---
 net/ipv4/tcp_output.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp_output.c +4 -1
index 4fd746b..ee8ab9a 100644
@@ -4134,7 +4134,10 @@ int tcp_connect(struct sock *sk)
 	if (unlikely(!buff))
 		return -ENOBUFS;
 
-	tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
+	/*SYN eats a sequence byte, write_seq updated by
+	 *tcp_connect_queue_skb().
+	 */
+	tcp_init_nondata_skb(buff, tp->write_seq, TCPHDR_SYN);
 	tcp_mstamp_refresh(tp);
 	tp->retrans_stamp = tcp_time_stamp_ts(tp);
 	tcp_connect_queue_skb(sk, buff);
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 4 lines · xin.guo

From: "xin.guo" <[email protected]>

Commit 783237e8daf13("net-tcp: Fast Open client - sending SYN-data")

To match Linux commit message style, please insert a space between the SHA1 and the patch title, like so:

Commit 783237e8daf13 ("net-tcp: Fast Open client - sending SYN-data")

Quoted 16 lines

introduces tcp_connect_queue_skb() and it would overwrite tcp->write_seq, so it is no need to update tp->write_seq before invoking tcp_connect_queue_skb()

---
 net/ipv4/tcp_output.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp_output.c +0 -0
index 4fd746b..ee8ab9a 100644
@@ -4134,7 +4134,10 @@ int tcp_connect(struct sock *sk)
        if (unlikely(!buff))
                return -ENOBUFS;

net/ipv4/tcp_output.c int tcp_connect(struct sock *sk)

Quoted 10 lines
net/ipv4/tcp_output.c +4 -2
 
-       tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
+       /*SYN eats a sequence byte, write_seq updated by
+        *tcp_connect_queue_skb().
+        */
+       tcp_init_nondata_skb(buff, tp->write_seq, TCPHDR_SYN);
        tcp_mstamp_refresh(tp);
        tp->retrans_stamp = tcp_time_stamp_ts(tp);
        tcp_connect_queue_skb(sk, buff);
--

As in the example provided by Eric, please use Linux kernel C comment style, which places a space character between the * and the first character of the comment text on each line. For example:

/* SYN eats a sequence byte, write_seq is updated by
* tcp_connect_queue_skb().
*/

For more information, see:

https://www.kernel.org/doc/html/v6.11/process/coding-style.html#commenting

thanks,
neal

author
#2 lore raw

Thanks neal, my bad,
I will read the document and post v3 for this patch

Quoted 53 lines · Neal Cardwell
Quoted 4 lines · xin.guo

From: "xin.guo" <[email protected]>

Commit 783237e8daf13("net-tcp: Fast Open client - sending SYN-data")

To match Linux commit message style, please insert a space between the SHA1 and the patch title, like so:

Commit 783237e8daf13 ("net-tcp: Fast Open client - sending SYN-data")

Quoted 16 lines

introduces tcp_connect_queue_skb() and it would overwrite tcp->write_seq, so it is no need to update tp->write_seq before invoking tcp_connect_queue_skb()

---
 net/ipv4/tcp_output.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp_output.c +0 -0
index 4fd746b..ee8ab9a 100644
@@ -4134,7 +4134,10 @@ int tcp_connect(struct sock *sk)
        if (unlikely(!buff))
                return -ENOBUFS;

net/ipv4/tcp_output.c int tcp_connect(struct sock *sk)

Quoted 10 lines
net/ipv4/tcp_output.c +4 -2
 
-       tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
+       /*SYN eats a sequence byte, write_seq updated by
+        *tcp_connect_queue_skb().
+        */
+       tcp_init_nondata_skb(buff, tp->write_seq, TCPHDR_SYN);
        tcp_mstamp_refresh(tp);
        tp->retrans_stamp = tcp_time_stamp_ts(tp);
        tcp_connect_queue_skb(sk, buff);
--

As in the example provided by Eric, please use Linux kernel C comment style, which places a space character between the * and the first character of the comment text on each line. For example:

/* SYN eats a sequence byte, write_seq is updated by
* tcp_connect_queue_skb().
*/

For more information, see:

https://www.kernel.org/doc/html/v6.11/process/coding-style.html#commenting

thanks,
neal