diff mbox series

net:ipv4: send an ack when seg.ack > snd.nxt

Message ID 20220319090142.137998-1-zhouzhouyi@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net:ipv4: send an ack when seg.ack > snd.nxt | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Zhouyi Zhou March 19, 2022, 9:01 a.m. UTC
From: Zhouyi Zhou <zhouzhouyi@gmail.com>

In RFC 793, page 72: If the ACK acks something not yet sent
(SEG.ACK > SND.NXT) then send an ACK, drop the segment,
and return. Fix Linux's behavior according to RFC 793.

Reported-by: Wei Xu <xuweihf@ustc.edu.cn>
Signed-off-by: Wei Xu <xuweihf@ustc.edu.cn>
Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
---
 net/ipv4/tcp_input.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Florian Westphal March 19, 2022, 10:04 a.m. UTC | #1
zhouzhouyi@gmail.com <zhouzhouyi@gmail.com> wrote:
> -	if (after(ack, tp->snd_nxt))
> +	if (after(ack, tp->snd_nxt)) {
> +		tcp_send_ack(sk);
>  		return -1;
> +	}

If we really need to do this we need to
  if (!(flag & FLAG_NO_CHALLENGE_ACK))
	tcp_send_challenge_ack(sk);

... else this might result in two acks?
Whats the problem thats being fixed here?
Zhouyi Zhou March 19, 2022, 10:34 a.m. UTC | #2
Dear Florian

Thank you for reviewing my patch ;-)

On Sat, Mar 19, 2022 at 6:04 PM Florian Westphal <fw@strlen.de> wrote:
>
> zhouzhouyi@gmail.com <zhouzhouyi@gmail.com> wrote:
> > -     if (after(ack, tp->snd_nxt))
> > +     if (after(ack, tp->snd_nxt)) {
> > +             tcp_send_ack(sk);
> >               return -1;
> > +     }
>
> If we really need to do this we need to
>   if (!(flag & FLAG_NO_CHALLENGE_ACK))
Yes, we need to check FLAG_NO_CHALLENGE_ACK here to avoid two acks.
>         tcp_send_challenge_ack(sk);
>
> ... else this might result in two acks?
> Whats the problem thats being fixed here?
We fix the code to let it match what RFC 793 page 72 has described. I
guess this is also what the intermediate internet devices (routers,
firewalls for example) expect us to do ;-)

Thanks again
Zhouyi
diff mbox series

Patch

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index bfe4112e000c..c10f84599655 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3771,11 +3771,13 @@  static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
 		goto old_ack;
 	}
 
-	/* If the ack includes data we haven't sent yet, discard
-	 * this segment (RFC793 Section 3.9).
+	/* If the ack includes data we haven't sent yet, then send
+	 * an ack, drop this segment, and return (RFC793 Section 3.9).
 	 */
-	if (after(ack, tp->snd_nxt))
+	if (after(ack, tp->snd_nxt)) {
+		tcp_send_ack(sk);
 		return -1;
+	}
 
 	if (after(ack, prior_snd_una)) {
 		flag |= FLAG_SND_UNA_ADVANCED;