Skip to contentSkip to conversation

tcp: remove unnecessary update for tp->write_seq in tcp_connect() 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()

PATCH In review xin.guo 1 participant 2 messages Oct 3, 2024

Subsystems (3)
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() 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()

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

---
 net/ipv4/tcp_output.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/ipv4/tcp_output.c +5 -2
index 4fd746b..3265f34 100644
@@ -4133,8 +4133,11 @@ int tcp_connect(struct sock *sk)
 	buff = tcp_stream_alloc_skb(sk, sk->sk_allocation, true);
 	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
author
#1 lore raw

Sorry for this post, please ignore it,

Quoted 29 lines · xin.guo

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

---
 net/ipv4/tcp_output.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/ipv4/tcp_output.c +5 -3
index 4fd746b..3265f34 100644
@@ -4133,8 +4133,11 @@ int tcp_connect(struct sock *sk)
        buff = tcp_stream_alloc_skb(sk, sk->sk_allocation, true);
        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);
--

1.8.3.1