diff mbox series

[net-next] tcp: remove unnecessary update for tp->write_seq in tcp_connect()

Message ID 1727849643-11648-1-git-send-email-guoxin0309@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] tcp: remove unnecessary update for tp->write_seq in tcp_connect() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 3 maintainers not CCed: pabeni@redhat.com kuba@kernel.org dsahern@kernel.org
netdev/build_clang success Errors and warnings before: 11 this patch: 11
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-02--09-00 (tests: 750)

Commit Message

xin.guo Oct. 2, 2024, 6:14 a.m. UTC
From: "xin.guo" <guoxin0309@gmail.com>

Commit 783237e8daf13("net-tcp: Fast Open client - sending SYN-data")
introduce 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()

Signed-off-by: xin.guo <guoxin0309@gmail.com>
---
 net/ipv4/tcp_output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Dumazet Oct. 2, 2024, 7:33 a.m. UTC | #1
On Wed, Oct 2, 2024 at 8:14 AM xin.guo <guoxin0309@gmail.com> wrote:
>
> From: "xin.guo" <guoxin0309@gmail.com>
>
> Commit 783237e8daf13("net-tcp: Fast Open client - sending SYN-data")
> introduce 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()
>
> Signed-off-by: xin.guo <guoxin0309@gmail.com>
> ---
>  net/ipv4/tcp_output.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 4fd746b..f255c7d 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -4134,7 +4134,7 @@ int tcp_connect(struct sock *sk)
>         if (unlikely(!buff))
>                 return -ENOBUFS;
>
> -       tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
> +       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
>

At line 3616, there is this comment :

/* FIN eats a sequence byte, write_seq advanced by tcp_queue_skb(). */

I think you need to add a similar one. Future readers will thank you.

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 4fd746bd4d54f621601b20c3821e71370a4a615a..86dea6f022d36cb56ef5678add2bd63132eee20f
100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -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);
xin.guo Oct. 2, 2024, 9:37 a.m. UTC | #2
Thanks Eric, I will send v2 for this patch.

On Wed, Oct 2, 2024 at 3:33 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Wed, Oct 2, 2024 at 8:14 AM xin.guo <guoxin0309@gmail.com> wrote:
> >
> > From: "xin.guo" <guoxin0309@gmail.com>
> >
> > Commit 783237e8daf13("net-tcp: Fast Open client - sending SYN-data")
> > introduce 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()
> >
> > Signed-off-by: xin.guo <guoxin0309@gmail.com>
> > ---
> >  net/ipv4/tcp_output.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> > index 4fd746b..f255c7d 100644
> > --- a/net/ipv4/tcp_output.c
> > +++ b/net/ipv4/tcp_output.c
> > @@ -4134,7 +4134,7 @@ int tcp_connect(struct sock *sk)
> >         if (unlikely(!buff))
> >                 return -ENOBUFS;
> >
> > -       tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
> > +       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
> >
>
> At line 3616, there is this comment :
>
> /* FIN eats a sequence byte, write_seq advanced by tcp_queue_skb(). */
>
> I think you need to add a similar one. Future readers will thank you.
>
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 4fd746bd4d54f621601b20c3821e71370a4a615a..86dea6f022d36cb56ef5678add2bd63132eee20f
> 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -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);
diff mbox series

Patch

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 4fd746b..f255c7d 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -4134,7 +4134,7 @@  int tcp_connect(struct sock *sk)
 	if (unlikely(!buff))
 		return -ENOBUFS;
 
-	tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
+	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);