From: Jason Xing <kerneljasonxing@gmail.com>
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 <kernelxing@tencent.com>
Subject: [PATCH net-next 2/2] mptcp: add reset reason options in some places
Date: Fri, 5 Apr 2024 10:39:14 +0800 [thread overview]
Message-ID: <20240405023914.54872-3-kerneljasonxing@gmail.com> (raw)
In-Reply-To: <20240405023914.54872-1-kerneljasonxing@gmail.com>
From: Jason Xing <kernelxing@tencent.com>
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 <kernelxing@tencent.com>
---
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;
--
2.37.3
next prev parent reply other threads:[~2024-04-05 2:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-05 2:39 [PATCH net-next 0/2] mptcp: add reset reasons in skb in more cases Jason Xing
2024-04-05 2:39 ` [PATCH net-next 1/2] mptcp: don't need to check SKB_EXT_MPTCP in mptcp_reset_option() Jason Xing
2024-04-05 7:47 ` Paolo Abeni
2024-04-05 7:58 ` Jason Xing
2024-04-05 8:34 ` Paolo Abeni
2024-04-05 9:11 ` Jason Xing
2024-04-05 2:39 ` Jason Xing [this message]
2024-04-05 8:16 ` [PATCH net-next 2/2] mptcp: add reset reason options in some places Paolo Abeni
2024-04-05 9:09 ` Jason Xing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240405023914.54872-3-kerneljasonxing@gmail.com \
--to=kerneljasonxing@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).