From nobody Sat May 18 21:45:38 2024 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 920211BF3F for ; Thu, 25 Apr 2024 03:13:54 +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=1714014837; cv=none; b=SVBHkq5PEIWU9RQ2T1vhnZXQeTiDRpK6CkFomtnwHKN7NZvmDCFiZm2/l2mgFM0s33PB7b1Ar9qyvGYpInn/LH7XBeQiXF4rbHqw1lKPb8rPDw2K6YlZc4GfQlbvyqUKsbKJfD8gAGkwAMjQW2Qu02TDHfPqXUAXb3lunIZcMmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014837; c=relaxed/simple; bh=+LesTt3Z2LMFg+SpRs/f+1BWhpKFNiGytAfxtWegupk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dTkpurOFs5roGseRUSx202XCPkjJosEkarYJxh1GLNLPXotkmgjouL4QkhbjdMS794516nbuZ/Roznq7/M/VEmIbMieUC+hNlgb8dHdZu6cpVBuGQsw+xrt0LgIy761PYduvkjrdp/i6aH4fPO16mcsjWWDnBa+WcJTcvTe9TFU= 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=jHVG3UD0; 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="jHVG3UD0" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6ecf05fd12fso522440b3a.2 for ; Wed, 24 Apr 2024 20:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714014834; x=1714619634; 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=nYes8UrjLtTge23x1oPsqCt8zdeGWq3g5+fzgOsk/os=; b=jHVG3UD0VYp/9j0fdcJmiRLNwPkdKZ0aB4/RgT5bgUyet3cMzdcJt+znUoCAfWJX6t OWFyME6hvRf06YbEmBqEl5+3gP6maYD8cb+tz3BBoCVCX2gvjA+1Z88yN+PzEAYnFjiY 9r6eReVCyNrmNTWXq25ohzi7tLzrucknL6e2LdyT9ZCoGldFkoY/EM0sh8vOn8g1w30J pTm8Ct7P/Wl6tyTz06u6QEpbx2/FRgY7mUUVhVToKckVeBEQSahqY5F3P8hMpxkgqyi5 xXxUGvv/ws4rf+ATS9FJlkN1/lmj6xy+5dKfEtodyqvg2kLt8ZEh+T7TO4/CuwqRgwdW E2fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714014834; x=1714619634; 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=nYes8UrjLtTge23x1oPsqCt8zdeGWq3g5+fzgOsk/os=; b=jEZR7MrdM1qywAS9ViLt3Dms0UkHvz7nLpnsZko/J9DDtB2dUVYrZi/vK/gkPLUEDk izahO/ZZmRv1LJsZO3VlH3eyntRHkME5exMs4JJWAUHWYMZ+xoRX2LXJEpU2C/Dkx7k9 cQLWrgAxBhfrHq5TzZctEhhEn5spBAAuVEkZ2DKFsSxHWxru6G2Rhim/VR+bb9Lnehre 7PEI1pgRnJhY2RLRUUwCBaKEqzQr04UhxH0u83ujXJQMh9RqxVwR6/A4EBRHfkz4KIUh gPss9PFOYm4cNP5PbefFfd2ZoaY00/ANKGlGW4qRv8MKLHhZ8OIYqZ3jphtE+cMfzEvO VgfA== X-Gm-Message-State: AOJu0YzvIqsLUhOMPa0QWjg7ZQa/EgyKBjTJjzN9kT+PNTRflmbTYArS 6mQH7vUVrHZ/XZhO1R2OTMU+HQ0idgAg2oNmyF0k3Vm4vETiccpA X-Google-Smtp-Source: AGHT+IEWvJViSoVS0wr9rr1/aeg8rz7tLGFqWHjwyTo05J3Py8YBVZ0LEjHJtmkaauTpWtMGe+8o0g== X-Received: by 2002:a05:6a21:788c:b0:1a7:39a8:6ca4 with SMTP id bf12-20020a056a21788c00b001a739a86ca4mr5096219pzc.29.1714014833849; Wed, 24 Apr 2024 20:13:53 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id gm8-20020a056a00640800b006e740d23674sm12588884pfb.140.2024.04.24.20.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 20:13:53 -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, horms@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v9 1/7] net: introduce rstreason to detect why the RST is sent Date: Thu, 25 Apr 2024 11:13:34 +0800 Message-Id: <20240425031340.46946-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240425031340.46946-1-kerneljasonxing@gmail.com> References: <20240425031340.46946-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) our own independent reasons which aren't relying on other reasons at all 3) reuse MP_TCPRST option for MPTCP The benefits of a standalone reset reason are listed here: 1) it can cover more than one case, such as reset reasons in MPTCP, active reset reasons. 2) people can easily/fastly understand and maintain this mechanism. 3) we get unified format of output with prefix stripped. 4) more new reset reasons are on the way ... I will implement the basic codes of active/passive reset reason in those three protocols, which are not complete for this moment. For passive reset part in TCP, I only introduce the NO_SOCKET common case which could be set as an example. After this series applied, it will have the ability to open a new gate to let other people contribute more reasons into it :) Signed-off-by: Jason Xing Acked-by: Matthieu Baerts (NGI0) Reviewed-by: Eric Dumazet --- include/net/rstreason.h | 106 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 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..bc53b5a24505 --- /dev/null +++ b/include/net/rstreason.h @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _LINUX_RSTREASON_H +#define _LINUX_RSTREASON_H +#include +#include + +#define DEFINE_RST_REASON(FN, FNe) \ + FN(NOT_SPECIFIED) \ + FN(NO_SOCKET) \ + 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(ERROR) \ + FNe(MAX) + +/** + * enum sk_rst_reason - the reasons of socket reset + * + * The reasons of sk reset, which are used in DCCP/TCP/MPTCP protocols. + * + * There are three parts in order: + * 1) skb drop reasons: relying on drop reasons for such as passive reset + * 2) independent reset reasons: such as active reset reasons + * 3) reset reasons in MPTCP: only for MPTCP use + */ +enum sk_rst_reason { + /* Refer to include/net/dropreason-core.h + * Rely on skb drop reasons because it indicates exactly why RST + * could happen. + */ + /** @SK_RST_REASON_NOT_SPECIFIED: reset reason is not specified */ + SK_RST_REASON_NOT_SPECIFIED, + /** @SK_RST_REASON_NO_SOCKET: no valid socket that can be used */ + SK_RST_REASON_NO_SOCKET, + + /* 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. + */ + /** + * @SK_RST_REASON_MPTCP_RST_EUNSPEC: 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, + /** + * @SK_RST_REASON_MPTCP_RST_EMPTCP: 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, + /** + * @SK_RST_REASON_MPTCP_RST_ERESOURCE: 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, + /** + * @SK_RST_REASON_MPTCP_RST_EPROHIBIT: Administratively prohibited. + * This code indicates that the requested subflow is prohibited by + * the policies of the sending host. + */ + SK_RST_REASON_MPTCP_RST_EPROHIBIT, + /** + * @SK_RST_REASON_MPTCP_RST_EWQ2BIG: 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, + /** + * @SK_RST_REASON_MPTCP_RST_EBADPERF: 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, + /** + * @SK_RST_REASON_MPTCP_RST_EMIDDLEBOX: 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, + + /** @SK_RST_REASON_ERROR: unexpected error happens */ + SK_RST_REASON_ERROR, + + /** + * @SK_RST_REASON_MAX: Maximum of socket reset reasons. + * It shouldn't be used as a real 'reason'. + */ + SK_RST_REASON_MAX, +}; +#endif --=20 2.37.3 From nobody Sat May 18 21:45:38 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 3E41218046 for ; Thu, 25 Apr 2024 03:13:59 +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=1714014840; cv=none; b=aJL0TM/lpArjDPC5oon9gVOMAGG+/4nWwmjsaoNY5UotKMXgC/kmHEYFaeYtPdQi0ktrDQ9r0MfthojUI581qU+aTJyoDQOnv3MRyhhZ5NjKjDPSIxajC6i0jb7IXNuwugMVtR4JJcxZVFvoniXQK9IkjioIDbQjI+OSTh8Ca84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014840; c=relaxed/simple; bh=55/RHpoHlC9YB5YVGgh9ZYOK/TFTKOarJZAiAFO7TY0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Zm6J1WOi13OOpoU6NKkk1r7iqaY0YfofYngClE0z+UyPuyA81IDY2E7OXVUof/WuUpjQcNJ6CblzHErhszoMl/a7+dYhEdgsR8Co+wuReFzwGTepd33g8B3i5Yw6N4Hhlp/EPYeiU6Kd5//lH8E9HIM29shJvFu0SNGDZfbilJk= 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=h0ob50GT; 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="h0ob50GT" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6ee12766586so484484b3a.0 for ; Wed, 24 Apr 2024 20:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714014838; x=1714619638; 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=AaTwbGXoanfrftf7v2SqxH09D9DVaPBxLL1b8FwqlRU=; b=h0ob50GTX4eRADe9gz84JCHLl/+fopF0wawry1Uf/Bg25V62bn9WMXKRfrph2Q4oPe dmxuEFIIBjvuZzMS3SvrEsetPy4oXQVJW98I7kFjcZtJ648dN1PYZQQiO/lAzIqhcQ0b 5OjqJk3T9+2s5WzVdqOmeSaLzEYPEvxE8/CXtRBEhxD2WSPxUkhrBV37X4XKPVkkb0by FAmPBPCD3FnAwjGKqc5D6nYSwOXeebTCfxM325gioVgXf3VFZHCTCFdgKK3GSwdJYxjP q8dDJFV1qWfk55oRf1tuCmqWWN3scxmTt6hP19vb17IYl/6ZO7plJPaKqrPeZmhkFKmM yNrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714014838; x=1714619638; 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=AaTwbGXoanfrftf7v2SqxH09D9DVaPBxLL1b8FwqlRU=; b=JebINyR2sxuFdkmSeQomGc5GqqJMiDDrJkstiDZ6l0xvg8Pp5m7lrrO9CFKSSIdS2E SyaiMiUGZxLrVNf9lAV3uwloh95mj6ec1O9Gj8Jba1PlEvFF2rqC2b4jEJk55TVbbFrE EO3+JsjHUo/d877wQg2GBRiVaPP8+xG/B9tUMObaliQdlaqK1jA5H16U+GUHKIbxt8Zp VQGNLZM5R5BC9CUxojhniW4VSECFsKVPqouKrT6/gEv5klbGNigMls1tB2KkP8wtgcX1 MtsosDoBMDxV9MfTWSK+XrnoW0oX328mvv9BF4RBeLYam2xKHVe/DbTAJX3PMe4XZP4i 9SbQ== X-Gm-Message-State: AOJu0Yxp96LDhhixZzYPe9v69PHksfFkFCHiX8CVcH/uE9MvdyymcfMe S2Dcbz15jIXOgqVAQ4FherhXdzXvrVeQrmUPOHslZG/2szuoK6Wy X-Google-Smtp-Source: AGHT+IHuLs/zkS5fTQu4UHxIOZWKIzjOIFxBoc0IvIZDFYIu3I0o6oP8He3xm3fTHI02JKi8A5Aj7g== X-Received: by 2002:a05:6a00:17a0:b0:6ec:f869:34c with SMTP id s32-20020a056a0017a000b006ecf869034cmr2627838pfg.16.1714014838442; Wed, 24 Apr 2024 20:13:58 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id gm8-20020a056a00640800b006e740d23674sm12588884pfb.140.2024.04.24.20.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 20:13:58 -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, horms@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v9 2/7] rstreason: prepare for passive reset Date: Thu, 25 Apr 2024 11:13:35 +0800 Message-Id: <20240425031340.46946-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240425031340.46946-1-kerneljasonxing@gmail.com> References: <20240425031340.46946-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 Acked-by: Matthieu Baerts (NGI0) Reviewed-by: Eric Dumazet --- 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 146c061145b4..7d543569a180 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) { @@ -878,7 +879,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 21:45:38 2024 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.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 A08EF10A3D for ; Thu, 25 Apr 2024 03:14:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014846; cv=none; b=ipIdbptnSjkAQOUujyHYvExUTQ4N9TZu7wJ82Qs/2SGAmJODntZtPMeZZ7xBgCNSkV6EYEQ/3nmDcZhqZjjCfkvWrsxHuBO6S7Y6bkrm/DDScB9EbnNlY7p5mNaIKVAIh03BdGDTIdWSJ3+tOPxikX9bcq44unKEU/dALRTZfKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014846; c=relaxed/simple; bh=3CSgRPNzb0vxazuCiKOfiTCXB6E/ggzocl8mwCpuJBg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PW73F6pRLAtUvf2cm6i19SlSPPo7K+MUgQrLqJyV5JRPgbPgYrLV9wUL1Fa+OWAPlCZCeDI4b4vqWz+bB5jLuuhgqT4vTjvC52pNSWvetr6lAQ/13pwbjsXy3csxF3SjlXH2FWtPtjzgzCgnVistVSZDlFlf+zeRK7Cw5MhxYeo= 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=fKZ39RVC; arc=none smtp.client-ip=209.85.210.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="fKZ39RVC" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6ee0642f718so1235562b3a.0 for ; Wed, 24 Apr 2024 20:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714014843; x=1714619643; 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=EIeMsBGu2uBX1XolPWE2+qMyy3X8EynnY26/dK+HipI=; b=fKZ39RVC/YcY40lAABPU2XuHnvYRVzO4okZHoXbLVWKUv3V5KUEq+CndgHUfXsCtHq 0C8OAEaCbGVv6BEyihWumnnkX31QNkuyLhOTS0mAOy6BnOr53p5s/AQSHOu8fL5pcERH QJT7kWhtynMRzTlp5xELlmmeIg9Y/P3s4u9f5pJ0cdtuZJE0/QrSL7907zIZB9wshNJ2 FGApZEciaa8p2PMYAHu1L9tZzRoZVcg20iuEDIIMlYLRCnriV1/3yH8/CkpuE4zB993a Y1+IxL+bKKU9zEHWENyUZpNgXxMN8oEK3X8iwDheroT/WwRfas1AOEI8QTyZZ/IDx2gL DMdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714014843; x=1714619643; 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=EIeMsBGu2uBX1XolPWE2+qMyy3X8EynnY26/dK+HipI=; b=qv2ubweMfh10eRlL4+4enxMpGQTfF880r2QqGUkyfyCVqRWaG6tTCnaVamNi6s6Btd jOgcVPNOfWaiOgqvM93cUPbfov1sWfAyrIH9t0pGNkwHlY/NTTVI6xVdv4QYl0pgBNkN UTU+qNmdVSRUlnRQb/bl0NjXRB7fj5/+pX7ggFHm+84Rwvs5jAwH3ff45GvX6wBhWQCZ lq1mmCfCPd3ex85eVeUWEsf7FycJba9ccjCDwoVN3XhIgq2b7BZtHjVhiTj9qRSX6NzT 4Iq5qLiaShc8hK/i3dGkmauVVUposIE26SU2F8UwE3q6byha2XApddEBv3+ER2XFksul ceIQ== X-Gm-Message-State: AOJu0YxclHHZf8UNvPeiHoO2zzkLyTe2/g3/sLAtD4khRv5Mi5fFsyX/ LVaI9/pszqFguAn7sdBtK+gON6IDtx66FOk2+voA32vR+s0xsdHo X-Google-Smtp-Source: AGHT+IEIU3Nap8cVHxwoUGeYiyaYLR0K5NZkBRbYYLjt3JOqKx0FWFSlhG1MoxeLIOhs2BHuzylJ+g== X-Received: by 2002:a05:6a21:2d8a:b0:1ac:3d62:9154 with SMTP id ty10-20020a056a212d8a00b001ac3d629154mr2567483pzb.31.1714014842890; Wed, 24 Apr 2024 20:14:02 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id gm8-20020a056a00640800b006e740d23674sm12588884pfb.140.2024.04.24.20.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 20:14:02 -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, horms@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v9 3/7] rstreason: prepare for active reset Date: Thu, 25 Apr 2024 11:13:36 +0800 Message-Id: <20240425031340.46946-4-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240425031340.46946-1-kerneljasonxing@gmail.com> References: <20240425031340.46946-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 Acked-by: Matthieu Baerts (NGI0) Reviewed-by: Eric Dumazet --- 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 99a1d88f7f47..e4f5c8b5172a 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3614,7 +3614,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 21:45:38 2024 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 24D8E1DDEE for ; Thu, 25 Apr 2024 03:14:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014849; cv=none; b=Pbd7s0b2KmEaaiAk52WFyXOI2NvvlFjkZ4iJzcPyIEsDT9+EUuTEXGqzvURSdAMdt+tB88eOCP8+E8TQRMKpsYKmYmbPMwlnPsZipGyvlxVGkZfaWpmqEEZXUK93FYux3NGkpg5RjEsoDN2TrCze6KtXbjkb1Z9uWtPTvW79gxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014849; c=relaxed/simple; bh=v7U6oW3gDsie/i0ijCRs85/Eal6SYC2LrAnRuKhJdAw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nf18xEWiOK+4g3uW1QIA8lwap6V4y4j7N7tHHgvWEFUZlJs1PIXMQl8grtWGq+Xtdts4HcJiL+wxwu01FAJ7U4i4uMr+t7kaBiw8Dnk9PBLhjbwAQGXULPBfxj6XH7wjsKRQfPnGJjDDl+3YTL3F3aj27GQaSr9gfKHoWSB7YFc= 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=Pegw/5vO; arc=none smtp.client-ip=209.85.210.182 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="Pegw/5vO" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6ee12766586so484536b3a.0 for ; Wed, 24 Apr 2024 20:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714014847; x=1714619647; 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=W6IM3xStLyH2OezX5Q6f1JfXVKMrEKiHR6KKT+cuT2w=; b=Pegw/5vO2vpDPfkYap2L7dtGis4qJyXUwXI8G0P8lSCM/vk3XFewLXP2/D3dA/yruD SwBtMUVj63+fToQRDZEe/sqnJTwsWM4JbvN82bEl+o62M6ThzsKIovfABeyEWbgR8int 8vol9jc3A4REi/cM30BC3PiJjYiHR5xQ8sGJlcx66zVoEWKhyIZJo6jlOy7YVh5nf37x G2mgPsD5bK9SBI2R7TMa+cWM2ygSLVw5a6iXTi5l3pl6eqeuJ2DW6vJsiagQf+x/GlGJ tncK7OqtjsDHY/AzwsgyM7qqWTqG14OWPzB0cL7IFRMOHdISX5AycKG2s1/dATLpkVIk eraw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714014847; x=1714619647; 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=W6IM3xStLyH2OezX5Q6f1JfXVKMrEKiHR6KKT+cuT2w=; b=q2mkatIxKt/HZVzCJti8KJ5mkCZsht6cqda/rop+/Jomlb9A9KJMEQH9zx1jNPUUN/ HfEi4Vxgil7Rf1YNGZ9TBMcNDbTvwnpQHinYL9cX+3cqOGYN7b6rV2lSCMi1p7w252T6 yls6zydTnnOSlMexrlA2bhMpLMHiNvyEg+aGhqr+fT4BnDONHCxmk9qMkjOlDjPRO0jz 9liVqbYOE5xmT7NhDl9+pR6yPSqrkKRH0MhMaHXJEDy+U3eFKsKU/xm9L9RpVUXItYRH kCo5hf8cFi9cayS2fZO0a6DPSRhjbEU8N0HzcTIpm9WDieK143pABZblatgnZ5fnvS9L rL9A== X-Gm-Message-State: AOJu0YwkKVrCaVrEy35WpMRoald61LT4/HfwYFomc8jfw4DgIoXI5Vfm MKRnvQXnKhJYNZN7clpkIiIq416jpSRh7YkgpqTF6ALHqMHVU+5p X-Google-Smtp-Source: AGHT+IGtwH1fE/Tcubt8Ed5lxBtcDpXwEXMYJQtyqMUjux9Y7TF9h7ABf/9vp6uIKgvCaOflWA4NQg== X-Received: by 2002:a05:6a00:a86:b0:6ed:2f0d:8d73 with SMTP id b6-20020a056a000a8600b006ed2f0d8d73mr2487746pfl.3.1714014847386; Wed, 24 Apr 2024 20:14:07 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id gm8-20020a056a00640800b006e740d23674sm12588884pfb.140.2024.04.24.20.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 20:14:06 -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, horms@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v9 4/7] tcp: support rstreason for passive reset Date: Thu, 25 Apr 2024 11:13:37 +0800 Message-Id: <20240425031340.46946-5-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240425031340.46946-1-kerneljasonxing@gmail.com> References: <20240425031340.46946-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 can finally display the corresponding item in enum sk_reset_reason instead of reinventing new reset reasons. This patch replaces all the prior NOT_SPECIFIED reasons. Signed-off-by: Jason Xing Reviewed-by: Eric Dumazet --- include/net/rstreason.h | 15 +++++++++++++++ net/ipv4/tcp_ipv4.c | 11 +++++++---- net/ipv6/tcp_ipv6.c | 11 +++++++---- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/include/net/rstreason.h b/include/net/rstreason.h index bc53b5a24505..df3b6ac0c9b3 100644 --- a/include/net/rstreason.h +++ b/include/net/rstreason.h @@ -103,4 +103,19 @@ enum sk_rst_reason { */ SK_RST_REASON_MAX, }; + +/* Convert skb drop reasons to enum sk_rst_reason type */ +static inline enum sk_rst_reason +sk_rst_convert_drop_reason(enum skb_drop_reason reason) +{ + switch (reason) { + case SKB_DROP_REASON_NOT_SPECIFIED: + return SK_RST_REASON_NOT_SPECIFIED; + case SKB_DROP_REASON_NO_SOCKET: + return SK_RST_REASON_NO_SOCKET; + default: + /* If we don't have our own corresponding reason */ + return SK_RST_REASON_NOT_SPECIFIED; + } +} #endif diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 418d11902fa7..6bd3a0fb9439 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, sk_rst_convert_drop_reason(reason)); discard: kfree_skb_reason(skb, reason); /* Be careful here. If this function gets more complicated and @@ -2278,7 +2278,10 @@ 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); + enum sk_rst_reason rst_reason; + + rst_reason =3D sk_rst_convert_drop_reason(drop_reason); + tcp_v4_send_reset(nsk, skb, rst_reason); goto discard_and_relse; } sock_put(sk); @@ -2357,7 +2360,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, sk_rst_convert_drop_reason(drop_reason)); } =20 discard_it: @@ -2409,7 +2412,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, sk_rst_convert_drop_reason(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..317d7a6e6b01 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, sk_rst_convert_drop_reason(reason)); discard: if (opt_skb) __kfree_skb(opt_skb); @@ -1865,7 +1865,10 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buf= f *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); + enum sk_rst_reason rst_reason; + + rst_reason =3D sk_rst_convert_drop_reason(drop_reason); + tcp_v6_send_reset(nsk, skb, rst_reason); goto discard_and_relse; } sock_put(sk); @@ -1942,7 +1945,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, sk_rst_convert_drop_reason(drop_reason)); } =20 discard_it: @@ -1998,7 +2001,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, sk_rst_convert_drop_reason(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 21:45:38 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 78EFB20DFF for ; Thu, 25 Apr 2024 03:14:12 +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=1714014854; cv=none; b=bDTImtqLShrIz0sV/bbMfxG0V0d9HjtfndSiJfDzwwgCIGNQ3Pth+QdKj1H4F0hpkQhpAVD8+jPGXXqJmtVxqGFDVeuwlwBcga++529Y2AZZbJJKepiWrcU4yAjlVX7ic296hyNdAizbJWkv0DuxzqmC6JRXZZ9zRokAMZLAJT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014854; c=relaxed/simple; bh=ZzdnPsiqXb+gwrlJNqitSNDymZ6BXbM5YRkAduTF0Ds=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sWJx5d4nL2ZUURLN4dRGQzDih1S2GCA4IkXM+DTHdQDLrwXlDzfyBzD7CNq/iOcMPS8qrM9akmvKo267xY3tK3Qp6U92qN4F16erSvXcKkMQWx7Ub0fIcWVu+o6dKec/vSD9GxtKMu2a8QNqip94SfirT/01RdsgHOSs/pwExIA= 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=g9yafNhd; 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="g9yafNhd" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6ee0642f718so1235633b3a.0 for ; Wed, 24 Apr 2024 20:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714014852; x=1714619652; 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=FMtORYJbYGS95Jxb6SGnELiDnvrnb/ZXbQDgC0mXKKg=; b=g9yafNhdsmjBPwIv05ll4ShQgZyXjGk1cSi7/G2ZsER+B3hU4rHvVX3xha//JIBhSG NT9A/EzdtpOnNJK15+1K59o7tAVtbsA5YyITNlq3XZedzzDCSi8fe6L4b96BiQfV2ek6 sebI8uLkT/B3KU+ZRRdpJpJtZCJ15iyriHexG9Q8R7+lVRqSbl4DTQB5oOKSnmJGqnCC va9VHpFpiWVLWFHT41YNGwkuBZL0StwqQ9GPt6pDVkJS3lMTAilSBBdeydglWJhwTCEG WlY4QCw0O54YLriJVxd4gZUec+mR71wH9MbH7DIxSXCe3tXx0qGhYPgWs3oo3gGVy+1D A5uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714014852; x=1714619652; 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=FMtORYJbYGS95Jxb6SGnELiDnvrnb/ZXbQDgC0mXKKg=; b=AfNNbFSZsEMMbdYPuEpy1pCIijt+gskrPrH4LeCGiP9db/nahupn9SRgdB+qaO75nE c6f7jIKONWhZNwmGTXD0fBnzoB8r3Pkeh2fYYY9b8/wlExKJwQPa9sk2+p9do37e8GiI UFfGUQLUEAlPlnounhntSPh6glHhq5nuhYlJzCEPRndpawvyByA/Yw/fTpYZnT4YTYvf 18LgxEisP9w0AGAxRNmtHxBGpf6+SnXIlpFTLk4K9qggIyZsiEJEIK6aqTC60OVOxYsA 1JRB3qOGNaULqiEF6MihYPtXAFnDorQerSv0IQMoUpnUobbu0KBinX+Hgg5xJfVfKePX XDqg== X-Gm-Message-State: AOJu0YwmcySgaDHI70q9St77S1QkoNmJhNHiJvGDY80/YxvnxzeGlWhC 74WiEg7zud+xhZrX5btxN9VUvvtqBZKV2jCMgCw5ezPDNpalFlH1 X-Google-Smtp-Source: AGHT+IHrRlMjZbB3EeKQMBe+MK774H9qalWmFJTcDp4e7CQEiCEC7v5c1cJQZnuGPwrmYiUrvX7Dqg== X-Received: by 2002:a05:6a20:3c92:b0:1aa:954f:d466 with SMTP id b18-20020a056a203c9200b001aa954fd466mr2428226pzj.23.1714014851801; Wed, 24 Apr 2024 20:14:11 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id gm8-20020a056a00640800b006e740d23674sm12588884pfb.140.2024.04.24.20.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 20:14:11 -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, horms@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v9 5/7] mptcp: support rstreason for passive reset Date: Thu, 25 Apr 2024 11:13:38 +0800 Message-Id: <20240425031340.46946-6-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240425031340.46946-1-kerneljasonxing@gmail.com> References: <20240425031340.46946-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 relies 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 Reviewed-by: Matthieu Baerts (NGI0) Reviewed-by: Eric Dumazet --- net/mptcp/protocol.h | 27 +++++++++++++++++++++++++++ net/mptcp/subflow.c | 22 +++++++++++++++++----- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index fdfa843e2d88..252618859ee8 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -581,6 +581,33 @@ mptcp_subflow_ctx_reset(struct mptcp_subflow_context *= subflow) WRITE_ONCE(subflow->local_id, -1); } =20 +/* Convert reset reasons in MPTCP to enum sk_rst_reason type */ +static inline enum sk_rst_reason +sk_rst_convert_mptcp_reason(u32 reason) +{ + switch (reason) { + case MPTCP_RST_EUNSPEC: + return SK_RST_REASON_MPTCP_RST_EUNSPEC; + case MPTCP_RST_EMPTCP: + return SK_RST_REASON_MPTCP_RST_EMPTCP; + case MPTCP_RST_ERESOURCE: + return SK_RST_REASON_MPTCP_RST_ERESOURCE; + case MPTCP_RST_EPROHIBIT: + return SK_RST_REASON_MPTCP_RST_EPROHIBIT; + case MPTCP_RST_EWQ2BIG: + return SK_RST_REASON_MPTCP_RST_EWQ2BIG; + case MPTCP_RST_EBADPERF: + return SK_RST_REASON_MPTCP_RST_EBADPERF; + case MPTCP_RST_EMIDDLEBOX: + return SK_RST_REASON_MPTCP_RST_EMIDDLEBOX; + default: + /* It should not happen, or else errors may occur + * in MPTCP layer + */ + return SK_RST_REASON_ERROR; + } +} + 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 ac867d277860..fb7abf2d01ca 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 sk_rst_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 sk_rst_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 sk_rst_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 21:45:38 2024 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 184B818E02 for ; Thu, 25 Apr 2024 03:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014858; cv=none; b=s1hhHsuxjL1FG9lzLPuLG5687XrASoB1ycIXJrSQFMibyaBHaOJ+yCuQ9vmh075bn/Z5eRFt9THiws+U4aHvViO/TKOPgEi5dOz9bLk77Z+0G1czsdrGCimxmmkFm1lubbm0Nf/8vG1hj/WhK47axMEhMjAvRfA//uOgLO/NtUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014858; c=relaxed/simple; bh=5Twuf+QmvuNeGozvIoYp0oljoELBzYsZuDa4GXIvUGY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ttbgIVDNc8DN04yWZ+hTMOrc1XgSngQYvnANj3VMwW6GBFBct8cECzQQ4ivrNk9cg6/7sEWKwgKoT7YuilQXX6ZPAvPYLMlEUsxQWz0X3/IOjlagB4KVZwsDN3VhsYgZuwpSneniQqF15ocSAUWRozPQVoqKtRPlpXmaNLhjJZE= 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=PNNRESK7; arc=none smtp.client-ip=209.85.210.170 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="PNNRESK7" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6f28bb6d747so500369b3a.3 for ; Wed, 24 Apr 2024 20:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714014856; x=1714619656; 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=W3+Qhzs5AOSyz2ITXuZgC1EVLjEOHqqD2ysMgBwoBAs=; b=PNNRESK7ZjfTxJs8X0UwHTYRkRrdZDGO8Vsh3QWUnT67RIAAhmbxYryblUNkzKbZqa PEHAVZHw1V3MH4NtmZC1ElSlvG8u2TBjHpRx1CrA3Q4axnrYmttd1A+VMJn1XFqgbHrz IOP5JxvLLlMhVPD1NWHORMQczJeOoEcw/AWLIhPFmffbBGingDhLucsjd5y/3feXcLgN yiK6pi2UCE+jBPm9SiMo/wTiwu7dUegajSLPi7VfzxjtsMZQQ6xrSmt93imIgCgEgmh7 m8y9inE97b4oO4O8jrXeUieY0Fh+M7bt5yf/tTnwPInNV8dhdnAhwnwKw6EM7Avv7y0Z MbHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714014856; x=1714619656; 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=W3+Qhzs5AOSyz2ITXuZgC1EVLjEOHqqD2ysMgBwoBAs=; b=WtY28N92HeRvwbEDppHSxabCdbqRdHDfwQODLOQ63PxDtjRnk6R9mkQE7S0wesHslD z//GghSyPkfKyTGVAX8XnYi3sm5c/CzZDR5CYgiiNms+h/aYwQSURoZbW1at4MNE85vp vE0FdXDG5UMfwTudA6Gw9nNU6pN86o135D59x0tIg4BgJazkn1D/4GHfuQGYldMqsg8K q86Lnm8Y6mbrI4gSxBrZOkmr7RTcJzNaBmT7wHnn8TRnNzloh/bpG8x4Vy8ntqIgTFvf TgT3ZuwgSwurPCtml+GcarXW0g3tvPILUMuIsXvnIao/o2KZNgBHf/NoFB5scw8wUfvI YKOw== X-Gm-Message-State: AOJu0YySR5b2iU/XHue+oEq53Jz7o3wj6c51Te7KoDMLXpCh4RXB6hl+ rxMBYLBTFyzi55vFlW3ERkMRX82os0A9fV9+aLwPsnhcvp1HfDfM X-Google-Smtp-Source: AGHT+IGXT08WAfSY9N6LNnChQMP0idSLLdNjAxVSI6PyQz7x57xvQbff1xV0tuZvTAVStGSawFSC/Q== X-Received: by 2002:a05:6a00:2388:b0:6ed:2fb8:467b with SMTP id f8-20020a056a00238800b006ed2fb8467bmr5357021pfc.26.1714014856426; Wed, 24 Apr 2024 20:14:16 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id gm8-20020a056a00640800b006e740d23674sm12588884pfb.140.2024.04.24.20.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 20:14:15 -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, horms@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v9 6/7] mptcp: introducing a helper into active reset logic Date: Thu, 25 Apr 2024 11:13:39 +0800 Message-Id: <20240425031340.46946-7-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240425031340.46946-1-kerneljasonxing@gmail.com> References: <20240425031340.46946-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 Reviewed-by: Matthieu Baerts (NGI0) Reviewed-by: Eric Dumazet --- 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 252618859ee8..cfc5f9c3f113 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 @@ -608,6 +609,16 @@ sk_rst_convert_mptcp_reason(u32 reason) } } =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 sk_rst_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 fb7abf2d01ca..97ec44d1df30 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 21:45:38 2024 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.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 C3E951C6B9 for ; Thu, 25 Apr 2024 03:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014863; cv=none; b=kVdmMk3OBOj4JO8cNe5gNo008780YlrwjWUSHqisyd1xbWLdTN8N1oVwBzT4lwLKe2b2CNtaSwX+eTFiwYdVGYeTFNWL39jual3iB23IInEzq0w9PQbs4lCQwQvb2PpiLu7yVxX0lTx51BcTnABo/NUslauRarAexLY1T1R/PkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714014863; c=relaxed/simple; bh=Su8k9rAmiQpz0eW3uCuyH9NG8vZCEsJsTNrN5666vjo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tsjAGsWLauSl/m4RgapJUoSK/sGpfjUCFvjIISYA0JsW/VFp+/ZtJPrGt7X+cSQiGj+ISMcFNHSG2gmazwxMwE6e438s52D1DCk1JS3g3mpoWQkduFsDDYYPi2eVsCpb5uX38uFE0/NImJD+fs3TZ3EkCud7Zs/YMx/gjuxxsG8= 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=lExUo6hI; arc=none smtp.client-ip=209.85.210.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="lExUo6hI" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6effe9c852eso465089b3a.3 for ; Wed, 24 Apr 2024 20:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714014861; x=1714619661; 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=eoNx1z39dGPPZ78bCeD3rHzBhVr78CiU8JLx1x2utLk=; b=lExUo6hIWE1SWOW/6SwrvwMOueOclcjfzCSxia8D/2bW4/n1vxNrKG0kqsQgenxWc0 N44k4cI+ezYQdLBTW/eL1PsU84+OxIt3B+hMZ6B8yJQZY+9GmLykoGfiimogI4lcErYa loC9TMWA04/vBjtGDaWcnNGfP3fHNCCtc8vY8aBDOqo96vCTt0ZHOTov6M7QzOEgoj32 VEqEY1owx2tMHKuJZDHa9dD8tgGMmzFtCq05CzP93KQ8mA3oP3AV928fU8i1bMaq3Vh0 pAhHrcFS83oPJ/Ry2nQh8MDq7Wl7TISvjw0/W8AV8oM90uDJk7y5tWkkGFsKBhd7dIHY Jh4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714014861; x=1714619661; 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=eoNx1z39dGPPZ78bCeD3rHzBhVr78CiU8JLx1x2utLk=; b=q2CLSgztwIhBGo+DdVa+6Vp6t6DotL2WbDJyabX7TVEdUHo+KDaP2iVIkrO7wih2Bc xMtI3lLlMLknI+/Hedf6TiZaRrfF+nDjXg5nMhRPZaC5mJzWRqUJ5oZiPtbNC5ODj5Ny hPylyvEuL+4dkp0IonmDsy3a00ZJqk7jXov3k+ECqrjOK8Zsq4WTg2f97WsDNnhR5iKB zGi7aKkgg97dVnWBik0MzfLAnNzjinXnC7D/V84jWLY9N0nl8zkN60fFndMEsVo7Na/Y gTBgreV/qtMCCprcryEe2+cdiuqiUZ5XAZcOGGhjtNwOnH30w4ctVPshQoEWBkDX4NZP DC7Q== X-Gm-Message-State: AOJu0Ywt+BP1Gt5ASlWUsTsR60cxLE7rJ9uOwSQx9sMYb9yMEpp0Xtyf S5svvoSxp9oZRARZAI9ocg59r+fZIBQ6fEtlg7/vL0D1zkdhXfzB X-Google-Smtp-Source: AGHT+IFYaBM1zVxSogGDuroOQcY0k8FNcX9L+oQEQWL9Yqbgf12ULz5XXVjMcB/LGl8/XCTTSuPxZw== X-Received: by 2002:a05:6a00:189b:b0:6ed:d3af:1070 with SMTP id x27-20020a056a00189b00b006edd3af1070mr5786765pfh.32.1714014860870; Wed, 24 Apr 2024 20:14:20 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id gm8-20020a056a00640800b006e740d23674sm12588884pfb.140.2024.04.24.20.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 20:14:20 -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, horms@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v9 7/7] rstreason: make it work in trace world Date: Thu, 25 Apr 2024 11:13:40 +0800 Message-Id: <20240425031340.46946-8-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240425031340.46946-1-kerneljasonxing@gmail.com> References: <20240425031340.46946-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) Reviewed-by: Eric Dumazet --- include/trace/events/tcp.h | 26 ++++++++++++++++++++++---- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/tcp_output.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h index 5c04a61a11c2..49b5ee091cf6 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,32 @@ DEFINE_EVENT(tcp_event_sk_skb, tcp_retransmit_skb, TP_ARGS(sk, skb) ); =20 +#undef FN +#define FN(reason) TRACE_DEFINE_ENUM(SK_RST_REASON_##reason); +DEFINE_RST_REASON(FN, FN) + +#undef FN +#undef FNe +#define FN(reason) { SK_RST_REASON_##reason, #reason }, +#define FNe(reason) { SK_RST_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 +126,19 @@ 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", + __print_symbolic(__entry->reason, DEFINE_RST_REASON(FN, FNe))) ); =20 +#undef FN +#undef FNe + /* * tcp event with arguments sk * diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 6bd3a0fb9439..6096ac7a3a02 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 e4f5c8b5172a..a8d5f22c079b 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3640,7 +3640,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 317d7a6e6b01..77958adf2e16 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