From patchwork Wed Jul 31 12:09:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13748588 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 F064E1AB516 for ; Wed, 31 Jul 2024 12:10:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427810; cv=none; b=Araw8roPFYqPGHEiAlODzo5Xb/XUiWpWPoI0xGUF7oozvAe35h79x0TActfxH9icXvGRY+g95lO9w8JRaWXEkbDLIX2/53IbytP5dY992EZdZA0ih0ourKTUZnDl8nsgaX4HyPydXUX94NqNRnEYcLJgK13O44JqgmgDfIVsVTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427810; c=relaxed/simple; bh=kfcSXfC5JcvC+7C0W1YUJMsNNRJUrr80jzzuWO2BF3I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T5Njt7/ujwTO3GK6Z4JGB0vSGLNbCTNYPQq5w3tyXG8on31ucK92J8txuuSMWwr4i0PiVvMtx8Fhr/CkMXe4Zj1m2QJwoF9P6mAAd1+FVddlnk1vRkA4idDTGDfOv0z9K7pDrg9u0Fredo61Bjzch/onaaW4P1ZrSYHXyEmNWIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Xa37+XjD; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xa37+XjD" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-70ef732ff95so2205081b3a.0 for ; Wed, 31 Jul 2024 05:10:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722427808; x=1723032608; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2W23wy756KJnEnaODYZZ3ycAfBd3JNd7g+sLxPmGmsM=; b=Xa37+XjDe/qnEoG6ssKd1obn4HljpszR7L72lNV4zQXx2EoHM8ExZ2Ma4+nfee3IoK MOG8tttII9f23/ES4J0IyR3aufjvbxa2yLULGI1A1cAhZr4hrQAe3pSbsIMcTEs5aWbZ diVamzn2Ls5kAB6Zv5rWMeaiPzzWkrKu+H5aF6X5X3M4oApgseyI236nyimlbPlhXh8j Swq1H1mET4tWyx9jULZY5tuQoX5nhw+McSg8YRggN895xdXD1m+rv0J49GGraQtsVl8o ZCw9yJtBZAoP/vF1QyZIoVCW7UTh98GS3SNA2MyzyOc/cKc4Wg82tpy/SPPwtQgF8FPT 3lRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722427808; x=1723032608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2W23wy756KJnEnaODYZZ3ycAfBd3JNd7g+sLxPmGmsM=; b=VO61PdQVVWLT2M9Go/iYVTmi53UN/J+xzpbAkRq7CKwZ/W43isquGa4XlPsCgIQtO+ 7baEaltaVCV809kgBInhQhXlt0yPmMnqJFUWI0C7L7y0/DIM2xnttbxVrNWUBOeWH6MJ lp94bdnHCiNylf5Qtil3WJ9gEHvjX0UVEHfhNeOdVRBJuLpzxM+UjvGuhoBs9SC0H++u quiOYm7o6LJh6pq+4ifiFeppAaWX9FHYcb5fFJUft9puz0CU914YrQExcQ3aVYvEOIJl G0wrHc9SsdEhEbDQ5TLivFWAA1DVROdaxVXM7Bzp6av50y0lcmyG0mKDf78/UrLSVohc AqEg== X-Gm-Message-State: AOJu0YyZkxPj+f0XmoatNuHgBP2DH0xaI3BQgleoS4KEtHqtE4Ktpq+e YMCQn01G4CImmO0qO9laAsJtygupd5OClvdvSWBE8vKgLAxSIpL7 X-Google-Smtp-Source: AGHT+IGtAF7Z2uoGk41gY7gCdHi48Rqp/zJre/uI1OvsKaVV5WWXWdpJTCNeHu5C4tU2yELI98lKfw== X-Received: by 2002:a05:6a00:1910:b0:70d:2af7:849d with SMTP id d2e1a72fcca58-70eceda313bmr11540578b3a.23.1722427807973; Wed, 31 Jul 2024 05:10:07 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70eca8af213sm7488545b3a.180.2024.07.31.05.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 05:10:07 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next v2 1/6] tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_CLOSE for active reset Date: Wed, 31 Jul 2024 20:09:50 +0800 Message-Id: <20240731120955.23542-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240731120955.23542-1-kerneljasonxing@gmail.com> References: <20240731120955.23542-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Introducing a new type TCP_ABORT_ON_CLOSE for tcp reset reason to handle the case where more data is unread in closing phase. Signed-off-by: Jason Xing Reviewed-by: Eric Dumazet --- include/net/rstreason.h | 6 ++++++ net/ipv4/tcp.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/net/rstreason.h b/include/net/rstreason.h index 2575c85d7f7a..fa6bfd0d7d69 100644 --- a/include/net/rstreason.h +++ b/include/net/rstreason.h @@ -17,6 +17,7 @@ FN(TCP_ABORT_ON_DATA) \ FN(TCP_TIMEWAIT_SOCKET) \ FN(INVALID_SYN) \ + FN(TCP_ABORT_ON_CLOSE) \ FN(MPTCP_RST_EUNSPEC) \ FN(MPTCP_RST_EMPTCP) \ FN(MPTCP_RST_ERESOURCE) \ @@ -84,6 +85,11 @@ enum sk_rst_reason { * an error, send a reset" */ SK_RST_REASON_INVALID_SYN, + /** + * @SK_RST_REASON_TCP_ABORT_ON_CLOSE: abort on close + * corresponding to LINUX_MIB_TCPABORTONCLOSE + */ + SK_RST_REASON_TCP_ABORT_ON_CLOSE, /* Copy from include/uapi/linux/mptcp.h. * These reset fields will not be changed since they adhere to diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index e03a342c9162..2e010add0317 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2833,7 +2833,7 @@ void __tcp_close(struct sock *sk, long timeout) NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONCLOSE); tcp_set_state(sk, TCP_CLOSE); tcp_send_active_reset(sk, sk->sk_allocation, - SK_RST_REASON_NOT_SPECIFIED); + SK_RST_REASON_TCP_ABORT_ON_CLOSE); } else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) { /* Check zero linger _after_ checking for unread data. */ sk->sk_prot->disconnect(sk, 0); From patchwork Wed Jul 31 12:09:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13748589 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (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 167551AB516 for ; Wed, 31 Jul 2024 12:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427813; cv=none; b=XG5cJgxmLWgzcbTWukSX01lDyGJ3lIHE+xnFpm0gruZc95jI1Yi7ECQv4y61PPltLoQIIZuwDNnP1GSl3xvRerHNNhML+VnRtbARGZZiGMIzu3fy2JkDoh8k8X6kd1Tokz23xo93eAv4/sk15mN98p7f8wAy4OP/1t34utBRY8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427813; c=relaxed/simple; bh=sELGKtAigfVF1zgsTyPKm9ZUrrRps71mcbi75aSK++o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YcGKycCVFlpwH5sXU227QMBq9lH6VrXXrk7IYrZxjcs9s+1IjJR0KpO0tpuf0fXAIMXobtYbziK+hShNAwAIeQ+FbFZ3KglN3KPRkJwHFigKesEHNb+rTCm8ssn6NBr8PPv6eHOxhbgT4TuU18zUBZMns9Av3063MoShaqohrlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nqUKVtTw; arc=none smtp.client-ip=209.85.160.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nqUKVtTw" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-264a12e05b9so3575913fac.1 for ; Wed, 31 Jul 2024 05:10:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722427811; x=1723032611; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ktupWLflllZrX9z6dcV/AAu/RJe8BItZC51A5Ri4yeE=; b=nqUKVtTwliwu8kB/Oz5VoKQfZ1sWbK8KNeYsk+YO2oEWgMUP/Wn2tNk8mr13n7gitU ZCbyC22B+korFa/UmolARNcMy3SCqZkfDkHaC6HNxpqm2eOnYeS87C+OQa1WThQyGmKq KhOl6YzCDFbOsGAf3hx0QiU1arj+K8OQikIfmZjoT2c4Cd/nyvEmwpR/fFgOsAdluJUL k7skgyfvA/Ni6mbFtdYG9zaSLTtcrLsOg2h04ApYj/R1goTzyeLg5iLyNZlR+mEVqfJJ Np2HLH0OXaV8Ai5XQMo1WIbIjT/bmoKH0w0zldh2yJI4tW5PJVtlV6znfMDiJdp5KAJE FKHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722427811; x=1723032611; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ktupWLflllZrX9z6dcV/AAu/RJe8BItZC51A5Ri4yeE=; b=CdZxlu8VdTvimIS1xUTFyR15UFn4OqJc3Vbxos0OiR0rUryLXX+PabpE72CbBqHq7f JYHQ4a8RVmfmyUTPAKBU9wjkBpsuz+bh5V4PP7TrTY893USU0UTgc+QYPv96pLkqsqfK zzBjpw2JJZuEyg8RYT6qNETM5OZb9/2KlZv/TrcyMhSos1UCuVEVxrGKZHIzzFrPifhQ hileTRxOpOn3EEBMbP9n2Jh4jwON6oUoM8uVGqJXR4LG0YRWa+lA7i/EtDiywDloIiaL 7N2J7G1n+ug0+hTktZRBKKpmcbdLfZbUY7hKlcptNXM/pXv91UJAhEXWa8oXSBmaPbnp yULQ== X-Gm-Message-State: AOJu0YzZUeKpq/x9vDGpfrR5movbJY/yPcsHInOrS3KP3kGNKYkNq8UK UES03E6ZZu8khVNJCxyK1X1A6hn78SCJU5VDCqeaDowXQ2aBmrj4 X-Google-Smtp-Source: AGHT+IGL2K65AEv7Mt+qJY5ywQYap5/RAwM+Aj8hOPnXqU2xeTMncbHYCO3OaRFdRdJuokuBVSO2FQ== X-Received: by 2002:a05:6870:8a11:b0:261:ff6:7496 with SMTP id 586e51a60fabf-267d4ee606amr18610206fac.40.1722427811005; Wed, 31 Jul 2024 05:10:11 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70eca8af213sm7488545b3a.180.2024.07.31.05.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 05:10:10 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next v2 2/6] tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_LINGER for active reset Date: Wed, 31 Jul 2024 20:09:51 +0800 Message-Id: <20240731120955.23542-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240731120955.23542-1-kerneljasonxing@gmail.com> References: <20240731120955.23542-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Introducing a new type TCP_ABORT_ON_LINGER for tcp reset reason to handle negative linger value case. Signed-off-by: Jason Xing Reviewed-by: Eric Dumazet --- include/net/rstreason.h | 6 ++++++ net/ipv4/tcp.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/net/rstreason.h b/include/net/rstreason.h index fa6bfd0d7d69..fbbaeb969e6a 100644 --- a/include/net/rstreason.h +++ b/include/net/rstreason.h @@ -18,6 +18,7 @@ FN(TCP_TIMEWAIT_SOCKET) \ FN(INVALID_SYN) \ FN(TCP_ABORT_ON_CLOSE) \ + FN(TCP_ABORT_ON_LINGER) \ FN(MPTCP_RST_EUNSPEC) \ FN(MPTCP_RST_EMPTCP) \ FN(MPTCP_RST_ERESOURCE) \ @@ -90,6 +91,11 @@ enum sk_rst_reason { * corresponding to LINUX_MIB_TCPABORTONCLOSE */ SK_RST_REASON_TCP_ABORT_ON_CLOSE, + /** + * @SK_RST_REASON_TCP_ABORT_ON_LINGER: abort on linger + * corresponding to LINUX_MIB_TCPABORTONLINGER + */ + SK_RST_REASON_TCP_ABORT_ON_LINGER, /* Copy from include/uapi/linux/mptcp.h. * These reset fields will not be changed since they adhere to diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 2e010add0317..5b0f1d1fc697 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2908,7 +2908,7 @@ void __tcp_close(struct sock *sk, long timeout) if (READ_ONCE(tp->linger2) < 0) { tcp_set_state(sk, TCP_CLOSE); tcp_send_active_reset(sk, GFP_ATOMIC, - SK_RST_REASON_NOT_SPECIFIED); + SK_RST_REASON_TCP_ABORT_ON_LINGER); __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONLINGER); } else { From patchwork Wed Jul 31 12:09:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13748590 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (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 EA0AC1AB516 for ; Wed, 31 Jul 2024 12:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427816; cv=none; b=Znph59gcGm53u0P92I5zn3NOi543Ury4OtN9oXUsfC6PwCKvwPeLbUFvLudB9BD33vYoXTUssoVfWUiWgYP2rtqdHk53K6E3ARMocaZklS0V1Q+G0yBf2yUiMk5UULbe3fCD4nTxmrPW7HKS3YQ+nDYwoYkfZX0hzAqyTx9SyAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427816; c=relaxed/simple; bh=wVa1ccJeseNY3fiGdLHG7LQGRcIJthDze9EEAOwxBQ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J3PK4HXzV2NQqHx8Z3fbOiLO5BA0iKheYI3tSm9Ulm7UqODKBOyQLbU2k3qvPn8QZz9W/P7AHt4X6HfETHLTYXQ0OBDOyr9L1wLUlgBtAwnUG0mjW4eYCfUH5RxekiFE7cZ9QI0f9MosTL7Ko8v2MDiTQDrTqzSBCR7lry3kppo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TxovRMsm; arc=none smtp.client-ip=209.85.160.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TxovRMsm" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-25dfb580d1fso2463645fac.2 for ; Wed, 31 Jul 2024 05:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722427814; x=1723032614; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nd8SawcL1fjjON1L9lvfL4eTUDsCc9Q6YNNuKjobjrA=; b=TxovRMsmWb2E5HZjq1UQPO25nhUy3CUGFbOxVIK389t344lCfkO62dLiOC/KtLnwFv s48VGiSd8JSXNhjW2tnvXT6dWtkAAhK8v8IwwVu+P8pVnAsJksr8fCFhGDd3rSxDKuh7 AKhVq2PciiqkorZaZvbYhLgbp6nZgZq4IsfCjeJb3CuviFTETD9iRxvLspuhr/792Y7J 7m6K4YYCCPvQZosD5/kew/t0tdI1qJ1kfu5WtyLYuMW3K9ZiVk++DV4z3XMpE1OtX89m gy6sUsctrsJzfWEEItb1q8oKMA9Xnknis1ZQgf26TTq1nYz6GDEdhgq9WEXAlAOiMNPZ N5Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722427814; x=1723032614; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nd8SawcL1fjjON1L9lvfL4eTUDsCc9Q6YNNuKjobjrA=; b=K/g4L+JzNhqxaD5z43+rdeWkOXEaH4LONFfqv0uyQO8j/Ir6AM0UgmfrfPAm+HIrrK YcDUVeY2uILqbDGkpP0HV+opJBZw1g5OE+KsB4WOHRvFOL/rzpLL5fWiorIb3jcHtrkv cuOlcM6ZQvCcfp9Kh1GCNKUt/QLP5MZ5DjQ+lSWDF6UlzuODua3rZDFz5CiduJYeYIVP S6bjYO8bQdV35lzo1VIKarXHgO7h3Klz+LwNbYqztfU3/WlFWmf0lfiLwhdFKHm5lxux sdSUWCQoMmp+4zXVuAnAvTLXAoGsimPmthHNHVzPrZz5oCmbpVJW37Twit9KLFf3uGvt q0Wg== X-Gm-Message-State: AOJu0Yy9iiA/EvoYOOR+8acfSvrVNeQfzf5dhTRtCAboGMjLIgyXpkUS vr6/4gVfLnUk4rm4UMrg+Dn2Cr7CLh69yPhEr4jMvR6OWYkPOv6R X-Google-Smtp-Source: AGHT+IG9j0YKGb1bV3qzdefdtJIGefTTLi0AKKBC9zC9Qotn9yY8DVtm0rBOFwY1ond+0CACRr7Cug== X-Received: by 2002:a05:6870:1690:b0:25d:f0ba:eab7 with SMTP id 586e51a60fabf-267d4d59a30mr17192345fac.18.1722427814018; Wed, 31 Jul 2024 05:10:14 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70eca8af213sm7488545b3a.180.2024.07.31.05.10.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 05:10:13 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next v2 3/6] tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_MEMORY for active reset Date: Wed, 31 Jul 2024 20:09:52 +0800 Message-Id: <20240731120955.23542-4-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240731120955.23542-1-kerneljasonxing@gmail.com> References: <20240731120955.23542-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Introducing a new type TCP_ABORT_ON_MEMORY for tcp reset reason to handle out of memory case. Signed-off-by: Jason Xing Reviewed-by: Eric Dumazet --- include/net/rstreason.h | 6 ++++++ net/ipv4/tcp.c | 2 +- net/ipv4/tcp_timer.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/net/rstreason.h b/include/net/rstreason.h index fbbaeb969e6a..eef658da8952 100644 --- a/include/net/rstreason.h +++ b/include/net/rstreason.h @@ -19,6 +19,7 @@ FN(INVALID_SYN) \ FN(TCP_ABORT_ON_CLOSE) \ FN(TCP_ABORT_ON_LINGER) \ + FN(TCP_ABORT_ON_MEMORY) \ FN(MPTCP_RST_EUNSPEC) \ FN(MPTCP_RST_EMPTCP) \ FN(MPTCP_RST_ERESOURCE) \ @@ -96,6 +97,11 @@ enum sk_rst_reason { * corresponding to LINUX_MIB_TCPABORTONLINGER */ SK_RST_REASON_TCP_ABORT_ON_LINGER, + /** + * @SK_RST_REASON_TCP_ABORT_ON_MEMORY: abort on memory + * corresponding to LINUX_MIB_TCPABORTONMEMORY + */ + SK_RST_REASON_TCP_ABORT_ON_MEMORY, /* Copy from include/uapi/linux/mptcp.h. * These reset fields will not be changed since they adhere to diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 5b0f1d1fc697..fd928c447ce8 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2927,7 +2927,7 @@ void __tcp_close(struct sock *sk, long timeout) if (tcp_check_oom(sk, 0)) { tcp_set_state(sk, TCP_CLOSE); tcp_send_active_reset(sk, GFP_ATOMIC, - SK_RST_REASON_NOT_SPECIFIED); + SK_RST_REASON_TCP_ABORT_ON_MEMORY); __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY); } else if (!check_net(sock_net(sk))) { diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 4d40615dc8fc..0fba4a4fb988 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -125,7 +125,7 @@ static int tcp_out_of_resources(struct sock *sk, bool do_reset) do_reset = true; if (do_reset) tcp_send_active_reset(sk, GFP_ATOMIC, - SK_RST_REASON_NOT_SPECIFIED); + SK_RST_REASON_TCP_ABORT_ON_MEMORY); tcp_done(sk); __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY); return 1; From patchwork Wed Jul 31 12:09:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13748591 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 B1EE61AED3B for ; Wed, 31 Jul 2024 12:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427819; cv=none; b=MS3tBhPhYaUj5NHR/vebc4JwkxajY0h12o+NxogD/wmfjGA2cdyNsdFLjO3nBO22U5dmnjigsNaK2okMmhYucypH4hNFL4J9SlXeB/0D4n5s+EfSAvkb1TH2QCQP1eklkUh1dWlA7QxxBPUv6b5OTpHuqwIz7qB26PMvOb1YFdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427819; c=relaxed/simple; bh=wKRYlDbDJLM/Gx64el1DdLGR3qFg9OlOfbPy4XoYNfQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y2zhveWUmcyb4iwDIh+uTCfnzQ0Ghzx5yrfNGVELr+iOruQgybz+2VOVDGYSmIDjvxzU+xgwRvvZy8eNvjfDWfqWnguAXmg0JjYASqCm/ElTLUJgJwvkbspKGb12YeVrUb67LCvzfbM1SrhsTIGgyGUCpjUiqsR92EEGU7b1AA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Pw51nL7M; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pw51nL7M" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-70eec5f2401so3067961b3a.3 for ; Wed, 31 Jul 2024 05:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722427817; x=1723032617; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lRADjC01DYCUa6G78E+iirXfPEEhpJpu7Urq/4yWEhM=; b=Pw51nL7MV1eptTePpSJIkDI8Z3ujeGC6r6oa9n9ZujeiQ/hqB13/KIiKO5tRD6Mo6W tEQT84Qea6LV64QQQ3LhQhb080sPhURzJ9QAk04R1ZQ1NMtd8hISkwM362OHmpYrcmAT WJeznx9RqmBGQrVPOv5oe957kHJTY0PwViye3QB4adolM+zUaC5xY35Fsq7cJgjsoURs Ht503ugwVUBXfqKN9QM2qdPanq4a4Mrhy7cwbBCrzJgepHMjr2jDDrCxxJ8ZM1W7aAqD VlNMe+XRz/2CN/3GLshcOU8UQDXA45200PqNH4SWgKvqHdyRpc1m1HvuFLxj0zW6G+YJ mNzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722427817; x=1723032617; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lRADjC01DYCUa6G78E+iirXfPEEhpJpu7Urq/4yWEhM=; b=QGCrVn49CGMlHOZORPgjdo5O5t+kzHd7MVVCrmJxvM8hSigkdK5AE4fNRpOq9b4Tn2 1KLA14vs2p46ET8aQpmGHZEPdK2r0F3hgjrDMZE/B3rJyYoQ7Au1mHtsxP+GRgFjzq5j U2OyjoeRT5OoDvzJE9MCB801tFwMsu1Hx44ZmAnBZ9VgIPjjsrMfu+BTNnAgV/CY9ZUE 1I+NlMpAgnLoo6ZqKM930i5XXVKvdkDxbEA/3IRSPY7qL291Zo/vgIbLFFhtBQAswSbw LDnCSIC/aR6DW9XPiEH7RQy/4I2YtRAEVVDX3+pUELOjgAQK/IsXKhDsILTd8wYiaeMz QRuA== X-Gm-Message-State: AOJu0YwGbeRDa8IRWbLoHB2xF1mINeBt1UE655I35+9I2nrbxKS5BGfT eQYp5cjdEwzeqnKPukd8C/5bNMAcwJIW6EXzNd2un/ErqYXPQh2k X-Google-Smtp-Source: AGHT+IHZLMH8fEJeSdaq1IkKIdah8mlFqK0gl/VJ559LDQ7wYA6DHR/+h+F8r6qZUHnwj11/9u8CkQ== X-Received: by 2002:a05:6a00:91cb:b0:70d:2621:5808 with SMTP id d2e1a72fcca58-70ecea19a17mr15958824b3a.9.1722427816978; Wed, 31 Jul 2024 05:10:16 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70eca8af213sm7488545b3a.180.2024.07.31.05.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 05:10:16 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next v2 4/6] tcp: rstreason: introduce SK_RST_REASON_TCP_STATE for active reset Date: Wed, 31 Jul 2024 20:09:53 +0800 Message-Id: <20240731120955.23542-5-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240731120955.23542-1-kerneljasonxing@gmail.com> References: <20240731120955.23542-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Introducing a new type TCP_STATE to handle some reset conditions appearing in RFC 793 due to its socket state. Actually, we can look into RFC 9293 which has no discrepancy about this part. Signed-off-by: Jason Xing --- V2 Link: https://lore.kernel.org/all/20240730200633.93761-1-kuniyu@amazon.com/ 1. use RFC 9293 instead of RFC 793 which is too old (Kuniyuki) --- include/net/rstreason.h | 6 ++++++ net/ipv4/tcp.c | 4 ++-- net/ipv4/tcp_timer.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/net/rstreason.h b/include/net/rstreason.h index eef658da8952..bbf20d0bbde7 100644 --- a/include/net/rstreason.h +++ b/include/net/rstreason.h @@ -20,6 +20,7 @@ FN(TCP_ABORT_ON_CLOSE) \ FN(TCP_ABORT_ON_LINGER) \ FN(TCP_ABORT_ON_MEMORY) \ + FN(TCP_STATE) \ FN(MPTCP_RST_EUNSPEC) \ FN(MPTCP_RST_EMPTCP) \ FN(MPTCP_RST_ERESOURCE) \ @@ -102,6 +103,11 @@ enum sk_rst_reason { * corresponding to LINUX_MIB_TCPABORTONMEMORY */ SK_RST_REASON_TCP_ABORT_ON_MEMORY, + /** + * @SK_RST_REASON_TCP_STATE: abort on tcp state + * Please see RFC 9293 for all possible reset conditions + */ + SK_RST_REASON_TCP_STATE, /* Copy from include/uapi/linux/mptcp.h. * These reset fields will not be changed since they adhere to diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index fd928c447ce8..64a49cb714e1 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3031,7 +3031,7 @@ int tcp_disconnect(struct sock *sk, int flags) /* The last check adjusts for discrepancy of Linux wrt. RFC * states */ - tcp_send_active_reset(sk, gfp_any(), SK_RST_REASON_NOT_SPECIFIED); + tcp_send_active_reset(sk, gfp_any(), SK_RST_REASON_TCP_STATE); WRITE_ONCE(sk->sk_err, ECONNRESET); } else if (old_state == TCP_SYN_SENT) WRITE_ONCE(sk->sk_err, ECONNRESET); @@ -4649,7 +4649,7 @@ int tcp_abort(struct sock *sk, int err) if (!sock_flag(sk, SOCK_DEAD)) { if (tcp_need_reset(sk->sk_state)) tcp_send_active_reset(sk, GFP_ATOMIC, - SK_RST_REASON_NOT_SPECIFIED); + SK_RST_REASON_TCP_STATE); tcp_done_with_error(sk, err); } diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 0fba4a4fb988..3910f6d8614e 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -779,7 +779,7 @@ static void tcp_keepalive_timer (struct timer_list *t) goto out; } } - tcp_send_active_reset(sk, GFP_ATOMIC, SK_RST_REASON_NOT_SPECIFIED); + tcp_send_active_reset(sk, GFP_ATOMIC, SK_RST_REASON_TCP_STATE); goto death; } From patchwork Wed Jul 31 12:09:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13748592 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 C55BF1AE877 for ; Wed, 31 Jul 2024 12:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427822; cv=none; b=H9+JTVLvlNY9zuwW4aV8OmGvU8G+mBQR9wIc2btqTlgfmOny63S/R6zyMaL3kgMQ2g2Fe4NlwmO8kRRf37I8IL+Xw/5SzaEShmVDgn0bSIZSqqUAE7se69liNmyQFy39b0xK+//KdqFeJH5zcNXb8qVMmyxaYplMN2Rs/bJlHTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427822; c=relaxed/simple; bh=BPDLL0zi+iLWsaCwoWShPKLRtDzcWRw9A9agSb9HcK8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i/IBKgOFEnTRy3JT6PA2blxqrFUL5Osg5voMys8bPCxxdmz7NvYDhiXECbTrqAnLZZYpP7T5KFfQVqKSUHZdnPQTHAt6AARbY8VI/QRKlk/qWpdvoGRNqD8Am3PfYvJevfsXEA7XRB9iyEkeOco5WqA8MbwS52FvR5POqqx1f4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BmgsyvsK; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BmgsyvsK" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-70b703eda27so3557040b3a.3 for ; Wed, 31 Jul 2024 05:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722427820; x=1723032620; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DHon0uilYTfxxaoms7BYfICF5Ub7S4yk95M44g2vUgI=; b=BmgsyvsKOD/nht3dUtEHnsS/4Xm/2q2wpLv45sROKnBdZUJ/pk/8AFQBdhTYCEQrVy vW2sSt4EupdACazkT0JO0ml6ccVSky1ci3T9l7pfZnEVqX/oSOWeZRQDQSt3mZSKC+RN 6sNELMg/asTbQ0xh6X9XhMHLAOJaIQc6eh06vMuvZKFmAx45Qi4D0l4tgFdm5TAJC3Wj PyK6SYpYkVDlbv1zimLfdAmlY9HQweHykMTHjzhzZKdb1IQLsUyaLGhXYlshI00N5v2e W1xzWutzd9UdpTFdP6+DIJIxjdrN6QNJIE+/3A7gDfxNpdEG4rlhLYDuhV45fxj98ieX kl2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722427820; x=1723032620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DHon0uilYTfxxaoms7BYfICF5Ub7S4yk95M44g2vUgI=; b=ucKTTSSAQnwSu2QPZYfVJoZ/rIa6rxVlMi9M5LwExqX/9gXYBLVIaX8wkTlfE33ujz HlNhdKDSmlmPdtEXaOUKg5FGYVN9xGGopHng1JJ1pd87OV4n5D23S7jmrkeSAAwpsQoN rJmZujamWYPoQGsw4OQrNsirQ33Pis/llOs5Fz8T7BvtF2IBSekq/5Wv+/UNZPwIzeMS ZbGqDRs/t5UvWtMpymoDVquzKvwaDdK/tOZ3SMCwNLb6qEl+blGjzQSD56xsgKouNcgN 5GMBdsrEYWt9XYt1g6iXpTSngFA29cYWPjWan/Kgl8rY3whG2RuwGcbmHY0nvYqZyRKz OpUg== X-Gm-Message-State: AOJu0YwA8/rYYkkI9COxVq1wTjKB4fixKGn98UaBtmqmknClE1+C/Mmm AgKwcHTSdoOg445e7Q94lY/ouGFQd7c1phLIbsleKr7fJp/axTGn X-Google-Smtp-Source: AGHT+IE1XtFfeORgVD0aS4G12gI0kbjs7noyblSIwGCfTDwNUYD1aRUIHbAmoCTyvYUxgzoIoaUifA== X-Received: by 2002:a05:6a20:1588:b0:1c4:c7ac:9e5b with SMTP id adf61e73a8af0-1c4c7aca0d0mr10644547637.45.1722427819957; Wed, 31 Jul 2024 05:10:19 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70eca8af213sm7488545b3a.180.2024.07.31.05.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 05:10:19 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next v2 5/6] tcp: rstreason: introduce SK_RST_REASON_TCP_TIMEOUT for active reset Date: Wed, 31 Jul 2024 20:09:54 +0800 Message-Id: <20240731120955.23542-6-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240731120955.23542-1-kerneljasonxing@gmail.com> References: <20240731120955.23542-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Whether user sets TCP_USER_TIMEOUT option or not, when we find there is no left chance to proceed, we will send an RST to the other side. Signed-off-by: Jason Xing --- v2 Link: https://lore.kernel.org/all/CAL+tcoB-12pUS0adK8M_=C97aXewYYmDA6rJKLXvAXEHvEsWjA@mail.gmail.com/ 1. correct the comment and changelog --- include/net/rstreason.h | 8 ++++++++ net/ipv4/tcp_timer.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/net/rstreason.h b/include/net/rstreason.h index bbf20d0bbde7..739ad1db4212 100644 --- a/include/net/rstreason.h +++ b/include/net/rstreason.h @@ -21,6 +21,7 @@ FN(TCP_ABORT_ON_LINGER) \ FN(TCP_ABORT_ON_MEMORY) \ FN(TCP_STATE) \ + FN(TCP_TIMEOUT) \ FN(MPTCP_RST_EUNSPEC) \ FN(MPTCP_RST_EMPTCP) \ FN(MPTCP_RST_ERESOURCE) \ @@ -108,6 +109,13 @@ enum sk_rst_reason { * Please see RFC 9293 for all possible reset conditions */ SK_RST_REASON_TCP_STATE, + /** + * @SK_RST_REASON_TCP_TIMEOUT: time to timeout + * Whether user sets TCP_USER_TIMEOUT options or not, when we + * have already run out of all the chances, we have to reset the + * connection + */ + SK_RST_REASON_TCP_TIMEOUT, /* Copy from include/uapi/linux/mptcp.h. * These reset fields will not be changed since they adhere to diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 3910f6d8614e..bd403300e4c4 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -807,7 +807,7 @@ static void tcp_keepalive_timer (struct timer_list *t) (user_timeout == 0 && icsk->icsk_probes_out >= keepalive_probes(tp))) { tcp_send_active_reset(sk, GFP_ATOMIC, - SK_RST_REASON_NOT_SPECIFIED); + SK_RST_REASON_TCP_TIMEOUT); tcp_write_err(sk); goto out; } From patchwork Wed Jul 31 12:09:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13748593 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 A791E18DF93 for ; Wed, 31 Jul 2024 12:10:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427825; cv=none; b=nfbsUmQgQmLSEcApKI4Eic6S1LqHOSAE+yx1oqSWj3KvGquwoK/CTxbQEVbVoNv8RepNKcQEG300xb/NXIvizxrq3OiOlWe1ztAd+o/wkkgwubmfIjtZkhlvvmjF5ibPRazkHF4EWSRf5lpo7YR0LeV2iEUuL1deT9mvvSBu/cA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722427825; c=relaxed/simple; bh=TJhLBE/1dDFmQcXMCrFDSflxqCoEQKoFBZolCz3PYeQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dhxUYOskMBuhKCQVOJTSaELCWy3rTQ0c12slTd+ZDfsiP6ESK98nytfhfoQLt8Eh188dkJ4Stiq2wAAXTHPwvGy/uCGrXftpxoYspObW/0pWrms9nqbLhSbnwlPysWMC34L8Gz/7ejClWa/5VRkQTITugvbLFG8AYKwTlprEZ/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LZ8fjFRq; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LZ8fjFRq" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-710439ad77dso1289079b3a.2 for ; Wed, 31 Jul 2024 05:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722427823; x=1723032623; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2lFhtVGvFg8VrMx6un0IDEAfYudNTjtIlz6cdmYL4D8=; b=LZ8fjFRq+I33T/+Ei9/Cgp3cn1xSlPhUcq+3LdX8Y7PPsb0mLCkjzv7ZggKrzc6idn wtz+QVSByrSvDyiYo+MVdV9SiTbwMwnjcpfVCMpHKjQIzh8Ig5f/1bD2WV/75Sp7/eZ6 dNiIP+j7gCsYM4VoRL5tx7X7vYfVqPkke6gjOS+pTbhLxy3v2+fKtfP5uYkK0yBov55g vVoRDCgN757GfkmscXdDt8Lm4lv4lBgR3z0TbpoDT0YuEXnXPpwxgMCoxfFm0YLihc2F AxOE7hAblOW1gQkyNay/AD3Cna67Np2kYokf3o13tYEjKL7wHW8HQE4HKOMOLPuGdhxG aG5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722427823; x=1723032623; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2lFhtVGvFg8VrMx6un0IDEAfYudNTjtIlz6cdmYL4D8=; b=EzMWAm27jafaEzMBHTaZnQTwtNK9udJdmh9VSDP8GYMFWCaIUcsPUwDKh4JgTwszIv qtTrHVVhRribafMygDHw8uoQZ2lIXwpdMQIToyEyIcnC7ZYWVMcrhVHDpstZQetzASZz E3JqgFQ1BoL63yeXUWZFatT3aO8eDG1KOEKrykpNs5WczCtyoM7UgSP5Vtxe7gsy8ErR dFbonrs5AzRGnb/nqk6fQ/1L+ocfHRZ63SZqsAe5do9YkMnM+RWLospcuJO5aBI3E3b4 Hp6h3O9jQyZaNcRGoQOyPsSXcmfqGNJaXWbbSk0PdKmZCum1sCvPbcbbMjrz6AASzy9u 2iOQ== X-Gm-Message-State: AOJu0YwCRVoVX2JPquwrvNlzHfEE3keQYBSgddIZH8j4EaTfrguGNvcZ KIR+/l0vtCH5Jg2QEBriMMA0aXBniq90u/cA1Ebe3noESFqxTQkX X-Google-Smtp-Source: AGHT+IGQaywvE1iA11+NI4+EcMilLqjJlf+shDA/Yxd3AHA1kNL9vUXpdjAwM0mEJYKTyePEooGK7w== X-Received: by 2002:a05:6a21:107:b0:1c4:d540:46c with SMTP id adf61e73a8af0-1c4d5400798mr8499463637.47.1722427822880; Wed, 31 Jul 2024 05:10:22 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70eca8af213sm7488545b3a.180.2024.07.31.05.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 05:10:22 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next v2 6/6] tcp: rstreason: let it work finally in tcp_send_active_reset() Date: Wed, 31 Jul 2024 20:09:55 +0800 Message-Id: <20240731120955.23542-7-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240731120955.23542-1-kerneljasonxing@gmail.com> References: <20240731120955.23542-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Now it's time to let it work by using the 'reason' parameter in the trace world :) Signed-off-by: Jason Xing --- 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 16c48df8df4c..cdd0def14427 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3649,7 +3649,7 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority, /* skb of trace_tcp_send_reset() keeps the skb that caused RST, * skb here is different to the troublesome skb, so use NULL */ - trace_tcp_send_reset(sk, NULL, SK_RST_REASON_NOT_SPECIFIED); + trace_tcp_send_reset(sk, NULL, reason); } /* Send a crossed SYN-ACK during socket establishment.