From patchwork Fri Apr 5 02:39:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13618383 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 4676417545 for ; Fri, 5 Apr 2024 02:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712284777; cv=none; b=aTlyOprfkk9TPAlWzdFrCpTS62NU200bVPO4wbMV1WrazakHsc48niW4KO8U9napxhUWsjCEj69O1Zhq8kjx/0YlaBChpo1RMwjtA02ustL/wZQdA8ixiB23Vdc8JT6mUP2KFrNtFgkgymlZYfc9zPB7lJGpJ3P296W1yN7TGJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712284777; c=relaxed/simple; bh=tTgPHWnpK1ARuYaqryAdkko9C7B0FiHVoFSbYKVwDg4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cxmTwehAVzplwzb5WjtX+mEh7KO1yCgwtsFghjpWHfizyx52mqcHHt2hFeohyVe8sg0VuFNlF90TVHSoO+YS8cv2ZDcN7eVCUDKQ5TeSGCLpFkYak9ug1xuz3QjhxdjSrQzISXzSF706CmoqqpAuQI5Ie7rWm1UDtYli7rfouLY= 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=iQob2qfl; arc=none smtp.client-ip=209.85.210.179 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="iQob2qfl" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6ecf9898408so575698b3a.1 for ; Thu, 04 Apr 2024 19:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712284775; x=1712889575; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lLePXVeMPfpQzwXoy7NOU9eXP6dijn/e0uzvyqDninM=; b=iQob2qflIHrnpFjIqWWmzAc0whYQRck/iAkrMUjjag2lo3/f1pwxeeleVWGsaqQpQz tuBYfTHWSNzkk4YRtUw4S55COGAW6j8SSNyL22v+t4IGD8vpN7Cpl6wxt/TnB0rO0PeE J4SEUw/FU5ZBw6uW7V0bULZX4PdIUwl3P0FdGpRcdqIlAW5/iLna9+yyuVXGKq+E/EVG RHxtSwINUpbgTYqj9Ff0oWuzGIupDT6PfHcDcDM5uYjCjTjpyyIfD8EnDxbFha7hlw8k EiNq0UOPgNwtlhgHHPCatXux0zwYpIvWFAn+2+tvRz8seFnX0NXHaSMaRFMcqvnoNeMr KCoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712284775; x=1712889575; 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=lLePXVeMPfpQzwXoy7NOU9eXP6dijn/e0uzvyqDninM=; b=TPz4NfK82fdZnOtKC6mCNNsInwkf6AIttt/nLby9d7HY4RAeXbicP1Q+1J+B7a/ZpA M02B70/OZP2X6uyxBsSTwvHwNpieQh5tyRTGh9hpCQG+iYrcNNsQk1QSF5Ozq3bFpsiI Cwavl2zDbktE6TDDEu9qoCcB5m4v/TByAzo/KF9kUDK9ZpswTt3z/Kl7YYjs8woRo0Fh DXN2qrC5fjpT3DYu3o+FquPwz5FgKlElPXX6Ttjfs+dezj+ZfgZWShNKqzqvbhSuKPnd +SuD5WBWYGM/TrErrJNooJSco86tsGkm80sFC3ZLflY1lPMF7l6wiJAPPGGEyUaEfwfO kI3Q== X-Forwarded-Encrypted: i=1; AJvYcCVzIFW6iZVsQiLEcpkBp29eaot0XNL57Bib+z+grjaP+eF/eptx1kq19PtNDwZWWhyYuPPgg01XUmSnWoeUwraF262UPb0v X-Gm-Message-State: AOJu0Yy3vi5EiCk2l2FYM9dY5SoMdD49JnmpAOI2NR0xYXTNGfHvMQd+ mG0OWBJP/omOSreN0KHSrelAvjVQtIKcKyAjAu7vJCMq8XANhGtT X-Google-Smtp-Source: AGHT+IFgg+Or3iPiTfJ7Gpg6zUuzHOLtW8b/EWVJmICdCHYpjFDA+eeksmR2Rov5q5XFktbksHTv1Q== X-Received: by 2002:a05:6a20:549b:b0:1a5:6c2c:2db9 with SMTP id i27-20020a056a20549b00b001a56c2c2db9mr1676278pzk.3.1712284775505; Thu, 04 Apr 2024 19:39:35 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([111.201.28.7]) by smtp.gmail.com with ESMTPSA id g27-20020a63565b000000b005d8b89bbf20sm366494pgm.63.2024.04.04.19.39.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 19:39:34 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next 1/2] mptcp: don't need to check SKB_EXT_MPTCP in mptcp_reset_option() Date: Fri, 5 Apr 2024 10:39:13 +0800 Message-Id: <20240405023914.54872-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240405023914.54872-1-kerneljasonxing@gmail.com> References: <20240405023914.54872-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Before this, what mptcp_reset_option() checks is totally the same as mptcp_get_ext() does, so we could skip it. Signed-off-by: Jason Xing --- include/net/mptcp.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index fb996124b3d5..42d13ee26619 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -215,10 +215,7 @@ __be32 mptcp_get_reset_option(const struct sk_buff *skb); static inline __be32 mptcp_reset_option(const struct sk_buff *skb) { - if (skb_ext_exist(skb, SKB_EXT_MPTCP)) - return mptcp_get_reset_option(skb); - - return htonl(0u); + return mptcp_get_reset_option(skb); } #else From patchwork Fri Apr 5 02:39:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13618384 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (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 8230A1799D for ; Fri, 5 Apr 2024 02:39:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712284783; cv=none; b=nA6KeVRDW0SpFyAzuK//l/LCswaVGQ4wwm+DKGC+uppPfmgRhNo9j2eHy+Wd3pj7WNcJU5C0bB+ZMN6rySP5AKzbbTVq9mgybDiuZ3BewA/4WDB+S7AOhk2FpKqcRKQbb6MA6FFsBVAZVRXbBR5FrLWbzT2HqwF8Qe9EGPirD/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712284783; c=relaxed/simple; bh=5QX6fzxn2CQXNmMlj/YURw9BuA5tNw+GgrYcPN6BxY8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T4qh/BeI//l6rFjo4/QH2dABv0YJ5qWZGn80Z+nDiz4POjuO148nYcLQr/WJVlCPfjzp3ppuOiu5noq4ZyMc1wIx9r8Iu8Szf2Kx85hZ05sz3fGA5/8d9hmcvVzOXSmOUJ7GEFJdKpft1w+xdeFF/JcLbPdDxFQu33DzfJsPHV4= 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=fMVLyXOd; arc=none smtp.client-ip=209.85.161.54 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="fMVLyXOd" Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5a470320194so1010883eaf.3 for ; Thu, 04 Apr 2024 19:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712284780; x=1712889580; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8+WUgxwoWhE9CA4LyTM2EhUBxr1t+2JsbiUmutcJLZ0=; b=fMVLyXOdKBMhZqjvUC43TUUQiv/ONBFmMgtsc/5th4zevLDTddUREa3j/q/eGsuutn mvow5m6hs6rJUUdbCOXJCu9An71jzXdy/8YW21UC+WN+VLpSj86L1TRo27T3xZB64dLH 2z5y2QwXNsQad2A+uNwZ9cEklmTSPcOQs2Wi5h8fealV+CGD39fP/O7Z8j85U4MnraKT edtpmjPBiNkgg66XSiJ5vc3sfAZ4udBdgWy8r8Ga1i/gXbMDHV4mSe7RzOFseWDDO/q1 hJfA0BIsE5ZQRSYFbw4U3ddiBT9teiJIW5c8I5M65JsWS7cv3aEQVLqp+TPTVyX6DIae HAxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712284780; x=1712889580; 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=8+WUgxwoWhE9CA4LyTM2EhUBxr1t+2JsbiUmutcJLZ0=; b=Ohqmn3s+8YIRNq/JmH8hKmZppe5SLZeR0DL4Ls04SXxr9dfMyJKdf14NhGtQs+r7kB eJevwIVXpbWfSQjzjhF/e+wgnmwrvtq11QeZPpbwPfnR4Gg/3QN48G3DdVrrBsvfY3Q0 +C5lCDGtw4/NvaDGAoGZj7Tr/cuoHrhQq8RCrLVhKssJ0HjiiIYSa7ZiRUlczJSmgWsD +PfjamsPlnthYMo5mYFNPk/fQIs/xYG0JHljDpPCuo3S+C0s0RjcmhfKMPzqsjjdn4jK AHdkNzDf/hasAfK0u+hVaYHLAdEq+HkH7pPt8nXQFc60tMgDaRU+vbd8a7gKDrsTQKdU e9KA== X-Forwarded-Encrypted: i=1; AJvYcCX4G+psYQotEib8GG7ge6qNNOlJHMZSSp3ygAE2wVM5OsOhO7D37pYsPUX2V9i7rewo6TwLcD9Izg7dq+fVzH54f+CcVkmJ X-Gm-Message-State: AOJu0YzmuShYx9N/CljxiCTNQzX4CWmr7yqThoMp9n8BrGTM5GAO05qL rHiv6vBxy79RMVyHdDfM5qlIPBXoImJmVL9JTMzghbnvVzQ9deZm X-Google-Smtp-Source: AGHT+IE9uCOy08j21++u8sWENz6qjmz3wlGDjgbgkrmZJDVgWfDvR0rwMbf1iyPQZSZQ+wmX25CVPA== X-Received: by 2002:a05:6359:a214:b0:183:612d:4499 with SMTP id ko20-20020a056359a21400b00183612d4499mr340167rwc.31.1712284780471; Thu, 04 Apr 2024 19:39:40 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([111.201.28.7]) by smtp.gmail.com with ESMTPSA id g27-20020a63565b000000b005d8b89bbf20sm366494pgm.63.2024.04.04.19.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 19:39:39 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next 2/2] mptcp: add reset reason options in some places Date: Fri, 5 Apr 2024 10:39:14 +0800 Message-Id: <20240405023914.54872-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240405023914.54872-1-kerneljasonxing@gmail.com> References: <20240405023914.54872-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing The reason codes are handled in two ways nowadays (quoting Mat Martineau): 1. Sending in the MPTCP option on RST packets when there is no subflow context available (these use subflow_add_reset_reason() and directly call a TCP-level send_reset function) 2. The "normal" way via subflow->reset_reason. This will propagate to both the outgoing reset packet and to a local path manager process via netlink in mptcp_event_sub_closed() RFC 8684 defines the skb reset reason behaviour which is not required even though in some places: A host sends a TCP RST in order to close a subflow or reject an attempt to open a subflow (MP_JOIN). In order to let the receiving host know why a subflow is being closed or rejected, the TCP RST packet MAY include the MP_TCPRST option (Figure 15). The host MAY use this information to decide, for example, whether it tries to re-establish the subflow immediately, later, or never. Since the commit dc87efdb1a5cd ("mptcp: add mptcp reset option support") introduced this feature about three years ago, we can fully use it. There remains some places where we could insert reason into skb as we can see in this patch. Many thanks to Mat for help:) Signed-off-by: Jason Xing --- net/mptcp/subflow.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 1626dd20c68f..49f746d91884 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -301,8 +301,13 @@ static struct dst_entry *subflow_v4_route_req(const struct sock *sk, return dst; dst_release(dst); - if (!req->syncookie) + if (!req->syncookie) { + struct mptcp_ext *mpext = mptcp_get_ext(skb); + + if (mpext) + subflow_add_reset_reason(skb, mpext->reset_reason); tcp_request_sock_ops.send_reset(sk, skb); + } return NULL; } @@ -368,8 +373,13 @@ static struct dst_entry *subflow_v6_route_req(const struct sock *sk, return dst; dst_release(dst); - if (!req->syncookie) + if (!req->syncookie) { + struct mptcp_ext *mpext = mptcp_get_ext(skb); + + if (mpext) + subflow_add_reset_reason(skb, mpext->reset_reason); tcp6_request_sock_ops.send_reset(sk, skb); + } return NULL; } #endif @@ -873,13 +883,18 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, ntohs(inet_sk((struct sock *)owner)->inet_sport)); if (!mptcp_pm_sport_in_anno_list(owner, sk)) { SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MISMATCHPORTACKRX); + subflow_add_reset_reason(skb, MPTCP_RST_EPROHIBIT); goto dispose_child; } SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINPORTACKRX); } - if (!mptcp_finish_join(child)) + if (!mptcp_finish_join(child)) { + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(child); + + subflow_add_reset_reason(skb, subflow->reset_reason); goto dispose_child; + } SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKRX); tcp_rsk(req)->drop_req = true;