From patchwork Mon Jan 13 13:55:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13937406 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A4B0125B2 for ; Mon, 13 Jan 2025 13:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736776563; cv=none; b=UYzTSSArsWGZmFfgKBxjL4JUw3fJN0FKkuuG8GT8/t5VilzLN03m/oyg5KqfxgHgGF2ipcgiKDLrB/qOMJKbof5CsdnRNn9H3mKjTQfRnLyYHLxhhfhiu565W0xBiXDchaeMX0QM/1hugH4Gro/uyi5Q8FZ7Tts8ibBrn7oTFeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736776563; c=relaxed/simple; bh=Tss+c/6QYRJBC1geYN31vpcWnf9EXnkMEuhMS1z1PmA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VRDLJDxvu7eYkAholy8Rlq1OKE3v2EshyYZHtzeuz99w7xdz0GdI0eiPk3+Br+Q6Zt1svaIQkJhRe/hvhpP73e0DvMFMQPtzHXrAL6f9K6hFnm1TsKa3dHyCId0VTiIyE4vqywmeNoxWIo3cXLNAmge7mUPGS/7f1EPZbXDyzic= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=eQw7qrLp; arc=none smtp.client-ip=209.85.219.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eQw7qrLp" Received: by mail-qv1-f73.google.com with SMTP id 6a1803df08f44-6d8860ab00dso72030916d6.0 for ; Mon, 13 Jan 2025 05:56:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736776561; x=1737381361; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=EdVAGJJ9HFgwWIAVRFq+e5v8FGcwI8PQJteOCqk6Y+A=; b=eQw7qrLpf/23KcGv5gpyySN1ltlMdzoFQJoyyfkdA0T4rm1LnwrcJYvPnfoK0TkcHR LLZA2Un8TxrSr82vy9+fN79HJqLn0xrbA5NsCaeoT9NrYSxXa+QKYqQc3i45EDv2A7Rk HW+RB6iunfGplyaDoqhDvatoORfYYqNPy7zPbTiPN1wsTStldKK3rDwjAYJ/jrc2vqgW EUeV2FnlW27vPYYoiurpkTjmnRmG+rRr/wNJtsSd8QpUOt66bvyWqctFNHbh9hPu1HTS BorzYqDMXNIC5tebMZfijkXEh5hNgOQ25sQcMDagzndYcWzYv2Yx10Mqteo4BDfN6VsH 8FXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736776561; x=1737381361; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EdVAGJJ9HFgwWIAVRFq+e5v8FGcwI8PQJteOCqk6Y+A=; b=anHMzOfzhv31K45S3KoA3y3D8YfEfCcLXgn7AnohBirLL09vDDJrQfJCgrienT+Aa1 eQqJEziLiDFE0Cq/mDUVOk5+P+opBZ5jaLqdicssShlBc92GKyiacd24csWWajGQYLvK joTzpf2T3JimvlPUgaE30ZqLOUG7ojWQgqlWh5l74jXzxANpjGfmyRXhXLOY1ZgCsMoH E7NsNKPKrVaUKn9arZ0F7f7rK+sf7ct0jfREAu70C7qO3uOdBoqMKiUWHzaTT/bJ5hMv FNYygIAgcrcW5KnL+0jqgR9uBmzd3HXc5kRf/SVUBIjvVVDBaMKEHn64MUqBQICOkoNS I3kQ== X-Gm-Message-State: AOJu0YyMLwsF8QdAoNyZwmjQhy4z77WzRZ5YRTbI1prNBGhA4XVezIG1 4308PeRxJEa3LoD+DLzkEY3LLaI7Eyug9Lxa4S4iKNuajCdiOd+BfSruldgGUQCD3PsgapNwbQa qYd3mgsdEpw== X-Google-Smtp-Source: AGHT+IGigptF8sqvn24HdosS5Uy2pKU1lEDMTreI6DY3o1uZFoZzvp4IgXfniQRiN497SHdrcVaMjBX2WoJY8A== X-Received: from qvbks22.prod.google.com ([2002:a05:6214:3116:b0:6dc:c098:fa40]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:570b:b0:6d1:9e72:596a with SMTP id 6a1803df08f44-6df9b2dadefmr374515166d6.37.1736776561163; Mon, 13 Jan 2025 05:56:01 -0800 (PST) Date: Mon, 13 Jan 2025 13:55:56 +0000 In-Reply-To: <20250113135558.3180360-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250113135558.3180360-1-edumazet@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250113135558.3180360-2-edumazet@google.com> Subject: [PATCH v2 net-next 1/3] tcp: add drop_reason support to tcp_disordered_ack() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Simon Horman , Neal Cardwell , Kuniyuki Iwashima , Jason Xing , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Following patch is adding a new drop_reason to tcp_validate_incoming(). Change tcp_disordered_ack() to not return a boolean anymore, but a drop reason. Change its name to tcp_disordered_ack_check() Refactor tcp_validate_incoming() to ease the code review of the following patch, and reduce indentation level. This patch is a refactor, with no functional change. Signed-off-by: Eric Dumazet Reviewed-by: Neal Cardwell Reviewed-by: Kuniyuki Iwashima Reviewed-by: Jason Xing --- net/ipv4/tcp_input.c | 79 ++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 4811727b8a02258ec6fa1fd129beecf7cbb0f90e..24966dd3e49f698e110f8601e098b65afdf0718a 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4450,34 +4450,38 @@ static u32 tcp_tsval_replay(const struct sock *sk) return inet_csk(sk)->icsk_rto * 1200 / HZ; } -static int tcp_disordered_ack(const struct sock *sk, const struct sk_buff *skb) +static enum skb_drop_reason tcp_disordered_ack_check(const struct sock *sk, + const struct sk_buff *skb) { const struct tcp_sock *tp = tcp_sk(sk); const struct tcphdr *th = tcp_hdr(skb); - u32 seq = TCP_SKB_CB(skb)->seq; + SKB_DR_INIT(reason, TCP_RFC7323_PAWS); u32 ack = TCP_SKB_CB(skb)->ack_seq; + u32 seq = TCP_SKB_CB(skb)->seq; - return /* 1. Pure ACK with correct sequence number. */ - (th->ack && seq == TCP_SKB_CB(skb)->end_seq && seq == tp->rcv_nxt) && + /* 1. Is this not a pure ACK ? */ + if (!th->ack || seq != TCP_SKB_CB(skb)->end_seq) + return reason; - /* 2. ... and duplicate ACK. */ - ack == tp->snd_una && + /* 2. Is its sequence not the expected one ? */ + if (seq != tp->rcv_nxt) + return reason; - /* 3. ... and does not update window. */ - !tcp_may_update_window(tp, ack, seq, ntohs(th->window) << tp->rx_opt.snd_wscale) && + /* 3. Is this not a duplicate ACK ? */ + if (ack != tp->snd_una) + return reason; - /* 4. ... and sits in replay window. */ - (s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) <= - tcp_tsval_replay(sk); -} + /* 4. Is this updating the window ? */ + if (tcp_may_update_window(tp, ack, seq, ntohs(th->window) << + tp->rx_opt.snd_wscale)) + return reason; -static inline bool tcp_paws_discard(const struct sock *sk, - const struct sk_buff *skb) -{ - const struct tcp_sock *tp = tcp_sk(sk); + /* 5. Is this not in the replay window ? */ + if ((s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) > + tcp_tsval_replay(sk)) + return reason; - return !tcp_paws_check(&tp->rx_opt, TCP_PAWS_WINDOW) && - !tcp_disordered_ack(sk, skb); + return 0; } /* Check segment sequence number for validity. @@ -5949,23 +5953,28 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, SKB_DR(reason); /* RFC1323: H1. Apply PAWS check first. */ - if (tcp_fast_parse_options(sock_net(sk), skb, th, tp) && - tp->rx_opt.saw_tstamp && - tcp_paws_discard(sk, skb)) { - if (!th->rst) { - if (unlikely(th->syn)) - goto syn_challenge; - NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED); - if (!tcp_oow_rate_limited(sock_net(sk), skb, - LINUX_MIB_TCPACKSKIPPEDPAWS, - &tp->last_oow_ack_time)) - tcp_send_dupack(sk, skb); - SKB_DR_SET(reason, TCP_RFC7323_PAWS); - goto discard; - } - /* Reset is accepted even if it did not pass PAWS. */ - } - + if (!tcp_fast_parse_options(sock_net(sk), skb, th, tp) || + !tp->rx_opt.saw_tstamp || + tcp_paws_check(&tp->rx_opt, TCP_PAWS_WINDOW)) + goto step1; + + reason = tcp_disordered_ack_check(sk, skb); + if (!reason) + goto step1; + /* Reset is accepted even if it did not pass PAWS. */ + if (th->rst) + goto step1; + if (unlikely(th->syn)) + goto syn_challenge; + + NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED); + if (!tcp_oow_rate_limited(sock_net(sk), skb, + LINUX_MIB_TCPACKSKIPPEDPAWS, + &tp->last_oow_ack_time)) + tcp_send_dupack(sk, skb); + goto discard; + +step1: /* Step 1: check sequence number */ reason = tcp_sequence(tp, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq); if (reason) { From patchwork Mon Jan 13 13:55:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13937407 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 819992397B5 for ; Mon, 13 Jan 2025 13:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736776565; cv=none; b=BhgHReOq1F8QCh6Gr304DOzEB7DPOMSigL7nsFYwbrbdnPRssaeHhWksHXK3pctiK/6zKtT8oByhIQcxl3XR6k2eIMqLzpzcviOPlmHOB52hU9oTkDKAebOymeRTFFdTNQtf/RCVrRx65S2SXVQaHXeylm81LeSFRU0U41p10R8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736776565; c=relaxed/simple; bh=Kvm9+Dez3YLepfPHoKcca3bIIsvFVh+k7L4BogIbXCs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VOpJK24+tdHzzdz3/d+ewUgFV0otJmwtm24Zts1LJ5apQqCuEf+tjn+wOA8wiELxSCClXvKwR03gshi7515jfaYkYW9OdBbynrfyy9oy/aa+fGLz/nzT+4h4PqPrcINLE4MUgTyMToxzHh8W0AVMi5RZPXtTfkhh7L8ieBJpFnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=n1SmmVfa; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="n1SmmVfa" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e53bf9e60e4so9957074276.1 for ; Mon, 13 Jan 2025 05:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736776562; x=1737381362; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4FMDm8S+gZ1xmkoqPNsmlzlxEiE3dU72laviv30xoSo=; b=n1SmmVfa9voLNNPjT+GE8CThy146MfSCsPFjMiGBpdxJ0y9cpZpV8drP0mUeTTvhOJ 0SBfzr7uX9iSeHFA4cprmt0x8vcFMLlFG8mvaT791aDPu196COVaiKYicsX8PVwYSFhu jcv0I8567RRWODXuNpHvSqxkVgYLEJ4cno20YPiTI3Y/5Vl4Npsq3sTuEPiFVbd5vgXz F8whQLp0dFeDBwGygJSW2kJlyD2fKBZ8FKzXcD085fqq5w40KDDR99Zc3yvHzK5Tu4EZ xRcoiynDZw+ehDDvl2gkewSsVoUti9TNr9DMkgteS9FV+b3joAT69HawFLEQO+c22CEC 4LQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736776562; x=1737381362; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4FMDm8S+gZ1xmkoqPNsmlzlxEiE3dU72laviv30xoSo=; b=MMuVp1REtDHrNI+r+kI+vZkEu4d+5JEbLpjlmDQhPxj7nkTfVmof444Q10JujIKVI0 raz5uXiATJLqJgFYMWy7mGC8YlQn6R59JjiY3QqV/IsCRd7yZ6ZRgtkPCoMcCct5z06P 9VxQtl0aewPqLY9nlNypWm89LwNKN+kXufnMfXbN1DDKOFWUD6HQnmx8xNyZytdd0eUq N5IJY34AQUojkfQonx2TADBVXzliHjxudeiM0jEo0o/Ljc+XYXrl4eu5ELgi4eIK6lBK gC++zdXr+XqJ3cFOdcwCAVzoZC7hgnXJcILVKK0wBHEdmHon/3SOqFIc7fnerzY5hC4B PJvA== X-Gm-Message-State: AOJu0YyNBtrmknWNNEndTw/WxzoA8xp9fwF1I54EjsG7+YxzsMQ4X1P4 rpHr3wK6yaGKiAeA5pzsUn1Foq0b5ab6eu/JcNS/UxWJMKqLmQubdCtjMYh0r92r80S66dYNxuH oXeJziJ1JXQ== X-Google-Smtp-Source: AGHT+IEhgnvYKvLO6EH1TYccJZvZbOTbHFZsJf8V6Z/G3GgHrOVRHaZV0nfZ7svePS4LNYuuPymNYsEE7p7oXw== X-Received: from ywbhr4.prod.google.com ([2002:a05:690c:6404:b0:6f5:278e:e957]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:690c:998c:b0:6ef:7640:e18a with SMTP id 00721157ae682-6f5312dd1a3mr162662417b3.31.1736776562456; Mon, 13 Jan 2025 05:56:02 -0800 (PST) Date: Mon, 13 Jan 2025 13:55:57 +0000 In-Reply-To: <20250113135558.3180360-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250113135558.3180360-1-edumazet@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250113135558.3180360-3-edumazet@google.com> Subject: [PATCH v2 net-next 2/3] tcp: add TCP_RFC7323_PAWS_ACK drop reason From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Simon Horman , Neal Cardwell , Kuniyuki Iwashima , Jason Xing , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org XPS can cause reorders because of the relaxed OOO conditions for pure ACK packets. For hosts not using RFS, what can happpen is that ACK packets are sent on behalf of the cpu processing NIC interrupts, selecting TX queue A for ACK packet P1. Then a subsequent sendmsg() can run on another cpu. TX queue selection uses the socket hash and can choose another queue B for packets P2 (with payload). If queue A is more congested than queue B, the ACK packet P1 could be sent on the wire after P2. A linux receiver when processing P1 (after P2) currently increments LINUX_MIB_PAWSESTABREJECTED (TcpExtPAWSEstab) and use TCP_RFC7323_PAWS drop reason. It might also send a DUPACK if not rate limited. In order to better understand this pattern, this patch adds a new drop_reason : TCP_RFC7323_PAWS_ACK. For old ACKS like these, we no longer increment LINUX_MIB_PAWSESTABREJECTED and no longer sends a DUPACK, keeping credit for other more interesting DUPACK. perf record -e skb:kfree_skb -a perf script ... swapper 0 [148] 27475.438637: skb:kfree_skb: ... location=tcp_validate_incoming+0x4f0 reason: TCP_RFC7323_PAWS_ACK swapper 0 [208] 27475.438706: skb:kfree_skb: ... location=tcp_validate_incoming+0x4f0 reason: TCP_RFC7323_PAWS_ACK swapper 0 [208] 27475.438908: skb:kfree_skb: ... location=tcp_validate_incoming+0x4f0 reason: TCP_RFC7323_PAWS_ACK swapper 0 [148] 27475.439010: skb:kfree_skb: ... location=tcp_validate_incoming+0x4f0 reason: TCP_RFC7323_PAWS_ACK swapper 0 [148] 27475.439214: skb:kfree_skb: ... location=tcp_validate_incoming+0x4f0 reason: TCP_RFC7323_PAWS_ACK swapper 0 [208] 27475.439286: skb:kfree_skb: ... location=tcp_validate_incoming+0x4f0 reason: TCP_RFC7323_PAWS_ACK ... Signed-off-by: Eric Dumazet Reviewed-by: Neal Cardwell Reviewed-by: Kuniyuki Iwashima Reviewed-by: Jason Xing --- include/net/dropreason-core.h | 5 +++++ net/ipv4/tcp_input.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 3a6602f379783078388eaaad3a9237b11baad534..28555109f9bdf883af2567f74dea86a327beba26 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -36,6 +36,7 @@ FN(TCP_OVERWINDOW) \ FN(TCP_OFOMERGE) \ FN(TCP_RFC7323_PAWS) \ + FN(TCP_RFC7323_PAWS_ACK) \ FN(TCP_OLD_SEQUENCE) \ FN(TCP_INVALID_SEQUENCE) \ FN(TCP_INVALID_ACK_SEQUENCE) \ @@ -259,6 +260,10 @@ enum skb_drop_reason { * LINUX_MIB_PAWSESTABREJECTED, LINUX_MIB_PAWSACTIVEREJECTED */ SKB_DROP_REASON_TCP_RFC7323_PAWS, + /** + * @SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK: PAWS check, old ACK packet. + */ + SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK, /** @SKB_DROP_REASON_TCP_OLD_SEQUENCE: Old SEQ field (duplicate packet) */ SKB_DROP_REASON_TCP_OLD_SEQUENCE, /** @SKB_DROP_REASON_TCP_INVALID_SEQUENCE: Not acceptable SEQ field */ diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 24966dd3e49f698e110f8601e098b65afdf0718a..dc0e88bcc5352dafee38143076f9e4feebdf8be3 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4465,7 +4465,9 @@ static enum skb_drop_reason tcp_disordered_ack_check(const struct sock *sk, /* 2. Is its sequence not the expected one ? */ if (seq != tp->rcv_nxt) - return reason; + return before(seq, tp->rcv_nxt) ? + SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK : + reason; /* 3. Is this not a duplicate ACK ? */ if (ack != tp->snd_una) @@ -5967,6 +5969,12 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, if (unlikely(th->syn)) goto syn_challenge; + /* Old ACK are common, do not change PAWSESTABREJECTED + * and do not send a dupack. + */ + if (reason == SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK) + goto discard; + NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED); if (!tcp_oow_rate_limited(sock_net(sk), skb, LINUX_MIB_TCPACKSKIPPEDPAWS, From patchwork Mon Jan 13 13:55:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13937408 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B44BD23A56F for ; Mon, 13 Jan 2025 13:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736776566; cv=none; b=KJUNfg5URbyRqll33/Ry/ofbY+1ZxWsLh2mqiuzaTSXtMo8VOlJS8+lLYLtBhHZwbY37dIQfTPd4lZ0Gc+eoEPAroBLFqGj1CJ82HL8fvVKwC9fQLvI0uniE3HrP2pg6Ak/UtpL7rju3zz1P5VGvtLh5NjHk+Arm/z6d64bBfw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736776566; c=relaxed/simple; bh=FnRT7xDm2jSZw8J8X01x/L2LSRGmct7Y7egsQtkZ8F8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=eFLbf8x8xa6vCvI54+C9QMyybt1jxHXu0WFnnW2re/L0wH+kDRoRZ6d3z955b55VCLHHRVn5lnlpFhF3ZzZkGN8UGjHl9gvtGRkYay+Jq2ZJdLFtSaTgZdCor9BrOyraL0ZhW9/zvlT8PWlyCZc1Z8UxAurXQBdy5xQK5szey7g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vSSbUxLj; arc=none smtp.client-ip=209.85.222.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vSSbUxLj" Received: by mail-qk1-f202.google.com with SMTP id af79cd13be357-7b6e1c50ef1so629008685a.2 for ; Mon, 13 Jan 2025 05:56:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736776563; x=1737381363; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=72NehsPMmIfpXsz7Pze5hUJE5FfsrxMMp8HLRAq7MS8=; b=vSSbUxLjFduFxlg6tkcJnj68aJEglTMZw4S7xcByOpQseE50pjivsYMDCcgRNiilBf LwvD6BJ78s6zWBNo+9J5FOk9FysC4tKzBAQBp2lhADwueg6+aBioWQobtMULzeVPqCpO WFgiOr2UYWwDg0N8uAnJOfx9nYccZXL/Ja98VnbJ/U0ehrlvC7n6Rbxg80uUUVPZLSnd ika60W2zLkkCd6TIl8CliToJwvP3wxnhGH3NpJsgsUiLyqobn07E2uoo51x9o7D3p4Wp NCV5G0yBrddnD2y9Us1VwQhd5TKyp4oHgNwQgvEOQXHvVYccmpugMKj5rj8Tj7vDSQaR Jj0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736776563; x=1737381363; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=72NehsPMmIfpXsz7Pze5hUJE5FfsrxMMp8HLRAq7MS8=; b=NtapTcpnTljJlqgfQsZ0gO/XbT2QgWAWUuOIJM2CqKdzXyEQrQ+0B90TwyP96NNAmN 2YlrC23o8D6dLY4dfmRASHzIMpNGKLN0fa8OrDk9pBJRSoVM54Q4hh9F0c5uAShAdtJF e4ZkQKVve7i0a6hjxdyMDnCCGctXxWXZrq+Ny1BsuF3QsD/kT6ekxypXq1z2p2F9EYFg DNJDH6JRUWi84m2ghEp1/e8zBAwmYCvgu+v8ZkZ84q19MUT7kVJIBZ+4RZOPZlHozbQN vyUVmpqWG7Xk76RGqy06h3HcWN09Oex7SLKsun55iI5puNsORbtnij/k9nzeIH/gwVZw wVlw== X-Gm-Message-State: AOJu0YxAp70/1qqIH+3gcvOkl5Drl0SDcR1tJSD3Zhb/8J3UiiHb21rX jSp5887Mof7Kucen1EVpg2naJpS2j1vP5odlOuKETMIOMIOQ0ftu1Sk0CLUiMi8Fl4Gl7CZtHpO F+0lloGHjfw== X-Google-Smtp-Source: AGHT+IHnpuiQWV4PZYmwmCL7KTGCNBhycp0YTXBZQqoSC34Wq5yT4fo5uwQ15HsspVccRuE7qRqwTl52UNo+Wg== X-Received: from qkbbi10.prod.google.com ([2002:a05:620a:318a:b0:7b6:ed9f:7b6e]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:a016:b0:7bc:db11:4945 with SMTP id af79cd13be357-7bcdb114b95mr2590067885a.51.1736776563733; Mon, 13 Jan 2025 05:56:03 -0800 (PST) Date: Mon, 13 Jan 2025 13:55:58 +0000 In-Reply-To: <20250113135558.3180360-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250113135558.3180360-1-edumazet@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250113135558.3180360-4-edumazet@google.com> Subject: [PATCH v2 net-next 3/3] tcp: add LINUX_MIB_PAWS_OLD_ACK SNMP counter From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Simon Horman , Neal Cardwell , Kuniyuki Iwashima , Jason Xing , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Prior patch in the series added TCP_RFC7323_PAWS_ACK drop reason. This patch adds the corresponding SNMP counter, for folks using nstat instead of tracing for TCP diagnostics. nstat -az | grep PAWSOldAck Suggested-by: Neal Cardwell Signed-off-by: Eric Dumazet Reviewed-by: Neal Cardwell Reviewed-by: Jason Xing Tested-by: Neal Cardwell Reviewed-by: Kuniyuki Iwashima --- include/net/dropreason-core.h | 1 + include/uapi/linux/snmp.h | 1 + net/ipv4/proc.c | 1 + net/ipv4/tcp_input.c | 7 ++++--- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 28555109f9bdf883af2567f74dea86a327beba26..ed864934e20b11fcf91478afe2450b2eadce799f 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -262,6 +262,7 @@ enum skb_drop_reason { SKB_DROP_REASON_TCP_RFC7323_PAWS, /** * @SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK: PAWS check, old ACK packet. + * Corresponds to LINUX_MIB_PAWS_OLD_ACK. */ SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK, /** @SKB_DROP_REASON_TCP_OLD_SEQUENCE: Old SEQ field (duplicate packet) */ diff --git a/include/uapi/linux/snmp.h b/include/uapi/linux/snmp.h index 2e75674e7d4f8f50f624ca454e6d7d1ed86f5c26..848c7784e684c03bdf743e42594317f3d889d83f 100644 --- a/include/uapi/linux/snmp.h +++ b/include/uapi/linux/snmp.h @@ -186,6 +186,7 @@ enum LINUX_MIB_TIMEWAITKILLED, /* TimeWaitKilled */ LINUX_MIB_PAWSACTIVEREJECTED, /* PAWSActiveRejected */ LINUX_MIB_PAWSESTABREJECTED, /* PAWSEstabRejected */ + LINUX_MIB_PAWS_OLD_ACK, /* PAWSOldAck */ LINUX_MIB_DELAYEDACKS, /* DelayedACKs */ LINUX_MIB_DELAYEDACKLOCKED, /* DelayedACKLocked */ LINUX_MIB_DELAYEDACKLOST, /* DelayedACKLost */ diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 40053a02bae103a9e1617ab0457da6398d75cd85..affd21a0f57281947f88c6563be3d99aae613baf 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -189,6 +189,7 @@ static const struct snmp_mib snmp4_net_list[] = { SNMP_MIB_ITEM("TWKilled", LINUX_MIB_TIMEWAITKILLED), SNMP_MIB_ITEM("PAWSActive", LINUX_MIB_PAWSACTIVEREJECTED), SNMP_MIB_ITEM("PAWSEstab", LINUX_MIB_PAWSESTABREJECTED), + SNMP_MIB_ITEM("PAWSOldAck", LINUX_MIB_PAWS_OLD_ACK), SNMP_MIB_ITEM("DelayedACKs", LINUX_MIB_DELAYEDACKS), SNMP_MIB_ITEM("DelayedACKLocked", LINUX_MIB_DELAYEDACKLOCKED), SNMP_MIB_ITEM("DelayedACKLost", LINUX_MIB_DELAYEDACKLOST), diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index dc0e88bcc5352dafee38143076f9e4feebdf8be3..eb82e01da911048b41ca380f913ef55566be79a7 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -5969,12 +5969,13 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, if (unlikely(th->syn)) goto syn_challenge; - /* Old ACK are common, do not change PAWSESTABREJECTED + /* Old ACK are common, increment PAWS_OLD_ACK * and do not send a dupack. */ - if (reason == SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK) + if (reason == SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK) { + NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWS_OLD_ACK); goto discard; - + } NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED); if (!tcp_oow_rate_limited(sock_net(sk), skb, LINUX_MIB_TCPACKSKIPPEDPAWS,