Skip to content

Commit ce222ff

Browse files
committed
mptcp: support rstreason for passive reset
JIRA: https://issues.redhat.com/browse/RHEL-48648 Upstream Status: linux.git commit 3e14049 Author: Jason Xing <kernelxing@tencent.com> Date: Thu Apr 25 11:13:38 2024 +0800 mptcp: support rstreason for passive reset 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 <kernelxing@tencent.com> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Antoine Tenart <atenart@redhat.com>
1 parent 8ea5cff commit ce222ff

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

net/mptcp/protocol.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,33 @@ mptcp_subflow_ctx_reset(struct mptcp_subflow_context *subflow)
576576
WRITE_ONCE(subflow->local_id, -1);
577577
}
578578

579+
/* Convert reset reasons in MPTCP to enum sk_rst_reason type */
580+
static inline enum sk_rst_reason
581+
sk_rst_convert_mptcp_reason(u32 reason)
582+
{
583+
switch (reason) {
584+
case MPTCP_RST_EUNSPEC:
585+
return SK_RST_REASON_MPTCP_RST_EUNSPEC;
586+
case MPTCP_RST_EMPTCP:
587+
return SK_RST_REASON_MPTCP_RST_EMPTCP;
588+
case MPTCP_RST_ERESOURCE:
589+
return SK_RST_REASON_MPTCP_RST_ERESOURCE;
590+
case MPTCP_RST_EPROHIBIT:
591+
return SK_RST_REASON_MPTCP_RST_EPROHIBIT;
592+
case MPTCP_RST_EWQ2BIG:
593+
return SK_RST_REASON_MPTCP_RST_EWQ2BIG;
594+
case MPTCP_RST_EBADPERF:
595+
return SK_RST_REASON_MPTCP_RST_EBADPERF;
596+
case MPTCP_RST_EMIDDLEBOX:
597+
return SK_RST_REASON_MPTCP_RST_EMIDDLEBOX;
598+
default:
599+
/* It should not happen, or else errors may occur
600+
* in MPTCP layer
601+
*/
602+
return SK_RST_REASON_ERROR;
603+
}
604+
}
605+
579606
static inline u64
580607
mptcp_subflow_get_map_offset(const struct mptcp_subflow_context *subflow)
581608
{

net/mptcp/subflow.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,13 @@ static struct dst_entry *subflow_v4_route_req(const struct sock *sk,
305305
return dst;
306306

307307
dst_release(dst);
308-
if (!req->syncookie)
309-
tcp_request_sock_ops.send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED);
308+
if (!req->syncookie) {
309+
struct mptcp_ext *mpext = mptcp_get_ext(skb);
310+
enum sk_rst_reason reason;
311+
312+
reason = sk_rst_convert_mptcp_reason(mpext->reset_reason);
313+
tcp_request_sock_ops.send_reset(sk, skb, reason);
314+
}
310315
return NULL;
311316
}
312317

@@ -372,8 +377,13 @@ static struct dst_entry *subflow_v6_route_req(const struct sock *sk,
372377
return dst;
373378

374379
dst_release(dst);
375-
if (!req->syncookie)
376-
tcp6_request_sock_ops.send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED);
380+
if (!req->syncookie) {
381+
struct mptcp_ext *mpext = mptcp_get_ext(skb);
382+
enum sk_rst_reason reason;
383+
384+
reason = sk_rst_convert_mptcp_reason(mpext->reset_reason);
385+
tcp6_request_sock_ops.send_reset(sk, skb, reason);
386+
}
377387
return NULL;
378388
}
379389
#endif
@@ -778,6 +788,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
778788
struct mptcp_subflow_request_sock *subflow_req;
779789
struct mptcp_options_received mp_opt;
780790
bool fallback, fallback_is_fatal;
791+
enum sk_rst_reason reason;
781792
struct mptcp_sock *owner;
782793
struct sock *child;
783794

@@ -903,7 +914,8 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
903914
tcp_rsk(req)->drop_req = true;
904915
inet_csk_prepare_for_destroy_sock(child);
905916
tcp_done(child);
906-
req->rsk_ops->send_reset(sk, skb, SK_RST_REASON_NOT_SPECIFIED);
917+
reason = sk_rst_convert_mptcp_reason(mptcp_get_ext(skb)->reset_reason);
918+
req->rsk_ops->send_reset(sk, skb, reason);
907919

908920
/* The last child reference will be released by the caller */
909921
return child;

0 commit comments

Comments
 (0)