From patchwork Tue Jul 30 13:35:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13747396 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.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 30F901A00F1 for ; Tue, 30 Jul 2024 13:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346528; cv=none; b=TEYGXNzKytlHhBK3lwu6OfMH6RuBhKUFaRHxgsOhjFfdsoY4Te0rMIXiwHQuI77Pv+s6teeN78fImqbE5qO3P+DBDa1Rhm6cX1M8SRgm87+r1kcSNO0M2e1hclnFD6lQHUCqlmz2H/Rq5Vh6GUjnKQzB5ZlQHzgPwEjzNleqi5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346528; c=relaxed/simple; bh=kfcSXfC5JcvC+7C0W1YUJMsNNRJUrr80jzzuWO2BF3I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cLL8wo5/y+kvSBcHapuDB5YnrTcpHnFIKHuT/q4IyZsxJ5jyAJNV5BKEBZtB/PYIH7U94WlTY3jhdhVFLGXxBSNzLPs3x25OPXzFKZ/8EvULpezg5YTIZ2FABUKkDU+teaOwgJXRfJN6cUU/il3jD5k+r/ZoyPDJya/yhnROXLo= 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=L/IDlFAe; arc=none smtp.client-ip=209.85.214.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="L/IDlFAe" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1ff3d5c6e9eso2560935ad.1 for ; Tue, 30 Jul 2024 06:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722346525; x=1722951325; 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=L/IDlFAeukJ6Uvym5ROFNrpBdJcgMaw+Hcdne8xKjTovKlJ7wasZYvRe1Zy9VqnqI+ fBfu4MhnfpNIgHGG0CSv5kA/qWTi0IZ79CrzX4FjvzEf2XAz1werdElPGUsWA7LxGMuf 8gJptttbifYoMLfsZtAF2Jq++cB7IOJwlOMu7btuGCRFupnmOfGRVrkl8zTGDTRiGHsD /7xLb6u1yyDWSbGX2uoThf1A/r05NYsDfhbT3Zx1q46BxhuTjFTswzFRwpP96Qi9PqOX gsJsNBqnyteQB+yloBILMkUjUAFlq95A+XXvWWv1zYc6IgfwFp0mV5QT6MuYhrZK8tBt dSdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722346525; x=1722951325; 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=MhKge6qBG5tIGgyQbTrd0NtrHtwemviWc6ezlpthwcU7AXXvnxa4Erb8eG8OYppqQ6 7OQZyA/ScpVUajRyZu7+NhQRu8wZxyHKYt1eMJbsbcWLt+L6ERUoV+a3cxsvpalHNggL BSPmdLBq38O0Ysy/BnoibXD9u8hwgJh6WgDJnLbZnj4ZP7LD2Up3u3Atx8vNRanhmYkY oUGYw3dfXk/64TdTWbV25DuB43Gq4ndb2ebrtvSzsd5Vyv5xASBuMc7gS0qSg2wu+/rk fkbK/bplFE/DSvjFWKDsIBop2Acju7f44gm0J6t4VtKuNz0O5AwQBl2HGVIDPXod9Fxy X6EQ== X-Gm-Message-State: AOJu0Yxk+ZGYC40yI7IQgmUyvo6s2QuBQYZ2DfHiFYkO5n3z7nuawxF/ IiBZ1PYQ+rmjpv7TeGQLIW5M3DCPe+Pj8inaywArya1bU2gR67ih X-Google-Smtp-Source: AGHT+IFRahXyV6JgGqW6WzrbHsB+RMigZXaf34XD5RwC2N5bN8BI1jzD1SioBvkJzJ0hjtxBWAQYlQ== X-Received: by 2002:a17:903:1cc:b0:1fb:6b94:66ee with SMTP id d9443c01a7336-1ff048421ccmr98217945ad.26.1722346525308; Tue, 30 Jul 2024 06:35:25 -0700 (PDT) Received: from KERNELXING-MC1.tencent.com ([114.253.36.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f9f279sm101562515ad.256.2024.07.30.06.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 06:35:24 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next 1/6] tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_CLOSE for active reset Date: Tue, 30 Jul 2024 21:35:08 +0800 Message-Id: <20240730133513.99986-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240730133513.99986-1-kerneljasonxing@gmail.com> References: <20240730133513.99986-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 --- 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 Tue Jul 30 13:35:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13747397 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 11CF41A00F4 for ; Tue, 30 Jul 2024 13:35:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346531; cv=none; b=qVifGR1tAVJ+sPpher+UO5OjWWOqyfeNQi38734KnbDj/wjwpJA2BfPxu3PrRaPhzziRFnXTfEr/4U7H2rz+PrZTM2rB9XCHEUvTIpSfyOjy7cZwgQAI2HoflW09sWLSW6hHPZxgOp0cDr+LocBktaXJ/Cmyi5hM/OrhjQq2FpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346531; c=relaxed/simple; bh=sELGKtAigfVF1zgsTyPKm9ZUrrRps71mcbi75aSK++o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jkyWGyd33Ep+9muU4A55+HdnHFpZTOqzDjG3wz6rB35mbQhDUkyr47j7nmuEPW/S9ti9zDqEtHANPFqUAVVfeqxid9UufFhGCMtbyT2rGDNlkgEZ884SxzWw94Q2F1i2t7dP8glqQWhJeerMP+qFJojryLD/bj4TjfmE2FgQxTg= 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=LD1/ryoR; arc=none smtp.client-ip=209.85.214.172 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="LD1/ryoR" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1fc66fc35f2so27613495ad.0 for ; Tue, 30 Jul 2024 06:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722346529; x=1722951329; 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=LD1/ryoRxT0nIERyFzLMivcWwhpp/syViGuqE5v/DJG6KH0bGlizB0fuQXhn6E11uK wkHyZTljWP65paCZ21vRlg6qqwW0uX0EJetpolZmlgbNihhqodIu8oZBnjCJ0J4sGMCK uL/OLijJTp7t8JOqmmWl/QD1SyG7xT4GmnnmP8pG243KVuXQoo1it87qtCdwTIp3/S2I GEtOkQrjgdduaN84hzlg2EOVwP15a+peROl2mSf+84ddv2Cn4/CEQoWkBtkHIYrBIsJk 9DzNEovJz30uhW5DSepV1qNzPOUzMNbIz8dC4EG0iqGFnImDxUt09LhBokgBtjOR9bsT RHrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722346529; x=1722951329; 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=VgkhMG+LgC1WsuiiN4Wms0u+sr+pU2WkTun+QM5IxGPAkcwdsaFXdI+kSnzUWpC8/A iS3mBZsRXUfCpz9NW5sT8u2yGy4WE49JWa0pOxL9mglYEFpqTSyLHvar26dY+3Gc16xh FPWE//0zgAuWC4zKBAvE8w9EM3qLfoe7n18/4Flm6l0bESW1NAFFvtEDpLYV2NJEOKVl uOeFJ5XP/oCyiLytghsUp6v+dwQ/CL51KTetvfguM1T+QfRsT3UirXzkyu1dQaQkW/At 9BGTjZsLJKLBp6lC9B+2TqNt9Mhb5r4dRmSWB4B+V8JqcFzKi+J3RIG0TsC7lhRA9Oo5 k7Ww== X-Gm-Message-State: AOJu0Yy9EebREGTjfECwl/VMmsT9ZqVRxYM7vL2Oza4Qon9FJ3kp14VP QYZMDOIjog4bUGX+OoArICB1TYYwLyL2DLQVBqhIFAlgSnZFHDtJ X-Google-Smtp-Source: AGHT+IG3CI80cROfbxu63IzeFExoOOumfbgslulntkl1plJxUNGPk+m6W5wVcL5IQE75UbfbOj9VYw== X-Received: by 2002:a17:903:246:b0:1fd:6033:f94e with SMTP id d9443c01a7336-1ff37c111damr36581345ad.27.1722346529338; Tue, 30 Jul 2024 06:35:29 -0700 (PDT) Received: from KERNELXING-MC1.tencent.com ([114.253.36.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f9f279sm101562515ad.256.2024.07.30.06.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 06:35:28 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next 2/6] tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_LINGER for active reset Date: Tue, 30 Jul 2024 21:35:09 +0800 Message-Id: <20240730133513.99986-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240730133513.99986-1-kerneljasonxing@gmail.com> References: <20240730133513.99986-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 --- 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 Tue Jul 30 13:35:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13747398 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 4EB571A00F4 for ; Tue, 30 Jul 2024 13:35:34 +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=1722346535; cv=none; b=r/ZMxNseUxYmz5nAgm/gd6jfgQUu7MMHzA1W79tIgJ32gsylqIILHIZUYC72RijnoCq3XS1MJWXr96pm7Wcnz866XUuSNxEfjV3mb2ofCvT402Ei3p3pEbxEQDYOZO18QlmruMTRkLehBb8ZfyVc7XQObaUXAu5rSd1gZoaB9f4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346535; c=relaxed/simple; bh=wVa1ccJeseNY3fiGdLHG7LQGRcIJthDze9EEAOwxBQ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K2uRReMBaXRP5l8N6nwxn7qGIWBTITm6p81Vr3lSUVqUKZFui0KnQq1R9E3kimAOd5q94qJysobKLf/rFfA/2XP3QpD56C201Un1TQDVKl/SEbE1F7ZE2jvllA8rfkEKLPfoVtcfUIZ0zm+mctE/4pGVI/iCp5CT8tDg0PbF0ug= 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=Y32ASjw3; 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="Y32ASjw3" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-70d19c525b5so2964665b3a.2 for ; Tue, 30 Jul 2024 06:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722346533; x=1722951333; 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=Y32ASjw3+xxZbZA0pYjS/EX6JYNTcuA1r0aBeUK7sW9N2EdporjEeJudXh6M/zwQfN V/hbQS9FumveBMhiq5aMgH2LuXJDLomJpT8VzTgeFCt/ua1l0T9SsGyRsF7XdDInsQWv wgtOjKmS5n2GAN5nrq+1LSyCy8YzruEW59wDXzq4Wjpss+8gQHXaxmxUwPyy3yKlKvti N16HLtep0F+FuOCGj4Fjqmt265fMfwd20Llut1b+ZiObz1EBSvznCkrt/xALTp9bq8wW jH/MkFxWhCTwqbyJ6Sb11BANPWeqh4ipVAZKkGsVHSsflsATOl00raO6p32dx5ifDcAu 3eUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722346533; x=1722951333; 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=XAoFLn1KTK+qHJB90sPF4ooe0zQOMJH+6zcvotkLmKUlXMCrGjG0RtCprm05rrbgJT 9b09n0n4VYQDZPUxm4recukvKCQSbDsWE6Xm93V3ecDTiCtDKg8H0/Zft78YO+dsDk7v B+zwS5S+rd3e3kOi5pXDIn7ay1yOBEHlA0Wok3BmZhtkJWiR7SYuXXy+9zZLnZjKnnXe qXeFSecNCG16xVLa8jbUZxs/wBfHxsrQPdv6iKRa4qDeEMaBwVNaDP5JI7LJIeI+/aKt DwAbFosEMdpEkqNy1G4magB+774uEvHKUWWTFnWuZJ3zTn2GsI99PtlP964Yu6fGpV8h 9ebg== X-Gm-Message-State: AOJu0Yz4ZweQpE7IIUDl78/wCfdCKdNmQYOHC49vbGKQEqMfbelwMgzy MdZSanQt6hPnkq9tqUokx9ZJ3hx7t2GBNr67ZoP1Lds0pbkNvOYm X-Google-Smtp-Source: AGHT+IHcxdCevNPSZ6r0szV4wO6JEqMGfGgBm7owlgkBAP5MGBNgn2/S+ukcvfHRKy1x7gNpqjUWsQ== X-Received: by 2002:a17:903:1c2:b0:1fd:9c2d:2f17 with SMTP id d9443c01a7336-1ff048e1ddamr93639245ad.44.1722346533423; Tue, 30 Jul 2024 06:35:33 -0700 (PDT) Received: from KERNELXING-MC1.tencent.com ([114.253.36.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f9f279sm101562515ad.256.2024.07.30.06.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 06:35:32 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next 3/6] tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_MEMORY for active reset Date: Tue, 30 Jul 2024 21:35:10 +0800 Message-Id: <20240730133513.99986-4-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240730133513.99986-1-kerneljasonxing@gmail.com> References: <20240730133513.99986-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 --- 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 Tue Jul 30 13:35:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13747399 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 4F5D81A00F4 for ; Tue, 30 Jul 2024 13:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346539; cv=none; b=rUwttZqYfr9uwSUL5YFiWASuHBvv52nMqwY9rilaZaBQRH8FH5UkwE4gozFpv35+uZWq0AP2ibSHggMAS3V80ueiDYeKCCeT3V/FDV1X8RPAH0bST0/WGKqgmC898t68WiqDNlcKMaSA5jcvBTfD/794KtmcEE15tXJH13fv4wE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346539; c=relaxed/simple; bh=gNRYtyPxTW5j0lVp3MPsk/y0Ru1C6PQUvY0RuwJleqc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LW2vGnZvnLq50utcovMHE/b5bsE77V5NzVXFR7nd3/LQL21tRfJzZ+D+XCT0dS6J0ZcD4JVnqzHFyauJnnDcgHsYvt96msruq3esNzyzVR8U+rLb0ZpjB25jFluyAfvY7ACRc6EWfc7hezeo/e+lLDufYRT+on5+ZJxy+V+qQcU= 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=fAuHPpKD; arc=none smtp.client-ip=209.85.214.181 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="fAuHPpKD" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fc658b6b2eso33492835ad.0 for ; Tue, 30 Jul 2024 06:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722346537; x=1722951337; 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=rrQYXJBKKEioBOqfWbTtlBWFqhm2B7GtE3jbVtpk0tU=; b=fAuHPpKDtLQTFohHGozxdbu4/Hgu6s5tTzWX0avgZ5RN9ukQkcdacsRndDPsqTitNH GpA9EeF3/T0WWoVZ0hG6LAbTfc58+n0Z7VVl7JaNqHUiWzfA9BfcoMArDnvfgFVLD0oa 51y2wwGWE13a4vJIBSvHNXAjVvFxc9y2b0Ik3f2u7sv6faKD/5XF762lcGCz/Rg+xlt5 uDsCHErNfKPq+YdVsEjtxPWiRwHWbledYa0SbLiP48oTaZGCO3F8Ltz5nZLaY3vX4zuv P1fuPrPfaWKKNpbV7i95zOT0wGd6VHir1dYz2DpRKsDE1YTd7UNXRMdaJ9WySYZfF6Aq s2Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722346537; x=1722951337; 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=rrQYXJBKKEioBOqfWbTtlBWFqhm2B7GtE3jbVtpk0tU=; b=udh2LAp/pRtRvWRksKTL7H5vddjZwBA76c44P1YqLHIuS6tbVCrEwzYYo6zKJrCXVA WXoAsZk/XNUVRD7HuDAs1rYnXaUNX2leObo91jNKzSdUuVJzeoNcbnzqu3EU8g5enXSC IxqaVN09hxvolfVbhbe/eYDsDXPcySNPb+HLtPQ1q8ZsTop0sU5R/1sjIwA0E8jY7eSW qv4fGykhgKkq08nR2RF36b7lgOZfobdYnqtvMv+s3AYQhQw5miBa7stonVtq4r9CgCiB 1YS4fFxHlCWZ7EnEi8JV1oYRtIu2YCyZuJOOH4CXd2MacPuljy21BzlNz3DlTH1+/HzI NXlw== X-Gm-Message-State: AOJu0Yxu2CWPOgtev4InFcZiytQHRB7cYrjZodA1KzjIepEQ/JBXrEMo WAGhPfcg29YrHqI174lmYrSoEIQ64X8eSMni884vf8Sn1ISqdmeQ X-Google-Smtp-Source: AGHT+IHkHILUM3Y06/JXPevGkqHgyam6P6Ei0HXJzlWST4G0NLgof3/PIrm3lmoW5z21YI6lqDpSOQ== X-Received: by 2002:a17:902:f683:b0:1fc:3daa:3a3 with SMTP id d9443c01a7336-1ff04854dd9mr129624895ad.39.1722346537548; Tue, 30 Jul 2024 06:35:37 -0700 (PDT) Received: from KERNELXING-MC1.tencent.com ([114.253.36.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f9f279sm101562515ad.256.2024.07.30.06.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 06:35:36 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next 4/6] tcp: rstreason: introduce SK_RST_REASON_TCP_STATE for active reset Date: Tue, 30 Jul 2024 21:35:11 +0800 Message-Id: <20240730133513.99986-5-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240730133513.99986-1-kerneljasonxing@gmail.com> References: <20240730133513.99986-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. Signed-off-by: Jason Xing --- 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..fecaa57f1634 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 793 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 Tue Jul 30 13:35:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13747400 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 613C51A070E for ; Tue, 30 Jul 2024 13:35:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346543; cv=none; b=q9Pn3cY5+Zgog8nISqMQXklHyMOEhJcGsdA/64lf+9ysY7jlaNwSU7ncDawdkxh003V6uU+NEC53q1EDJAMh9VHAa9RWT9XJGLBHbcXvFl2wV7047sxMYFfRer2syX8UIGQLFFKAczd2ufXbU/quayrDHPXafWhpEi4yeWiAMGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346543; c=relaxed/simple; bh=muj48Rby8axVXDjlC75D5v6qvbHfw5sbPBHewVslqvo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FfwroZYdKzJkkLE/M4SwaIUM+12ZDEk8V4kKeT8kSATftvIaeR3SaS9n0TemI5SjkvQY2LpdfNKO6oBcnxmLVwRIH82XzJa8lWhz3m75XmPDzG47XSx2Hj1wqperIoUQZ961a4MRCdq/n1OrO0Ec7p/IKwYXK6HGgY0KUOj4cV0= 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=ST57Lm+6; arc=none smtp.client-ip=209.85.214.181 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="ST57Lm+6" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fc5296e214so32736875ad.0 for ; Tue, 30 Jul 2024 06:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722346541; x=1722951341; 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=hBwC0xtR8VWUdgnjbtcrVKP8K9w2i0toxt+qfaBwjT0=; b=ST57Lm+6JvSPQLWjst6PwiEL5fY/ep/uQPTFs4oz8zaOcRDs815tMDh24YpVWRQ9tF YPTp/De+WDjCl89xjqz8j1LulK+SF5ExWD8k6O8btlVnRM5iAdadx7gErg6+2uPmwHzn +x2544alnsqVv5y9F7PnDuGxPhR8B6m+BsGkQd+vBPA5pKBUM+BJRSMqaBhOAYo/k9de XfZD9oP+4kbw/6QwPM8F8R2LpiXd4TH7JHSTxw4xBSXQWAV6gGuhF9LZIUKo8rsCKhyH 3RD3ZXSlfdbLIfOi0t8Kkn/l5AAAIAKWqjZX4VH2GAn7XJ/PPluQsE2cHhwJuN4OhfXn GNCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722346541; x=1722951341; 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=hBwC0xtR8VWUdgnjbtcrVKP8K9w2i0toxt+qfaBwjT0=; b=idjOJ8OdKMjNghTqBw1tLuXZrfhZyZxB3egOQS0QDZr7GdOvT40eswuuzqnyIGXTRd VvKBoBYKXGLo4O5P4rTHu+YYwxQZekyzlWJYf8fgfOXtqHyI7l8XiiDZkWFGCz4H0voP AoDqqj3IGWHKhNSOwnczaQWV6utIWYWlsbGLLYF3swhIaVlqOGSRpt7JX6ivuCbrAnid sri+sffESkYf9Z++VQU4ZtERS7VOC3jCcXNx8YnyAnFS5ywa/hCbYtoHtqm/mk1tQYaa Sy2530dEqkOqyNzX8ANTybtyEGdQoNnG1Us5GOorRmbXKd13NLipVh5dA8VVwZfYAUlH S8lw== X-Gm-Message-State: AOJu0YzPWDXK8E81JJQj2fhn9l9cJboRoIXuwhygVden6S/T9tW7kj9J PTamYlg0MWkdzWN7q1LKJY7J0vN17aI555cOEpe1VUIEP9fI1zCKYGeBwWeI X-Google-Smtp-Source: AGHT+IH29OGxC1WCdq3ZeS71ASq64KrnqyJRe4YX/PzdxMMI0/A3sH095L1OjUP5T9PQGboJYK9TMA== X-Received: by 2002:a17:903:1c8:b0:1fb:a38b:c5a7 with SMTP id d9443c01a7336-1ff047dd4a3mr154008005ad.13.1722346541617; Tue, 30 Jul 2024 06:35:41 -0700 (PDT) Received: from KERNELXING-MC1.tencent.com ([114.253.36.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f9f279sm101562515ad.256.2024.07.30.06.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 06:35:41 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next 5/6] tcp: rstreason: introduce SK_RST_REASON_TCP_TIMEOUT for active reset Date: Tue, 30 Jul 2024 21:35:12 +0800 Message-Id: <20240730133513.99986-6-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240730133513.99986-1-kerneljasonxing@gmail.com> References: <20240730133513.99986-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 Only when user sets TCP_USER_TIMEOUT option and there is no left chance to proceed, we will send an RST to the other side. Signed-off-by: Jason Xing --- include/net/rstreason.h | 7 +++++++ net/ipv4/tcp_timer.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/net/rstreason.h b/include/net/rstreason.h index fecaa57f1634..ca10aaebd768 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,12 @@ enum sk_rst_reason { * Please see RFC 793 for all possible reset conditions */ SK_RST_REASON_TCP_STATE, + /** + * @SK_RST_REASON_TCP_TIMEOUT: time to timeout + * When user sets TCP_USER_TIMEOUT options and run out of all the + * chance, 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 Tue Jul 30 13:35:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13747401 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.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 B2D3D1A0720 for ; Tue, 30 Jul 2024 13:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346548; cv=none; b=jBGjh+zm0vv+bNp83IBNsszT/fliFyazjKSh1SIN5sa+MoQuiIW99wsuWmJCkfuB7KEDz4TNHMlY8DDXHTnXG9xPjkMzHZKYVfImizZJLtqlDXDry1bEKNTCn3Pk6BPKOum1FumSxxhQEOAcOSuqrGNyJG/pddEzuBeWrOq4mbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722346548; c=relaxed/simple; bh=TJhLBE/1dDFmQcXMCrFDSflxqCoEQKoFBZolCz3PYeQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f2cx58CxYh4OMpyFhztmjKwUx2Ej2K7DFwWvXtM+ofo1xSKmw2GN6MJegGZG8pOnZG1bYfGiDI/+WYpBxcqnMMeFWEzgArOYBP2IeSR39ZPOjwXoAquop8fG1rZRSpCTWtUBfSy488oYChM71mwPGs297NB+QkDtQQSMsbFlJPM= 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=c1/8Obk6; arc=none smtp.client-ip=209.85.214.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="c1/8Obk6" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1fc65329979so35901515ad.0 for ; Tue, 30 Jul 2024 06:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722346546; x=1722951346; 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=c1/8Obk6ZJ/JJHrC5ORsbCTwdJ1DF6YJ7lGiZ6XHj9/yX+dZ7atHsFWl3iJycqnzn0 ya7pPj/lOOo0R/WzGAkblzDlZ01cvgP9aECl5Vk/iO9UJzOOu+9tWTJYo49kCngcPnoz o68pC/aYLRLEChDz5OK3edrdk/pq+VxJ/ZRs7uU0qvGQExHD6eJ2W/uUj9ZDEdoJlP0T +viTBOsvRhbvVgUvHmFv7h0FhpRCUlz6mXD+ql21GMaOrIxOiARYs/Z5CgjI6XU6SVsl +lAb4gCVVH3lMOCXem5gMnqbg8NsE1HFrHOrZsPWnqqpywG7eVGuqzq9Z4nKDOWgy/cM Ds6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722346546; x=1722951346; 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=I74+KReS15QrKCKnbCT12VxRkG3Al5wJr1x823R2qGCx6en7lJoh2JUdztZ2Uu1iKV 6CxBuDk87B7ZNIOiUrv5dqymQ1X7jIGtAOMt4sLuQ6D+7OnZfdK64sXdU8lBvGuOyVPB qEUZxNDkjwv1m3Q+nLE5+YXo6i26hNpJswfKORPGzwKrfKt5eGIvyiHmg/A0HHGawQTm uTsZdhZDmL0AF5XkWqiuVwU+kbgN3/pgxIr7Of4vHhT2YF/Tf4nF0NEfBwsFE8gZTIig Bz7ZiAkqGLhdGPjpqNfIErB/3jXsJiEdTrMbCsAojNbmVw3IQNQhWXt4bJFHQtN8W5ah jOLw== X-Gm-Message-State: AOJu0Yys6I8c7asvZIlJ6S+SxKJHlu2wCj4+hmv62onA+heWh9Rcloym GdRZHvTdnYpTKn9+8Dc4MNfHH7NI7CgGs7eUG98zmlLtKOSxHsOP X-Google-Smtp-Source: AGHT+IFGRSj1xTQLos2xhBwPDep/WWZJwNEQ8UUgyLSGhW+6edpBqJV4isvR3KHgWcL6TLC8YOj5VQ== X-Received: by 2002:a17:903:2352:b0:1fd:5fa0:e98f with SMTP id d9443c01a7336-1ff048d4d3amr126359945ad.44.1722346545692; Tue, 30 Jul 2024 06:35:45 -0700 (PDT) Received: from KERNELXING-MC1.tencent.com ([114.253.36.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f9f279sm101562515ad.256.2024.07.30.06.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 06:35:45 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next 6/6] tcp: rstreason: let it work finally in tcp_send_active_reset() Date: Tue, 30 Jul 2024 21:35:13 +0800 Message-Id: <20240730133513.99986-7-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240730133513.99986-1-kerneljasonxing@gmail.com> References: <20240730133513.99986-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.