From nobody Sat May 18 19:24:32 2024 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (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 9D05D128809 for ; Tue, 16 Apr 2024 11:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267624; cv=none; b=diHN41oBVHZf3anzECMqH7esd3gWF87ukOERAXCDz9J1pMujKxLSsJ32KHKFjMRNJDkQK9T9ZTptUVWZsWqTOvaqCVrI2a7Z41lPbHXP5LKRmVB36aqexr5GkHUb0FhQ88+lKf9ASvY6+Q1pHkue1afMMDNXtTZjEeCWZ+6z/Yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267624; c=relaxed/simple; bh=RJnbFc5JHAO9cPZZJOzJbZBugWtXN/ZrYKzKfwfgFG0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a2YyUCtXf+SudxYam9v0GHfSBykIxVLw1YJ/dlBnUaxieKmyULuSzBSq7YoiBYJ2jG1vkkJEDle5Rbve7D6TLMxIul0QMTmyoBdYMO+gUQPbuuo/yjteKZ+e3vIFFre5hTw2yjZrTeliXH/B6MWRvjJJmxOkKV7Wi1w/RDDTM3A= 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=H82fPff/; arc=none smtp.client-ip=209.85.160.41 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="H82fPff/" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-232f2b86e4fso2087136fac.3 for ; Tue, 16 Apr 2024 04:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713267622; x=1713872422; darn=lists.linux.dev; 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=2UH4meUAVHMlL8PvFN7UeOC3D/JlMgEbNXoAK969ZI8=; b=H82fPff///+G1doV9MLHtLVmx8CirWdWTCQ902oN5O3jkWuDul/laBeoNuqTPvJbHy /cjWiOwKa5u/YmpECGVKab1N5Qd9PTHVs0AuBBwD+e5sTjghcJCOfy3HCkrZVI0WmmLB cE51df8H0HlXfB/5/FVda3hR1xoyzjLYynfLzBrE2Xi4/FeHAdRKt5rnxp3ucWeCfBu/ or2TJ7wRb1xz1/FWKeGzMKMFkwWctaoG+9g/T53mJuyYZ7clralJSc6iWR2EtPnG7l9L qYB8xZkpVw92kBfwihkWqpqs+ma7I1nSOLHwuwmlD19NnjBPdKpdvdMUHYATtiba121r qy0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713267622; x=1713872422; 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=2UH4meUAVHMlL8PvFN7UeOC3D/JlMgEbNXoAK969ZI8=; b=SPscFpLzadelIi1yGQpk3R9uisjYGWrlGBUxeEy2V7z6M2/OWSfNFRQ85UJ5eaQ+B6 UW6ujzGjPONTtp8OFYFQRQhM3v31rMHpU2RvWY+Tw2+OFSEuU9jDUEwok8b2MJXKC/gb 2ZqKCNXjGv6A4hYFtOkhpi6/Zj7CyRf68kJr1fPx3fDnJ6JjjbZQRv3Y3c1XUaxXWlnv QQJWs7L1JgxusOfhznmb7ncAbUAcJ4IM5A6SLx10vBPEnBAdBRnBYmFAMW0gLLSHicgH 6McVF1+m2SEwKkyYekElbs/ThHr20RAA5S35P1XyrX8h4P3KXbMrIdJEQJAsjdleU+AD yiTg== X-Gm-Message-State: AOJu0YzgEYs78EpUwl5MogAnITF5SrQohRw5wtsJqWMlpvYK8xUK4Cbo Qu28pq2mGMMcMrbPOGlmt2OS7j0wAV5SaYsK3CCQXPpbM8fQx+JI X-Google-Smtp-Source: AGHT+IG0uu+2aacCqrUFlmiuiLMgv4QcVanCDLIWG6wQyK6aBj9DGPhtrmVjFSdgM3BKuR42EM3dpQ== X-Received: by 2002:a05:6870:f286:b0:222:a91a:63cd with SMTP id u6-20020a056870f28600b00222a91a63cdmr13449674oap.45.1713267621604; Tue, 16 Apr 2024 04:40:21 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id a21-20020aa78655000000b006e6c16179dbsm8862045pfo.24.2024.04.16.04.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 04:40:21 -0700 (PDT) From: Jason Xing To: edumazet@google.com, dsahern@kernel.org, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, atenart@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v5 1/7] net: introduce rstreason to detect why the RST is sent Date: Tue, 16 Apr 2024 19:39:57 +0800 Message-Id: <20240416114003.62110-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416114003.62110-1-kerneljasonxing@gmail.com> References: <20240416114003.62110-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing Add a new standalone file for the easy future extension to support both active reset and passive reset in the TCP/DCCP/MPTCP protocols. This patch only does the preparations for reset reason mechanism, nothing else changes. The reset reasons are divided into three parts: 1) reuse drop reasons for passive reset in TCP 2) reuse MP_TCPRST option for MPTCP 3) our own reasons I will implement the basic codes of active/passive reset reason in those three protocols, which is not complete for this moment. But it provides a new chance to let other people add more reasons into it:) Signed-off-by: Jason Xing --- include/net/rstreason.h | 93 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 include/net/rstreason.h diff --git a/include/net/rstreason.h b/include/net/rstreason.h new file mode 100644 index 000000000000..0c3fa55fa62f --- /dev/null +++ b/include/net/rstreason.h @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _LINUX_RSTREASON_H +#define _LINUX_RSTREASON_H +#include + +#define DEFINE_RST_REASON(FN, FNe) \ + FN(MPTCP_RST_EUNSPEC) \ + FN(MPTCP_RST_EMPTCP) \ + FN(MPTCP_RST_ERESOURCE) \ + FN(MPTCP_RST_EPROHIBIT) \ + FN(MPTCP_RST_EWQ2BIG) \ + FN(MPTCP_RST_EBADPERF) \ + FN(MPTCP_RST_EMIDDLEBOX) \ + FN(NOT_SPECIFIED) \ + FNe(MAX) + +#define RST_REASON_START (SKB_DROP_REASON_MAX + 1) + +/* There are three parts in order: + * 1) 0 - SKB_DROP_REASON_MAX: rely on drop reasons for passive reset in T= CP + * 2) SKB_DROP_REASON_MAX + 1 - MPTCP_RST_EMIDDLEBOX: for MPTCP use + * 3) MPTCP_RST_EMIDDLEBOX - SK_RST_REASON_MAX: independent reset reason + */ +enum sk_rst_reason { + /* Leave this 'blank' part (0-SKB_DROP_REASON_MAX) for the reuse + * of skb drop reason because rst reason relies on what drop reason + * indicates exactly why it could happen. + */ + + /* Copy from include/uapi/linux/mptcp.h. + * These reset fields will not be changed since they adhere to + * RFC 8684. So do not touch them. I'm going to list each definition + * of them respectively. + */ + /* Unspecified error. + * This is the default error; it implies that the subflow is no + * longer available. The presence of this option shows that the + * RST was generated by an MPTCP-aware device. + */ + SK_RST_REASON_MPTCP_RST_EUNSPEC =3D RST_REASON_START, + /* MPTCP-specific error. + * An error has been detected in the processing of MPTCP options. + * This is the usual reason code to return in the cases where a RST + * is being sent to close a subflow because of an invalid response. + */ + SK_RST_REASON_MPTCP_RST_EMPTCP, + /* Lack of resources. + * This code indicates that the sending host does not have enough + * resources to support the terminated subflow. + */ + SK_RST_REASON_MPTCP_RST_ERESOURCE, + /* Administratively prohibited. + * This code indicates that the requested subflow is prohibited by + * the policies of the sending host. + */ + SK_RST_REASON_MPTCP_RST_EPROHIBIT, + /* Too much outstanding data. + * This code indicates that there is an excessive amount of data + * that needs to be transmitted over the terminated subflow while + * having already been acknowledged over one or more other subflows. + * This may occur if a path has been unavailable for a short period + * and it is more efficient to reset and start again than it is to + * retransmit the queued data. + */ + SK_RST_REASON_MPTCP_RST_EWQ2BIG, + /* Unacceptable performance. + * This code indicates that the performance of this subflow was + * too low compared to the other subflows of this Multipath TCP + * connection. + */ + SK_RST_REASON_MPTCP_RST_EBADPERF, + /* Middlebox interference. + * Middlebox interference has been detected over this subflow, + * making MPTCP signaling invalid. For example, this may be sent + * if the checksum does not validate. + */ + SK_RST_REASON_MPTCP_RST_EMIDDLEBOX, + + /* For the real standalone socket reset reason, we start from here */ + SK_RST_REASON_NOT_SPECIFIED, + + /* Maximum of socket reset reasons. + * It shouldn't be used as a real 'reason'. + */ + SK_RST_REASON_MAX, +}; + +static inline enum sk_rst_reason convert_mptcp_reason(u32 reason) +{ + return reason +=3D RST_REASON_START; +} +#endif --=20 2.37.3 From nobody Sat May 18 19:24:32 2024 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 8A1D1129A69 for ; Tue, 16 Apr 2024 11:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267629; cv=none; b=d1DHSgnYqLDqQaiPoez9nH2o/4rmcUSNlKfXSL7V03S/GIXQB0n0gCsyVn3Ruqlbc14xSAQw3KylWNneT1sJHwq834bGDi7Asp1eXmSGi7C6FPN1HswktOcgIDfx8+I85dYC6CykXKBUMzZQmTzXYP4Eq3F2Is5JTMFqdr9Qq+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267629; c=relaxed/simple; bh=R72y8G3W+r5Gv772gRuKqyNYdMiisYHVyoC5CLyv1S8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UIfr4aeB7x9PVKsZRhdnpoQzsRsJTxAxoei2dBjlKK82LGqkH6XnQrs2u5QyuX4qIUHyq6Gj4ktklF5mEY1VtngAwmzG1KHF39xu2z6HjripuR8RR33F9Fk1BDYPlWcSWmH2Pej7WJiBjRpubOhQFdRWTPAPEJ79+o+3CFSsXRU= 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=PTDY8IPB; arc=none smtp.client-ip=209.85.215.174 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="PTDY8IPB" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-5d4a1e66750so2277658a12.0 for ; Tue, 16 Apr 2024 04:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713267626; x=1713872426; darn=lists.linux.dev; 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=i6oTHYgz5TngiL2FyP+veB9hzruY6XcRakjEoX1j6fI=; b=PTDY8IPBz/biQeL0DNgPhsWQAdwPAoqsDQy1IvQ+kyIv1kSfmBjS8yvKERjSf99v50 lljXMrAPs6RO2ldNtWfqeIB4Jnxw6go5KvToun6DO8zyDisPAhaOIFnN/RysCbuOqAKZ +DoAexJ+UX9l9HLsE2u2o1GEdVLAQoloxtSR3aKi+s1Qc5wEawxCafPTBGZ6T0IArFV+ CPBZHByRGNB9bvlFyYXlPdUScKKxfmenL+0VX6thcKA81bHu802jz8nATMRjb2pVuEqj e66NgDw/NRvsGgvUL9lq9vfl0MLrgk9mianFzuuKVtZYGO9QO+pbdGC3BnDlmOCa6L/A 1+lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713267626; x=1713872426; 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=i6oTHYgz5TngiL2FyP+veB9hzruY6XcRakjEoX1j6fI=; b=MQ6Fd/Kl8F3KH9+LaF2nGbNC5ljC5lOECd059ko8tiAw6YzPoYby4ufpEWPfHa5VSh Aav23f6Pdh9EzReUaxhqlCJ5DX5tGY8jPoQGygMK3lg4+XqIXRuN1EPhcWNulT7IgzHh ADKMv4JMsDrlYGajayKlxSnuPni5rBT5k09spLMpDg0rysSVW04DwUpnmNOahWi9GaKn xqWDioi7uW54sQwm+U9t3yKvtszAZDAVFKJRsZirfkj5F8rVpPrKNIscBUxSDxlTrRhp BZ+LUwEj96IDZ5LhMg5Kyq42ZUCu6LtSqKh+y1delXLUDxNzIxqkrellww4eLaffBjrT e63g== X-Gm-Message-State: AOJu0YyhYi1HDMEf3Z+JV4mNwxMMqQUX6fPkxqnGYyfi9qZW30MDFMbb fUqiGkjTsi7FqIdZWu+4JdfC6t10PeiFzivbUev+z2MyxjUtlh0D X-Google-Smtp-Source: AGHT+IHwBgtTq9t2BUzSZi+qYWm8XShSYiNyddMRKqDyI7088zu5/lJprBncOBCfByd0geGHFSmq6A== X-Received: by 2002:a05:6a21:998f:b0:1a7:75ee:6742 with SMTP id ve15-20020a056a21998f00b001a775ee6742mr14223583pzb.2.1713267625692; Tue, 16 Apr 2024 04:40:25 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id a21-20020aa78655000000b006e6c16179dbsm8862045pfo.24.2024.04.16.04.40.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 04:40:25 -0700 (PDT) From: Jason Xing To: edumazet@google.com, dsahern@kernel.org, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, atenart@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v5 2/7] rstreason: prepare for passive reset Date: Tue, 16 Apr 2024 19:39:58 +0800 Message-Id: <20240416114003.62110-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416114003.62110-1-kerneljasonxing@gmail.com> References: <20240416114003.62110-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing Adjust the parameter and support passing reason of reset which is for now NOT_SPECIFIED. No functional changes. Signed-off-by: Jason Xing --- include/net/request_sock.h | 4 +++- net/dccp/ipv4.c | 10 ++++++---- net/dccp/ipv6.c | 10 ++++++---- net/dccp/minisocks.c | 3 ++- net/ipv4/tcp_ipv4.c | 12 +++++++----- net/ipv4/tcp_minisocks.c | 3 ++- net/ipv6/tcp_ipv6.c | 15 +++++++++------ net/mptcp/subflow.c | 8 +++++--- 8 files changed, 40 insertions(+), 25 deletions(-) diff --git a/include/net/request_sock.h b/include/net/request_sock.h index 004e651e6067..bdc737832da6 100644 --- a/include/net/request_sock.h +++ b/include/net/request_sock.h @@ -18,6 +18,7 @@ #include =20 #include +#include =20 struct request_sock; struct sk_buff; @@ -34,7 +35,8 @@ struct request_sock_ops { void (*send_ack)(const struct sock *sk, struct sk_buff *skb, struct request_sock *req); void (*send_reset)(const struct sock *sk, - struct sk_buff *skb); + struct sk_buff *skb, + enum sk_rst_reason reason); void (*destructor)(struct request_sock *req); void (*syn_ack_timeout)(const struct request_sock *req); }; diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 9fc9cea4c251..ff41bd6f99c3 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 #include "ackvec.h" #include "ccid.h" @@ -521,7 +522,8 @@ static int dccp_v4_send_response(const struct sock *sk,= struct request_sock *req return err; } =20 -static void dccp_v4_ctl_send_reset(const struct sock *sk, struct sk_buff *= rxskb) +static void dccp_v4_ctl_send_reset(const struct sock *sk, struct sk_buff *= rxskb, + enum sk_rst_reason reason) { int err; const struct iphdr *rxiph; @@ -706,7 +708,7 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) return 0; =20 reset: - dccp_v4_ctl_send_reset(sk, skb); + dccp_v4_ctl_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); kfree_skb(skb); return 0; } @@ -869,7 +871,7 @@ static int dccp_v4_rcv(struct sk_buff *skb) if (nsk =3D=3D sk) { reqsk_put(req); } else if (dccp_child_process(sk, nsk, skb)) { - dccp_v4_ctl_send_reset(sk, skb); + dccp_v4_ctl_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); goto discard_and_relse; } else { sock_put(sk); @@ -909,7 +911,7 @@ static int dccp_v4_rcv(struct sk_buff *skb) if (dh->dccph_type !=3D DCCP_PKT_RESET) { DCCP_SKB_CB(skb)->dccpd_reset_code =3D DCCP_RESET_CODE_NO_CONNECTION; - dccp_v4_ctl_send_reset(sk, skb); + dccp_v4_ctl_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); } =20 discard_it: diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index c8ca703dc331..85f4b8fdbe5e 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -29,6 +29,7 @@ #include #include #include +#include =20 #include "dccp.h" #include "ipv6.h" @@ -256,7 +257,8 @@ static void dccp_v6_reqsk_destructor(struct request_soc= k *req) kfree_skb(inet_rsk(req)->pktopts); } =20 -static void dccp_v6_ctl_send_reset(const struct sock *sk, struct sk_buff *= rxskb) +static void dccp_v6_ctl_send_reset(const struct sock *sk, struct sk_buff *= rxskb, + enum sk_rst_reason reason) { const struct ipv6hdr *rxip6h; struct sk_buff *skb; @@ -656,7 +658,7 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_bu= ff *skb) return 0; =20 reset: - dccp_v6_ctl_send_reset(sk, skb); + dccp_v6_ctl_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); discard: if (opt_skb !=3D NULL) __kfree_skb(opt_skb); @@ -762,7 +764,7 @@ static int dccp_v6_rcv(struct sk_buff *skb) if (nsk =3D=3D sk) { reqsk_put(req); } else if (dccp_child_process(sk, nsk, skb)) { - dccp_v6_ctl_send_reset(sk, skb); + dccp_v6_ctl_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); goto discard_and_relse; } else { sock_put(sk); @@ -801,7 +803,7 @@ static int dccp_v6_rcv(struct sk_buff *skb) if (dh->dccph_type !=3D DCCP_PKT_RESET) { DCCP_SKB_CB(skb)->dccpd_reset_code =3D DCCP_RESET_CODE_NO_CONNECTION; - dccp_v6_ctl_send_reset(sk, skb); + dccp_v6_ctl_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); } =20 discard_it: diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index 64d805b27add..251a57cf5822 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c @@ -15,6 +15,7 @@ #include #include #include +#include =20 #include "ackvec.h" #include "ccid.h" @@ -202,7 +203,7 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_= buff *skb, DCCP_SKB_CB(skb)->dccpd_reset_code =3D DCCP_RESET_CODE_TOO_BUSY; drop: if (dccp_hdr(skb)->dccph_type !=3D DCCP_PKT_RESET) - req->rsk_ops->send_reset(sk, skb); + req->rsk_ops->send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); =20 inet_csk_reqsk_queue_drop(sk, req); out: diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 88c83ac42129..418d11902fa7 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -70,6 +70,7 @@ #include #include #include +#include =20 #include #include @@ -723,7 +724,8 @@ static bool tcp_v4_ao_sign_reset(const struct sock *sk,= struct sk_buff *skb, * Exception: precedence violation. We do not implement it in any case. */ =20 -static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb) +static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb, + enum sk_rst_reason reason) { const struct tcphdr *th =3D tcp_hdr(skb); struct { @@ -1934,7 +1936,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *sk= b) return 0; =20 reset: - tcp_v4_send_reset(rsk, skb); + tcp_v4_send_reset(rsk, skb, SK_RST_REASON_NOT_SPECIFIED); discard: kfree_skb_reason(skb, reason); /* Be careful here. If this function gets more complicated and @@ -2276,7 +2278,7 @@ int tcp_v4_rcv(struct sk_buff *skb) } else { drop_reason =3D tcp_child_process(sk, nsk, skb); if (drop_reason) { - tcp_v4_send_reset(nsk, skb); + tcp_v4_send_reset(nsk, skb, SK_RST_REASON_NOT_SPECIFIED); goto discard_and_relse; } sock_put(sk); @@ -2355,7 +2357,7 @@ int tcp_v4_rcv(struct sk_buff *skb) bad_packet: __TCP_INC_STATS(net, TCP_MIB_INERRS); } else { - tcp_v4_send_reset(NULL, skb); + tcp_v4_send_reset(NULL, skb, SK_RST_REASON_NOT_SPECIFIED); } =20 discard_it: @@ -2407,7 +2409,7 @@ int tcp_v4_rcv(struct sk_buff *skb) tcp_v4_timewait_ack(sk, skb); break; case TCP_TW_RST: - tcp_v4_send_reset(sk, skb); + tcp_v4_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); inet_twsk_deschedule_put(inet_twsk(sk)); goto discard_it; case TCP_TW_SUCCESS:; diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index f53c7ada2ace..0bc19aca2759 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -22,6 +22,7 @@ #include #include #include +#include =20 static bool tcp_in_window(u32 seq, u32 end_seq, u32 s_win, u32 e_win) { @@ -879,7 +880,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_b= uff *skb, * avoid becoming vulnerable to outside attack aiming at * resetting legit local connections. */ - req->rsk_ops->send_reset(sk, skb); + req->rsk_ops->send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); } else if (fastopen) { /* received a valid RST pkt */ reqsk_fastopen_remove(sk, req, true); tcp_reset(sk, skb); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index bb7c3caf4f85..017f6293b5f4 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -60,6 +60,7 @@ #include #include #include +#include =20 #include #include @@ -69,7 +70,8 @@ =20 #include =20 -static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb); +static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb, + enum sk_rst_reason reason); static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *s= kb, struct request_sock *req); =20 @@ -1008,7 +1010,8 @@ static void tcp_v6_send_response(const struct sock *s= k, struct sk_buff *skb, u32 kfree_skb(buff); } =20 -static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb) +static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb, + enum sk_rst_reason reason) { const struct tcphdr *th =3D tcp_hdr(skb); struct ipv6hdr *ipv6h =3D ipv6_hdr(skb); @@ -1677,7 +1680,7 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *sk= b) return 0; =20 reset: - tcp_v6_send_reset(sk, skb); + tcp_v6_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); discard: if (opt_skb) __kfree_skb(opt_skb); @@ -1862,7 +1865,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff= *skb) } else { drop_reason =3D tcp_child_process(sk, nsk, skb); if (drop_reason) { - tcp_v6_send_reset(nsk, skb); + tcp_v6_send_reset(nsk, skb, SK_RST_REASON_NOT_SPECIFIED); goto discard_and_relse; } sock_put(sk); @@ -1939,7 +1942,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff= *skb) bad_packet: __TCP_INC_STATS(net, TCP_MIB_INERRS); } else { - tcp_v6_send_reset(NULL, skb); + tcp_v6_send_reset(NULL, skb, SK_RST_REASON_NOT_SPECIFIED); } =20 discard_it: @@ -1995,7 +1998,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff= *skb) tcp_v6_timewait_ack(sk, skb); break; case TCP_TW_RST: - tcp_v6_send_reset(sk, skb); + tcp_v6_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); inet_twsk_deschedule_put(inet_twsk(sk)); goto discard_it; case TCP_TW_SUCCESS: diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index b94d1dca1094..32fe2ef36d56 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -20,6 +20,8 @@ #include #endif #include +#include + #include "protocol.h" #include "mib.h" =20 @@ -308,7 +310,7 @@ static struct dst_entry *subflow_v4_route_req(const str= uct sock *sk, =20 dst_release(dst); if (!req->syncookie) - tcp_request_sock_ops.send_reset(sk, skb); + tcp_request_sock_ops.send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); return NULL; } =20 @@ -376,7 +378,7 @@ static struct dst_entry *subflow_v6_route_req(const str= uct sock *sk, =20 dst_release(dst); if (!req->syncookie) - tcp6_request_sock_ops.send_reset(sk, skb); + tcp6_request_sock_ops.send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); return NULL; } #endif @@ -911,7 +913,7 @@ static struct sock *subflow_syn_recv_sock(const struct = sock *sk, tcp_rsk(req)->drop_req =3D true; inet_csk_prepare_for_destroy_sock(child); tcp_done(child); - req->rsk_ops->send_reset(sk, skb); + req->rsk_ops->send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); =20 /* The last child reference will be released by the caller */ return child; --=20 2.37.3 From nobody Sat May 18 19:24:32 2024 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (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 1289E12A16B for ; Tue, 16 Apr 2024 11:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267632; cv=none; b=MSwJG9FbfxREXiAF2fc8TPpK00rJPweReqT3mHujJWSJ89l0bnx8Q/z5yhuf0t88fgcba6tCo5Zm6lE4WU/+W3nNS6eiBF+WCooI4KuRHIdCnL28Tr7svxR4sQRyrzJ5Qdi4Q18Op6KTR089S5++dxOJYx1tmBSXSVj8GyO3YUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267632; c=relaxed/simple; bh=UQ8OKu/6XO1gzteA1wAsmRbCyz+zioVQYep7p/MIbLM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FGbXtXXmZnQiOwE8f1tRVcdT6fPFeuwB1FTH0ZWipCs4u4o+6qfqKtQVodvyotIH2SP4CzgFrmYMPS4RQ/MFMXi4NqtApsSfegZV3B2YJXEroB4axalAbQ9Mlrz+nXB2JL9Vunui+H4RbNdYyLaDp0tji/9GN5Oln+xsFiLNFDY= 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=VdgDD73K; arc=none smtp.client-ip=209.85.160.41 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="VdgDD73K" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-2351c03438cso221873fac.2 for ; Tue, 16 Apr 2024 04:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713267630; x=1713872430; darn=lists.linux.dev; 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=OLE5sB7nZh8FDwAJ64hDtj2qNR1n4lihjWtB4CW/Oiw=; b=VdgDD73Kcmmv9DWTAEXKrAJOQ+67Owu+Pb257hsWNjcxR4IRp76dosRmAWCp6zkmkb LSUQZdf6G3cymZlcugfbpq8S3A4p06mLjEreOlZNyR6lRNWviY66QBrynA6WLiPFdZGY d6R5DJeeYa2ClLlFhtNeLuz4QScFDxtt+bs7dOnneXQhUoWSR9wCiLdcXCOMf7Fv02OE g99eC27dU89bA8g/gmQl6VUCBemJydMCh9yzBltnfeM+EvRgpCjsexXahluuMi9vkeon IowscKZxnYzMiwHnYJ08nUb0uz8eBT/QSb5+h79e3jBFcpiRUJbL0YTmH8GzMJRyNOW6 OT+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713267630; x=1713872430; 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=OLE5sB7nZh8FDwAJ64hDtj2qNR1n4lihjWtB4CW/Oiw=; b=PSIhqs+q5atRIwN8e/9h5cSd295kk5BJ3iqkpFmo8y51gwGJvSritXZVZhJVvtrG/s zSYkA3TZIxT1I1hZTXM73qDwB5dcEY2yheUT4p3oitep0quCsUt+U1tg/j+8tUYve/iT I02O5HPoJKHQNVckq2nnETsJCc1be5AAtjhTPLKpLbgxS1BF2+QfbefjWIGJEUCQz9BP wquLuH/ZjW7sBkw2Xu2P2xQ2HPN1QJKSPJItQDl8sEROti9OTFJ8M9YK1vOaVksmI7IN nTLSCclbOZIq5AgOG31dYu7Nf1PSfxLAUYp/2RlLfqrus5ZOgPd0bx7aXivcCRuDyaiW WoeA== X-Gm-Message-State: AOJu0YyCs+g8DXniwrAFlJX5l/jFsCl/XHgHk6jeRQG7BcEvX0iCZNEq 9Ncm4yTq/4sboyJc00TRaBiYwZgQuugJ8Y4QER3GQ/QWdF6o72Ec X-Google-Smtp-Source: AGHT+IF8f1hedEYzgKnIzJLEf05JE1ZfB11qpMzmZ2ALmR5m2KQBEvmCEmaxO1n+It4VNfT0L1LpqA== X-Received: by 2002:a05:6870:ac26:b0:22e:e46f:57e3 with SMTP id kw38-20020a056870ac2600b0022ee46f57e3mr13439076oab.35.1713267630129; Tue, 16 Apr 2024 04:40:30 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id a21-20020aa78655000000b006e6c16179dbsm8862045pfo.24.2024.04.16.04.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 04:40:29 -0700 (PDT) From: Jason Xing To: edumazet@google.com, dsahern@kernel.org, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, atenart@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v5 3/7] rstreason: prepare for active reset Date: Tue, 16 Apr 2024 19:39:59 +0800 Message-Id: <20240416114003.62110-4-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416114003.62110-1-kerneljasonxing@gmail.com> References: <20240416114003.62110-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing Like what we did to passive reset: only passing possible reset reason in each active reset path. No functional changes. Signed-off-by: Jason Xing --- include/net/tcp.h | 3 ++- net/ipv4/tcp.c | 15 ++++++++++----- net/ipv4/tcp_output.c | 3 ++- net/ipv4/tcp_timer.c | 9 ++++++--- net/mptcp/protocol.c | 4 +++- net/mptcp/subflow.c | 5 +++-- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index b935e1ae4caf..adeacc9aa28a 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -670,7 +670,8 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_qu= eue, void tcp_send_probe0(struct sock *); int tcp_write_wakeup(struct sock *, int mib); void tcp_send_fin(struct sock *sk); -void tcp_send_active_reset(struct sock *sk, gfp_t priority); +void tcp_send_active_reset(struct sock *sk, gfp_t priority, + enum sk_rst_reason reason); int tcp_send_synack(struct sock *); void tcp_push_one(struct sock *, unsigned int mss_now); void __tcp_send_ack(struct sock *sk, u32 rcv_nxt); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index f23b97777ea5..4ec0f4feee00 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -275,6 +275,7 @@ #include #include #include +#include =20 #include #include @@ -2811,7 +2812,8 @@ void __tcp_close(struct sock *sk, long timeout) /* Unread data was tossed, zap the connection. */ NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONCLOSE); tcp_set_state(sk, TCP_CLOSE); - tcp_send_active_reset(sk, sk->sk_allocation); + tcp_send_active_reset(sk, sk->sk_allocation, + SK_RST_REASON_NOT_SPECIFIED); } else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) { /* Check zero linger _after_ checking for unread data. */ sk->sk_prot->disconnect(sk, 0); @@ -2885,7 +2887,8 @@ void __tcp_close(struct sock *sk, long timeout) struct tcp_sock *tp =3D tcp_sk(sk); if (READ_ONCE(tp->linger2) < 0) { tcp_set_state(sk, TCP_CLOSE); - tcp_send_active_reset(sk, GFP_ATOMIC); + tcp_send_active_reset(sk, GFP_ATOMIC, + SK_RST_REASON_NOT_SPECIFIED); __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONLINGER); } else { @@ -2903,7 +2906,8 @@ void __tcp_close(struct sock *sk, long timeout) if (sk->sk_state !=3D TCP_CLOSE) { if (tcp_check_oom(sk, 0)) { tcp_set_state(sk, TCP_CLOSE); - tcp_send_active_reset(sk, GFP_ATOMIC); + tcp_send_active_reset(sk, GFP_ATOMIC, + SK_RST_REASON_NOT_SPECIFIED); __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY); } else if (!check_net(sock_net(sk))) { @@ -3007,7 +3011,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()); + tcp_send_active_reset(sk, gfp_any(), SK_RST_REASON_NOT_SPECIFIED); WRITE_ONCE(sk->sk_err, ECONNRESET); } else if (old_state =3D=3D TCP_SYN_SENT) WRITE_ONCE(sk->sk_err, ECONNRESET); @@ -4564,7 +4568,8 @@ int tcp_abort(struct sock *sk, int err) smp_wmb(); sk_error_report(sk); if (tcp_need_reset(sk->sk_state)) - tcp_send_active_reset(sk, GFP_ATOMIC); + tcp_send_active_reset(sk, GFP_ATOMIC, + SK_RST_REASON_NOT_SPECIFIED); tcp_done(sk); } =20 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 61119d42b0fd..276d9d541b01 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3586,7 +3586,8 @@ void tcp_send_fin(struct sock *sk) * was unread data in the receive queue. This behavior is recommended * by RFC 2525, section 2.17. -DaveM */ -void tcp_send_active_reset(struct sock *sk, gfp_t priority) +void tcp_send_active_reset(struct sock *sk, gfp_t priority, + enum sk_rst_reason reason) { struct sk_buff *skb; =20 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 976db57b95d4..83fe7f62f7f1 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -22,6 +22,7 @@ #include #include #include +#include =20 static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk) { @@ -127,7 +128,8 @@ static int tcp_out_of_resources(struct sock *sk, bool d= o_reset) (!tp->snd_wnd && !tp->packets_out)) do_reset =3D true; if (do_reset) - tcp_send_active_reset(sk, GFP_ATOMIC); + tcp_send_active_reset(sk, GFP_ATOMIC, + SK_RST_REASON_NOT_SPECIFIED); tcp_done(sk); __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY); return 1; @@ -768,7 +770,7 @@ static void tcp_keepalive_timer (struct timer_list *t) goto out; } } - tcp_send_active_reset(sk, GFP_ATOMIC); + tcp_send_active_reset(sk, GFP_ATOMIC, SK_RST_REASON_NOT_SPECIFIED); goto death; } =20 @@ -795,7 +797,8 @@ static void tcp_keepalive_timer (struct timer_list *t) icsk->icsk_probes_out > 0) || (user_timeout =3D=3D 0 && icsk->icsk_probes_out >=3D keepalive_probes(tp))) { - tcp_send_active_reset(sk, GFP_ATOMIC); + tcp_send_active_reset(sk, GFP_ATOMIC, + SK_RST_REASON_NOT_SPECIFIED); tcp_write_err(sk); goto out; } diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f8bc34f0d973..065967086492 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -21,6 +21,7 @@ #endif #include #include +#include #include #include "protocol.h" #include "mib.h" @@ -2569,7 +2570,8 @@ static void mptcp_check_fastclose(struct mptcp_sock *= msk) =20 slow =3D lock_sock_fast(tcp_sk); if (tcp_sk->sk_state !=3D TCP_CLOSE) { - tcp_send_active_reset(tcp_sk, GFP_ATOMIC); + tcp_send_active_reset(tcp_sk, GFP_ATOMIC, + SK_RST_REASON_NOT_SPECIFIED); tcp_set_state(tcp_sk, TCP_CLOSE); } unlock_sock_fast(tcp_sk, slow); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 32fe2ef36d56..ac867d277860 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -414,7 +414,7 @@ void mptcp_subflow_reset(struct sock *ssk) /* must hold: tcp_done() could drop last reference on parent */ sock_hold(sk); =20 - tcp_send_active_reset(ssk, GFP_ATOMIC); + tcp_send_active_reset(ssk, GFP_ATOMIC, SK_RST_REASON_NOT_SPECIFIED); tcp_done(ssk); if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags)) mptcp_schedule_work(sk); @@ -1350,7 +1350,8 @@ static bool subflow_check_data_avail(struct sock *ssk) tcp_set_state(ssk, TCP_CLOSE); while ((skb =3D skb_peek(&ssk->sk_receive_queue))) sk_eat_skb(ssk, skb); - tcp_send_active_reset(ssk, GFP_ATOMIC); + tcp_send_active_reset(ssk, GFP_ATOMIC, + SK_RST_REASON_NOT_SPECIFIED); WRITE_ONCE(subflow->data_avail, false); return false; } --=20 2.37.3 From nobody Sat May 18 19:24:32 2024 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 D439712A15A for ; Tue, 16 Apr 2024 11:40:34 +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=1713267636; cv=none; b=gR9JUYV0XqkmBPlfHeo8uad/jWHMFskH2HP65GP96tbnsbP9JMYMjhLRm2Mp3A545DwqYXutm1Bk+ahJ0L2sHa/q3d2nRmlhWGGI+cVPf4xSYfLYcg5kNMqOfUAbfiS7sZ8qs9wWxf3TbqTIg8tAhOZ+cQ0Q7Q7BMRJ+yxDTugE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267636; c=relaxed/simple; bh=If0ixVmS4jqLthHAQJrwikLdIGrKYKIcGDEuRLNduYY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JSoic1BJyGyetinjtmXxiyt02WxTu2O7vua7AkVH9JswvZdUz7+kTDOMrNS4RaXCb1BFyTKizL89IVlFRw60oRNjuCzZh5kxVAmZtKJLdeSvQQ4id/ia2CKGxTvl8fjuQcVXulmWX/5E2fNLrmpJzebQMe8mQ0z82NhhXRx2QAM= 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=PCVV6nUb; 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="PCVV6nUb" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6ecf05fd12fso4043683b3a.2 for ; Tue, 16 Apr 2024 04:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713267634; x=1713872434; darn=lists.linux.dev; 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=gI624BRC7VHIXXWrjtPFW+9g8fWkyjzMnN2FP5J+sk4=; b=PCVV6nUb+Kt2aTO5M7dUuTX34EwChVVYvCP4wPbJ1+An9/oT1E9tdCTzeeY6Jmo8MC rAlNi6nDM3sKqJ4yXhF+8GHJsLMIA5czwQrLHExBIfspWAJ7e/3J6ULSwTFxdWn3YJRp wUf4UyBk1BN04maAeffmzlpQrLY5XozeoaYOalC0veD5NR6m5u9bJ2err6xpQrmzeEu/ f7/jk7Pan4MgZ4UIE1Njw935l95zyGeOy16e4CgTOpyR9j4m1MdxH7FbkCClaQEtu86b OhXH2aAhtQvppkB1hJDG4QzrIUCZx/e4+hylHnnE3ed8qOOcwgotc4OSHniP6tbQLbnF m4WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713267634; x=1713872434; 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=gI624BRC7VHIXXWrjtPFW+9g8fWkyjzMnN2FP5J+sk4=; b=K1Rmhas3pLWustH7Mt8ErXZMBBMAqO9A8MQ1KUMAhGHfFL46Jq44p77VDsUXV+5xRU 3FZeoTmzxl8T1UVfi9nBtEwpdB9r3QWigm4RLTea3Efy9akmEL0vP1MTatO5MTlnS5S/ ciNF+2LTdLoRCyhET2dmQooJG+6H0TCEEnj0ePHOpIFAfdU/GLA4Lj5s+DKRrLEjpMNC E/yzgW4LKcwlGQ7iiUpPLMPMlhuTmwCdHXJttE21uZPEp9dWm0QuwhZkWC+xYkcvsKZL NPixFSx6fWwal2GczNPuJfImVtW8g4r5guObIhBlAvmPG5+IBVof+80rTQbagWN4/Mpr BRNQ== X-Gm-Message-State: AOJu0Ywv+ulCzMa+HLhpET9XkYlA0g5QucV8hmwo/FeSjHmnPNVLG+pP H3D1yKWQ1IW+MrvsIN9nkB/MwuD6apyDyrgGbCsKP/jOhrZ/zqQx X-Google-Smtp-Source: AGHT+IE2dwFcOV4zY/B5HFLQFhG6u6XzpPjpMTRt7YIs6qY8/aqhPsmxMGSKrRc9cMCv6yg1WzDMeg== X-Received: by 2002:a05:6a00:2312:b0:6ea:74d4:a01c with SMTP id h18-20020a056a00231200b006ea74d4a01cmr15362591pfh.14.1713267634216; Tue, 16 Apr 2024 04:40:34 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id a21-20020aa78655000000b006e6c16179dbsm8862045pfo.24.2024.04.16.04.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 04:40:33 -0700 (PDT) From: Jason Xing To: edumazet@google.com, dsahern@kernel.org, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, atenart@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v5 4/7] tcp: support rstreason for passive reset Date: Tue, 16 Apr 2024 19:40:00 +0800 Message-Id: <20240416114003.62110-5-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416114003.62110-1-kerneljasonxing@gmail.com> References: <20240416114003.62110-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing Reuse the dropreason logic to show the exact reason of tcp reset, so we don't need to implement those duplicated reset reasons. This patch replaces all the prior NOT_SPECIFIED reasons. Signed-off-by: Jason Xing --- net/ipv4/tcp_ipv4.c | 8 ++++---- net/ipv6/tcp_ipv6.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 418d11902fa7..474f7525189a 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1936,7 +1936,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *sk= b) return 0; =20 reset: - tcp_v4_send_reset(rsk, skb, SK_RST_REASON_NOT_SPECIFIED); + tcp_v4_send_reset(rsk, skb, reason); discard: kfree_skb_reason(skb, reason); /* Be careful here. If this function gets more complicated and @@ -2278,7 +2278,7 @@ int tcp_v4_rcv(struct sk_buff *skb) } else { drop_reason =3D tcp_child_process(sk, nsk, skb); if (drop_reason) { - tcp_v4_send_reset(nsk, skb, SK_RST_REASON_NOT_SPECIFIED); + tcp_v4_send_reset(nsk, skb, drop_reason); goto discard_and_relse; } sock_put(sk); @@ -2357,7 +2357,7 @@ int tcp_v4_rcv(struct sk_buff *skb) bad_packet: __TCP_INC_STATS(net, TCP_MIB_INERRS); } else { - tcp_v4_send_reset(NULL, skb, SK_RST_REASON_NOT_SPECIFIED); + tcp_v4_send_reset(NULL, skb, drop_reason); } =20 discard_it: @@ -2409,7 +2409,7 @@ int tcp_v4_rcv(struct sk_buff *skb) tcp_v4_timewait_ack(sk, skb); break; case TCP_TW_RST: - tcp_v4_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); + tcp_v4_send_reset(sk, skb, drop_reason); inet_twsk_deschedule_put(inet_twsk(sk)); goto discard_it; case TCP_TW_SUCCESS:; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 017f6293b5f4..e0b90049e3c5 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1680,7 +1680,7 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *sk= b) return 0; =20 reset: - tcp_v6_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); + tcp_v6_send_reset(sk, skb, reason); discard: if (opt_skb) __kfree_skb(opt_skb); @@ -1865,7 +1865,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff= *skb) } else { drop_reason =3D tcp_child_process(sk, nsk, skb); if (drop_reason) { - tcp_v6_send_reset(nsk, skb, SK_RST_REASON_NOT_SPECIFIED); + tcp_v6_send_reset(nsk, skb, drop_reason); goto discard_and_relse; } sock_put(sk); @@ -1942,7 +1942,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff= *skb) bad_packet: __TCP_INC_STATS(net, TCP_MIB_INERRS); } else { - tcp_v6_send_reset(NULL, skb, SK_RST_REASON_NOT_SPECIFIED); + tcp_v6_send_reset(NULL, skb, drop_reason); } =20 discard_it: @@ -1998,7 +1998,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff= *skb) tcp_v6_timewait_ack(sk, skb); break; case TCP_TW_RST: - tcp_v6_send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); + tcp_v6_send_reset(sk, skb, drop_reason); inet_twsk_deschedule_put(inet_twsk(sk)); goto discard_it; case TCP_TW_SUCCESS: --=20 2.37.3 From nobody Sat May 18 19:24:32 2024 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 D1078129A70 for ; Tue, 16 Apr 2024 11:40:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267640; cv=none; b=I25zT8nuxK9/E4tSA4Gri6F3krLYUfmmyU4W31ISBTj6baA5EmsQyarqlJFQNExHwb11h5iSjpQ+HLeCf6lbeLko5ttXXt7zLQBRzG/3/hqx5dJAMIcNVFF4jUV3MFTKagPkdWfuVjs+ZUA4CeFy9ADO+LsOaz92UjqIopx6Yso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267640; c=relaxed/simple; bh=0VTQYJ78QzBxqF81nvpNqVGCLyn+HEz3ONaeMbi9mG0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b3UBJIdPNLbzE5HRxFQfPxTJbQz/8ZS1SA2QqwiB72wuNTD7ET7dyaUaKb84RFXOvyMMjlzxLWokeGVAeuFqgALc/naeFnfm8+3jXYryuhO/9iFnMhWgnYV3Mnf5lQzQH5nV61MG124OSEaW7za5mfWudL4OCFD7H+i6Dk9aIOA= 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=ngyoiLn2; arc=none smtp.client-ip=209.85.210.174 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="ngyoiLn2" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6ecee1f325bso3936141b3a.2 for ; Tue, 16 Apr 2024 04:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713267638; x=1713872438; darn=lists.linux.dev; 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=Nk1xbizv/3iUHnTNC2vK0HjYyLpTvBev3i1Kew13jY0=; b=ngyoiLn2JzwSHxcEDifXXdRIrJx3PUTAf9eKPYz9l2MACuFeV2udIccKK0+IxQ6GnO M2fpRa+k+HBqJr+PTrqqNFQaEzmio/CVu/ZOIkt2wZg9DbQt5edYYK+DoJgmFEzjys7R owAsISsvfIrnrQaoDa3KFMfJ3lqNJQ/uDrU/4gQXMdsUfYddI2OdFtvdB0fnZM+MVe2s CxUIybkKQbNyTtoRFDT/ouWNOBnxwYWHkkzfWgrXAy+DYvK6PAFGLSeARo8TdIoEi9YT F8Nv+ERxeWX3qh3PAGORyWK/uyWQjK3cb6ka3crR+osrEMZZ6o1jI3gvoCbGpUzYRm/7 9p4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713267638; x=1713872438; 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=Nk1xbizv/3iUHnTNC2vK0HjYyLpTvBev3i1Kew13jY0=; b=vr8nfIdWlMW3L4vm3gdZ4ManCGuInqgyyQ1YqLoB6/sTpL3yvNqgIi3eKBM+WAvuth fTVGtXeDS2/NSRG/IWs+QfVdHF1nfRM/8JXt9rFAqDNitHjxvL6LKacuV7Wn9qWGmeCb 4Ub/xPRChIIO8RxbZF+E16c2j1cRsADjeXCl4QfmsiN+zS/yBKdDBPX9kRhf+ilYu0Ti mpuKTm/ic7ZOk+bi7xflKX7EUxbO/W2ydqWm8nbmL8Ejv5TkwQndWXirPQq3pjFG/SR1 77p+z2riGKlWnmUMSAbWGHhqUPiUIhqdN+3JPXOcqJ8Er4QCusAFvg5Tpyv90h5M07Vf sCzg== X-Gm-Message-State: AOJu0YzkgczlbCHaNW9aW7gFpMf2KOOqbE1KWSWQBSitkoJOK2Q8KQeh ZsIaAWP8HY1eYmf5nJUVcdfm5Byw1+TiRn7ixsHepauzxW1+U+Fe X-Google-Smtp-Source: AGHT+IFe+4nCe+cABIheFzccWhrHioYgnYZncmu/Al9/d2IKxv2fJ/4SVd7hf79T+RJDu8mJNzEp/g== X-Received: by 2002:aa7:8888:0:b0:6ea:8b0c:584 with SMTP id z8-20020aa78888000000b006ea8b0c0584mr17359372pfe.9.1713267638254; Tue, 16 Apr 2024 04:40:38 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id a21-20020aa78655000000b006e6c16179dbsm8862045pfo.24.2024.04.16.04.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 04:40:37 -0700 (PDT) From: Jason Xing To: edumazet@google.com, dsahern@kernel.org, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, atenart@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v5 5/7] mptcp: support rstreason for passive reset Date: Tue, 16 Apr 2024 19:40:01 +0800 Message-Id: <20240416114003.62110-6-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416114003.62110-1-kerneljasonxing@gmail.com> References: <20240416114003.62110-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing It relys on what reset options in the skb are as rfc8684 says. Reusing this logic can save us much energy. This patch replaces most of the prior NOT_SPECIFIED reasons. Signed-off-by: Jason Xing --- net/mptcp/subflow.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index ac867d277860..bde4a7fdee82 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -309,8 +309,13 @@ static struct dst_entry *subflow_v4_route_req(const st= ruct sock *sk, return dst; =20 dst_release(dst); - if (!req->syncookie) - tcp_request_sock_ops.send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); + if (!req->syncookie) { + struct mptcp_ext *mpext =3D mptcp_get_ext(skb); + enum sk_rst_reason reason; + + reason =3D convert_mptcp_reason(mpext->reset_reason); + tcp_request_sock_ops.send_reset(sk, skb, reason); + } return NULL; } =20 @@ -377,8 +382,13 @@ static struct dst_entry *subflow_v6_route_req(const st= ruct sock *sk, return dst; =20 dst_release(dst); - if (!req->syncookie) - tcp6_request_sock_ops.send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); + if (!req->syncookie) { + struct mptcp_ext *mpext =3D mptcp_get_ext(skb); + enum sk_rst_reason reason; + + reason =3D convert_mptcp_reason(mpext->reset_reason); + tcp6_request_sock_ops.send_reset(sk, skb, reason); + } return NULL; } #endif @@ -783,6 +793,7 @@ static struct sock *subflow_syn_recv_sock(const struct = sock *sk, struct mptcp_subflow_request_sock *subflow_req; struct mptcp_options_received mp_opt; bool fallback, fallback_is_fatal; + enum sk_rst_reason reason; struct mptcp_sock *owner; struct sock *child; =20 @@ -913,7 +924,8 @@ static struct sock *subflow_syn_recv_sock(const struct = sock *sk, tcp_rsk(req)->drop_req =3D true; inet_csk_prepare_for_destroy_sock(child); tcp_done(child); - req->rsk_ops->send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED); + reason =3D convert_mptcp_reason(mptcp_get_ext(skb)->reset_reason); + req->rsk_ops->send_reset(sk, skb, reason); =20 /* The last child reference will be released by the caller */ return child; --=20 2.37.3 From nobody Sat May 18 19:24:32 2024 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 5473B129E8E for ; Tue, 16 Apr 2024 11:40:43 +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=1713267644; cv=none; b=riWA8PkybUg4y9pHCOtI2M8Z9q6tgOzNc0PoX1vvINuWBiFbELWe+PzNW1wGBLIVJE2ruD2chXR4RoDGgNepdBKFgpWEc3QvVFfeGvgo3+gqh2t1692CL0PUx8tl1ehtVj7xGUYMB86B+X8uA8PcuOOW9C98Yf3tpqmO2+1LOiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267644; c=relaxed/simple; bh=9+NXcmGwyt344ac+65+IFERA0aeIWelc23La2k0MJFY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U1fZEBxbypRsjytg808UKgWHj2HSWH3KWTyDtp1AAdZLUMG2ZLVRDogBeaneqp3h2stuSDfgjekMFSIRRlqGXeAKTf2r5eIcCxt0ofK70pOyZnpkHkb9zHWG8Rck5W/GzOmVMTriECUiJvhCzTbIWZvmBh4hqPnlb8AB08eoOps= 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=DtTBpWoO; 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="DtTBpWoO" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6ed9fc77bbfso3306397b3a.1 for ; Tue, 16 Apr 2024 04:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713267642; x=1713872442; darn=lists.linux.dev; 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=UXPsQyON3TFtDQR7bYganuNlYsXI10vIvS6F+4BgaXc=; b=DtTBpWoO7RVyUt86dSa3yA6w5NK4urdLLlG+PLwKCb/4u3NeIdum19qElSTygW5FY0 6HQhr1uLXAgZ4o74WgXw1z492wUpeMQ5c9bo/GeKDUuPEl56nTW3tRskN/kRSZfD6GhS DX+fxtpYMKvfMvz3uBhOc3tNPaNpQ4ra32ZA6qpUN2iHtUAdbeEQbbKCe4DHAJXc3M7b c0LPxogPX7WBwK2CUnciBOpEroM82zNzQPQC1FtzcpGQMk+J+YXFvLdNjkjJagsn5Vxd xppO3DFb1EnRNY4PcxfNM7PZhydSII3nwIaSbBIyKanbtN11cTAGMt9Wm+2UxYM1AShR hhvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713267642; x=1713872442; 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=UXPsQyON3TFtDQR7bYganuNlYsXI10vIvS6F+4BgaXc=; b=Hic6+skmlIa/PA8tVNeUzBS2Kh2uXg4bqZmPURcDdR49JHMmfAdhM5gQLJwUAtzx4s i1X9UOmNTp4d0xM1I10vjfqtnjS1P8jyoC9m75otvPcuoZJKjE6AFc7zR07KSqMdP8e/ 0WPhzg5rJhlN3U9UWp74YHljbvYj7g5Nr73lwL+JX8CTOviAcgb/8n+TwMTrVe1BBjHW hmVS0ANQ2c2at+ny3H6tqpQfL4Hquv2osjbchKP1aS+v7cZMp1GrOXeTLZ0yPthP4gkN Z5KM/1c3YQGLsl4XIL5WQog25d5qlNFduJbRUxWgqYDXM6rFcD51szhe7fl4EjQXWxM1 QNcg== X-Gm-Message-State: AOJu0Yw1fWosUZJBDLt0lKjAQAR4n6hfIsiyHYYn5D5ZdXJZKm+kB2AM ztFPD8nVvgpNJAkZcy6fApdLdITaGEfgqt+OPcxzKhqIaaEOH1go X-Google-Smtp-Source: AGHT+IEm5A6jT+QGQHERvvGqADXMfEefRQUAVhU84i4vmIlcqJfSQBMWf2rQhxtQGSf4Fu0MKDeoIw== X-Received: by 2002:a05:6a20:3250:b0:1a3:8e1d:16b8 with SMTP id hm16-20020a056a20325000b001a38e1d16b8mr10410698pzc.28.1713267642554; Tue, 16 Apr 2024 04:40:42 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id a21-20020aa78655000000b006e6c16179dbsm8862045pfo.24.2024.04.16.04.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 04:40:42 -0700 (PDT) From: Jason Xing To: edumazet@google.com, dsahern@kernel.org, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, atenart@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v5 6/7] mptcp: introducing a helper into active reset logic Date: Tue, 16 Apr 2024 19:40:02 +0800 Message-Id: <20240416114003.62110-7-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416114003.62110-1-kerneljasonxing@gmail.com> References: <20240416114003.62110-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing Since we have mapped every mptcp reset reason definition in enum sk_rst_reason, introducing a new helper can cover some missing places where we have already set the subflow->reset_reason. Note: using SK_RST_REASON_NOT_SPECIFIED is the same as SK_RST_REASON_MPTCP_RST_EUNSPEC. They are both unknown. So we can convert it directly. Suggested-by: Paolo Abeni Signed-off-by: Jason Xing --- Link: https://lore.kernel.org/all/2d3ea199eef53cf6a0c48e21abdee0eefbdee927.= camel@redhat.com/ --- net/mptcp/protocol.c | 4 +--- net/mptcp/protocol.h | 11 +++++++++++ net/mptcp/subflow.c | 6 ++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 065967086492..4b13ca362efa 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -21,7 +21,6 @@ #endif #include #include -#include #include #include "protocol.h" #include "mib.h" @@ -2570,8 +2569,7 @@ static void mptcp_check_fastclose(struct mptcp_sock *= msk) =20 slow =3D lock_sock_fast(tcp_sk); if (tcp_sk->sk_state !=3D TCP_CLOSE) { - tcp_send_active_reset(tcp_sk, GFP_ATOMIC, - SK_RST_REASON_NOT_SPECIFIED); + mptcp_send_active_reset_reason(tcp_sk); tcp_set_state(tcp_sk, TCP_CLOSE); } unlock_sock_fast(tcp_sk, slow); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index fdfa843e2d88..82ef2f42a1bc 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -12,6 +12,7 @@ #include #include #include +#include =20 #include "mptcp_pm_gen.h" =20 @@ -581,6 +582,16 @@ mptcp_subflow_ctx_reset(struct mptcp_subflow_context *= subflow) WRITE_ONCE(subflow->local_id, -1); } =20 +static inline void +mptcp_send_active_reset_reason(struct sock *sk) +{ + struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(sk); + enum sk_rst_reason reason; + + reason =3D convert_mptcp_reason(subflow->reset_reason); + tcp_send_active_reset(sk, GFP_ATOMIC, reason); +} + static inline u64 mptcp_subflow_get_map_offset(const struct mptcp_subflow_context *subflow) { diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index bde4a7fdee82..4783d558863c 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -20,7 +20,6 @@ #include #endif #include -#include =20 #include "protocol.h" #include "mib.h" @@ -424,7 +423,7 @@ void mptcp_subflow_reset(struct sock *ssk) /* must hold: tcp_done() could drop last reference on parent */ sock_hold(sk); =20 - tcp_send_active_reset(ssk, GFP_ATOMIC, SK_RST_REASON_NOT_SPECIFIED); + mptcp_send_active_reset_reason(ssk); tcp_done(ssk); if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags)) mptcp_schedule_work(sk); @@ -1362,8 +1361,7 @@ static bool subflow_check_data_avail(struct sock *ssk) tcp_set_state(ssk, TCP_CLOSE); while ((skb =3D skb_peek(&ssk->sk_receive_queue))) sk_eat_skb(ssk, skb); - tcp_send_active_reset(ssk, GFP_ATOMIC, - SK_RST_REASON_NOT_SPECIFIED); + mptcp_send_active_reset_reason(ssk); WRITE_ONCE(subflow->data_avail, false); return false; } --=20 2.37.3 From nobody Sat May 18 19:24:32 2024 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 E3B0F12A166 for ; Tue, 16 Apr 2024 11:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267649; cv=none; b=U/jPppDYpy0WYXJ+N/ZcGGMSGFyVQ/6i127fB5syt3wgMO1PA1BtDGbT48MlX8mKy1xpYvbAwjH885s3kvStZjBskMiD3FTncY0ZmagWBdn4P0QupIbkoInx1yEqtcdG3AOq+uyIFlh/7N1wstK8mj72gLtb0wNX4IPIpiAQ78o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713267649; c=relaxed/simple; bh=TpPs/G5lSMfwUSyl5wVFAr0dgNU4d3+Y0STOnkHAmzs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xmuo/vEAewkdz/NfsP2dMpZKK5Ul7VCGIFcsCeG3fm6ZqOIoKh3rKS0BnxZgm+qGn76RaKM6Y2lNP/fQaKPRDxqv4h2uCOcKRixN1KUdm7h4KDvNyLaOci2rc1oT3b9ycxxBkiJ53W+twCdoT4FuySny6c+otVb9b5SRz1vL55c= 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=ViUJyEt/; arc=none smtp.client-ip=209.85.210.178 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="ViUJyEt/" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6ed112c64beso3408846b3a.1 for ; Tue, 16 Apr 2024 04:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713267647; x=1713872447; darn=lists.linux.dev; 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=cgIm2mCCIOR76GdPrzThP7+upXmF5LtBKCvY2pmuYuc=; b=ViUJyEt/N0Wq5YW8EBorom/sKOSlWKJ0mhfHVNByH9cr1SubpSIZgF4qA/b87UpIt9 HTNk1/JtNUPaq9DvYBpbiTsj1K1Hl5ooWI7oKLjZYxGcZNQk63lAg5WJv19qmbVXaRTo 0Af1B+v1Fn8DaLf4Z+iUrLJkG8NTINfJxT7CN2WaggbD2wGKSz0EdKG5XUDmLVHzZgjV IPXdFIaWM46Q/Xyl6s+UkvRGB4SmIeHMgZlDtrfy7LTiqQ5bRWIT6JFMlObZBzKNhePJ 2leBEHusG3cfLr1RGThr0oBoJ72RaS9jL6+RQgsXgMqeVkVQ4fwl7VCm010oMjL5YSDG 6eHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713267647; x=1713872447; 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=cgIm2mCCIOR76GdPrzThP7+upXmF5LtBKCvY2pmuYuc=; b=wz9IuHByN2i738UpLv19pvay+6YN2yIrDx7+9ktO4e4oLTpmpQLzTJxaTz6EXct9AG Y9A2Qe+a/AVfhb9943Jfue8X+ptAS4yiyE6rWgCcDWEIMtm7gOR+0uts2DpTbacC0VNn mrd1Mj7ApJUEeqb7rfmarwNeJqHjRNluLEheNdSDwitBGZc9swc/VuAXeU43G+71sTXC duuOuCmSpgYX+9TxsSgEB3L1F4GUp4ZDvojxDjKtYbc9mStEKZ57H9fWJ+7cfBYy2W0T 75Pu1nxvgICOfiL1/QqRkC86RcoJaP7VqNA+MmGIVsrF4XP5Z23uilM2GD8WP7oBwVEx U9WA== X-Gm-Message-State: AOJu0YwyFhXW7ijyU16KyGOl/QPwIR1fRFi3wNt06ZwF0/roWF8MAXM3 YzpejcWpk9mTsVX++isCruyN2Ln3bNmnRgKL4ysnoG1krZsmUBf+ldmQqaFi X-Google-Smtp-Source: AGHT+IFKRtzQXx+/htpH4Umb0BxSu4jMCQWF6uBdvoxmCBLNrYeRb2UGfuMS3Rl3qeeqSmJRM14EyA== X-Received: by 2002:a05:6a00:1302:b0:6ed:63e:3525 with SMTP id j2-20020a056a00130200b006ed063e3525mr12040966pfu.31.1713267646714; Tue, 16 Apr 2024 04:40:46 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id a21-20020aa78655000000b006e6c16179dbsm8862045pfo.24.2024.04.16.04.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 04:40:46 -0700 (PDT) From: Jason Xing To: edumazet@google.com, dsahern@kernel.org, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, atenart@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v5 7/7] rstreason: make it work in trace world Date: Tue, 16 Apr 2024 19:40:03 +0800 Message-Id: <20240416114003.62110-8-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416114003.62110-1-kerneljasonxing@gmail.com> References: <20240416114003.62110-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing At last, we should let it work by introducing this reset reason in trace world. One of the possible expected outputs is: ... tcp_send_reset: skbaddr=3Dxxx skaddr=3Dxxx src=3Dxxx dest=3Dxxx state=3DTCP_ESTABLISHED reason=3DNOT_SPECIFIED Signed-off-by: Jason Xing Reviewed-by: Steven Rostedt (Google) --- include/trace/events/tcp.h | 37 +++++++++++++++++++++++++++++++++---- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/tcp_output.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h index 5c04a61a11c2..b1455cbc0634 100644 --- a/include/trace/events/tcp.h +++ b/include/trace/events/tcp.h @@ -11,6 +11,7 @@ #include #include #include +#include =20 /* * tcp event with arguments sk and skb @@ -74,20 +75,38 @@ DEFINE_EVENT(tcp_event_sk_skb, tcp_retransmit_skb, TP_ARGS(sk, skb) ); =20 +#undef FN1 +#define FN1(reason) TRACE_DEFINE_ENUM(SK_RST_REASON_##reason); +#undef FN2 +#define FN2(reason) TRACE_DEFINE_ENUM(SKB_DROP_REASON_##reason); +DEFINE_RST_REASON(FN1, FN1) + +#undef FN1 +#undef FNe1 +#define FN1(reason) { SK_RST_REASON_##reason, #reason }, +#define FNe1(reason) { SK_RST_REASON_##reason, #reason } + +#undef FN2 +#undef FNe2 +#define FN2(reason) { SKB_DROP_REASON_##reason, #reason }, +#define FNe2(reason) { SKB_DROP_REASON_##reason, #reason } /* * skb of trace_tcp_send_reset is the skb that caused RST. In case of * active reset, skb should be NULL */ TRACE_EVENT(tcp_send_reset, =20 - TP_PROTO(const struct sock *sk, const struct sk_buff *skb), + TP_PROTO(const struct sock *sk, + const struct sk_buff *skb, + const enum sk_rst_reason reason), =20 - TP_ARGS(sk, skb), + TP_ARGS(sk, skb, reason), =20 TP_STRUCT__entry( __field(const void *, skbaddr) __field(const void *, skaddr) __field(int, state) + __field(enum sk_rst_reason, reason) __array(__u8, saddr, sizeof(struct sockaddr_in6)) __array(__u8, daddr, sizeof(struct sockaddr_in6)) ), @@ -113,14 +132,24 @@ TRACE_EVENT(tcp_send_reset, */ TP_STORE_ADDR_PORTS_SKB(skb, th, entry->daddr, entry->saddr); } + __entry->reason =3D reason; ), =20 - TP_printk("skbaddr=3D%p skaddr=3D%p src=3D%pISpc dest=3D%pISpc state=3D%s= ", + TP_printk("skbaddr=3D%p skaddr=3D%p src=3D%pISpc dest=3D%pISpc state=3D%s= reason=3D%s", __entry->skbaddr, __entry->skaddr, __entry->saddr, __entry->daddr, - __entry->state ? show_tcp_state_name(__entry->state) : "UNKNOWN") + __entry->state ? show_tcp_state_name(__entry->state) : "UNKNOWN", + __entry->reason < RST_REASON_START ? + __print_symbolic(__entry->reason, DEFINE_DROP_REASON(FN2, FNe2)) : + __print_symbolic(__entry->reason, DEFINE_RST_REASON(FN1, FNe1))) ); =20 +#undef FN1 +#undef FNe1 + +#undef FN2 +#undef FNe2 + /* * tcp event with arguments sk * diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 474f7525189a..e9e95315a619 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -871,7 +871,7 @@ static void tcp_v4_send_reset(const struct sock *sk, st= ruct sk_buff *skb, if (sk) arg.bound_dev_if =3D sk->sk_bound_dev_if; =20 - trace_tcp_send_reset(sk, skb); + trace_tcp_send_reset(sk, skb, reason); =20 BUILD_BUG_ON(offsetof(struct sock, sk_bound_dev_if) !=3D offsetof(struct inet_timewait_sock, tw_bound_dev_if)); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 276d9d541b01..b08ffb17d5a0 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3612,7 +3612,7 @@ void tcp_send_active_reset(struct sock *sk, gfp_t pri= ority, /* 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); + trace_tcp_send_reset(sk, NULL, SK_RST_REASON_NOT_SPECIFIED); } =20 /* Send a crossed SYN-ACK during socket establishment. diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index e0b90049e3c5..88f7b0528ffb 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1133,7 +1133,7 @@ static void tcp_v6_send_reset(const struct sock *sk, = struct sk_buff *skb, label =3D ip6_flowlabel(ipv6h); } =20 - trace_tcp_send_reset(sk, skb); + trace_tcp_send_reset(sk, skb, reason); =20 tcp_v6_send_response(sk, skb, seq, ack_seq, 0, 0, 0, oif, 1, ipv6_get_dsfield(ipv6h), label, priority, txhash, --=20 2.37.3