* [MPTCP][PATCH v4 mptcp-next 0/5] MP_FAIL support
@ 2021-07-14 10:41 Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 1/5] mptcp: MP_FAIL suboption sending Geliang Tang
0 siblings, 1 reply; 7+ messages in thread
From: Geliang Tang @ 2021-07-14 10:41 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
v4:
- just deal with the multiple subflows case, put the single subflow
case into the new 'infinite mapping' part.
v3:
- respond with MP_FAIL
- add single subflow check
- add infinite mapping sending and receiving
- export/20210626T054902
v2:
- MP_FAIL logic:
* Peer B send a DSS to peer A, and the data has been modify by the
middleboxes, then peer A detects the bad checksum.
* In the multiple subflows case, peer A sends MP_FAIL+RST back to peer B,
and peer A discards the data following the bad data sequence number. Peer
B receives this MP_FAIL+RST, and close this subflow.
* In the single subflow case, using the simple implementation, peer A
sends MP_FAIL back to peer B, and peer A fallback to a regular TCP. Peer
B receives this MP_FAIL, and fallback to a regular TCP.
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/52
Geliang Tang (5):
mptcp: MP_FAIL suboption sending
mptcp: MP_FAIL suboption receiving
mptcp: send out MP_FAIL when data checksum fail
mptcp: add the mibs for MP_FAIL
selftests: mptcp: add MP_FAIL mibs check
include/net/mptcp.h | 5 +-
net/mptcp/mib.c | 2 +
net/mptcp/mib.h | 2 +
net/mptcp/options.c | 78 ++++++++++++++++++-
net/mptcp/pm.c | 8 ++
net/mptcp/protocol.h | 19 +++++
net/mptcp/subflow.c | 16 ++++
.../testing/selftests/net/mptcp/mptcp_join.sh | 38 +++++++++
8 files changed, 163 insertions(+), 5 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [MPTCP][PATCH v4 mptcp-next 1/5] mptcp: MP_FAIL suboption sending
2021-07-14 10:41 [MPTCP][PATCH v4 mptcp-next 0/5] MP_FAIL support Geliang Tang
@ 2021-07-14 10:41 ` Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 2/5] mptcp: MP_FAIL suboption receiving Geliang Tang
0 siblings, 1 reply; 7+ messages in thread
From: Geliang Tang @ 2021-07-14 10:41 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
This patch added the MP_FAIL suboption sending support.
Add a new flag named send_mp_fail in struct mptcp_subflow_context. If
this flag is set, send out MP_FAIL suboption.
Add a new member fail_seq in struct mptcp_out_options to save the data
sequence number to put into the MP_FAIL suboption.
An MP_FAIL option could be included in a RST or on the subflow-level
ACK.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
include/net/mptcp.h | 5 +++-
net/mptcp/options.c | 61 +++++++++++++++++++++++++++++++++++++++++---
net/mptcp/protocol.h | 3 +++
3 files changed, 64 insertions(+), 5 deletions(-)
diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index 8b5af683a818..66fb9a51ead8 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -60,7 +60,10 @@ struct mptcp_out_options {
u16 suboptions;
u64 sndr_key;
u64 rcvr_key;
- u64 ahmac;
+ union {
+ u64 ahmac;
+ u64 fail_seq;
+ };
struct mptcp_addr_info addr;
struct mptcp_rm_list rm_list;
u8 join_id;
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 4452455aef7f..db7d0ad417d0 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -755,7 +755,7 @@ static bool mptcp_established_options_mp_prio(struct sock *sk,
return true;
}
-static noinline void mptcp_established_options_rst(struct sock *sk, struct sk_buff *skb,
+static noinline bool mptcp_established_options_rst(struct sock *sk, struct sk_buff *skb,
unsigned int *size,
unsigned int remaining,
struct mptcp_out_options *opts)
@@ -763,12 +763,36 @@ static noinline void mptcp_established_options_rst(struct sock *sk, struct sk_bu
const struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
if (remaining < TCPOLEN_MPTCP_RST)
- return;
+ return false;
*size = TCPOLEN_MPTCP_RST;
opts->suboptions |= OPTION_MPTCP_RST;
opts->reset_transient = subflow->reset_transient;
opts->reset_reason = subflow->reset_reason;
+
+ return true;
+}
+
+static bool mptcp_established_options_mp_fail(struct sock *sk,
+ unsigned int *size,
+ unsigned int remaining,
+ struct mptcp_out_options *opts)
+{
+ struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+
+ if (!subflow->send_mp_fail)
+ return false;
+
+ if (remaining < TCPOLEN_MPTCP_FAIL)
+ return false;
+
+ *size = TCPOLEN_MPTCP_FAIL;
+ opts->suboptions |= OPTION_MPTCP_FAIL;
+ opts->fail_seq = subflow->map_seq;
+
+ pr_debug("MP_FAIL fail_seq=%llu", opts->fail_seq);
+
+ return true;
}
bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
@@ -787,15 +811,30 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
return false;
if (unlikely(skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST)) {
- mptcp_established_options_rst(sk, skb, size, remaining, opts);
+ if (mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts)) {
+ *size += opt_size;
+ remaining -= opt_size;
+ }
+ if (mptcp_established_options_rst(sk, skb, &opt_size, remaining, opts)) {
+ *size += opt_size;
+ remaining -= opt_size;
+ }
return true;
}
snd_data_fin = mptcp_data_fin_enabled(msk);
if (mptcp_established_options_mp(sk, skb, snd_data_fin, &opt_size, remaining, opts))
ret = true;
- else if (mptcp_established_options_dss(sk, skb, snd_data_fin, &opt_size, remaining, opts))
+ else if (mptcp_established_options_dss(sk, skb, snd_data_fin, &opt_size, remaining, opts)) {
ret = true;
+ if (opts->ext_copy.use_ack) {
+ if (mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts)) {
+ *size += opt_size;
+ remaining -= opt_size;
+ ret = true;
+ }
+ }
+ }
/* we reserved enough space for the above options, and exceeding the
* TCP option space would be fatal
@@ -1341,6 +1380,20 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
opts->backup, TCPOPT_NOP);
}
+ if (OPTION_MPTCP_FAIL & opts->suboptions) {
+ const struct sock *ssk = (const struct sock *)tp;
+ struct mptcp_subflow_context *subflow;
+
+ subflow = mptcp_subflow_ctx(ssk);
+ subflow->send_mp_fail = 0;
+
+ *ptr++ = mptcp_option(MPTCPOPT_MP_FAIL,
+ TCPOLEN_MPTCP_FAIL,
+ 0, 0);
+ put_unaligned_be64(opts->fail_seq, ptr);
+ ptr += 2;
+ }
+
if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
*ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
TCPOLEN_MPTCP_MPJ_SYN,
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 0f0c026c5f8b..5a38d850f564 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -26,6 +26,7 @@
#define OPTION_MPTCP_FASTCLOSE BIT(8)
#define OPTION_MPTCP_PRIO BIT(9)
#define OPTION_MPTCP_RST BIT(10)
+#define OPTION_MPTCP_FAIL BIT(11)
/* MPTCP option subtypes */
#define MPTCPOPT_MP_CAPABLE 0
@@ -67,6 +68,7 @@
#define TCPOLEN_MPTCP_PRIO_ALIGN 4
#define TCPOLEN_MPTCP_FASTCLOSE 12
#define TCPOLEN_MPTCP_RST 4
+#define TCPOLEN_MPTCP_FAIL 12
#define TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM (TCPOLEN_MPTCP_DSS_CHECKSUM + TCPOLEN_MPTCP_MPC_ACK_DATA)
@@ -425,6 +427,7 @@ struct mptcp_subflow_context {
mpc_map : 1,
backup : 1,
send_mp_prio : 1,
+ send_mp_fail : 1,
rx_eof : 1,
can_ack : 1, /* only after processing the remote a key */
disposable : 1; /* ctx can be free at ulp release time */
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [MPTCP][PATCH v4 mptcp-next 2/5] mptcp: MP_FAIL suboption receiving
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 1/5] mptcp: MP_FAIL suboption sending Geliang Tang
@ 2021-07-14 10:41 ` Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fail Geliang Tang
0 siblings, 1 reply; 7+ messages in thread
From: Geliang Tang @ 2021-07-14 10:41 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
This patch added handling for receiving MP_FAIL suboption.
Add a new members mp_fail and fail_seq in struct mptcp_options_received.
When MP_FAIL suboption is received, set mp_fail to 1 and save the sequence
number to fail_seq.
Then invoke mptcp_pm_mp_fail_received to deal with the MP_FAIL suboption.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
net/mptcp/options.c | 16 ++++++++++++++++
net/mptcp/pm.c | 7 +++++++
net/mptcp/protocol.h | 3 +++
3 files changed, 26 insertions(+)
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index db7d0ad417d0..ed9a4a645459 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -336,6 +336,16 @@ static void mptcp_parse_option(const struct sk_buff *skb,
mp_opt->reset_reason = *ptr;
break;
+ case MPTCPOPT_MP_FAIL:
+ if (opsize != TCPOLEN_MPTCP_FAIL)
+ break;
+
+ ptr += 2;
+ mp_opt->mp_fail = 1;
+ mp_opt->fail_seq = get_unaligned_be64(ptr);
+ pr_debug("MP_FAIL: data_seq=%llu", mp_opt->fail_seq);
+ break;
+
default:
break;
}
@@ -364,6 +374,7 @@ void mptcp_get_options(const struct sock *sk,
mp_opt->reset = 0;
mp_opt->csum_reqd = READ_ONCE(msk->csum_enabled);
mp_opt->deny_join_id0 = 0;
+ mp_opt->mp_fail = 0;
length = (th->doff * 4) - sizeof(struct tcphdr);
ptr = (const unsigned char *)(th + 1);
@@ -1137,6 +1148,11 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
mp_opt.mp_prio = 0;
}
+ if (mp_opt.mp_fail) {
+ mptcp_pm_mp_fail_received(sk, mp_opt.fail_seq);
+ mp_opt.mp_fail = 0;
+ }
+
if (mp_opt.reset) {
subflow->reset_seen = 1;
subflow->reset_reason = mp_opt.reset_reason;
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 639271e09604..d4c19420194a 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -247,6 +247,13 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup)
mptcp_event(MPTCP_EVENT_SUB_PRIORITY, mptcp_sk(subflow->conn), sk, GFP_ATOMIC);
}
+void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq)
+{
+ struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+
+ pr_debug("map_seq=%llu fail_seq=%llu", subflow->map_seq, fail_seq);
+}
+
/* path manager helpers */
bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 5a38d850f564..20f8faf0543b 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -139,6 +139,7 @@ struct mptcp_options_received {
add_addr : 1,
rm_addr : 1,
mp_prio : 1,
+ mp_fail : 1,
echo : 1,
csum_reqd : 1,
backup : 1,
@@ -160,6 +161,7 @@ struct mptcp_options_received {
u64 ahmac;
u8 reset_reason:4;
u8 reset_transient:1;
+ u64 fail_seq;
};
static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field)
@@ -711,6 +713,7 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup);
int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
struct mptcp_addr_info *addr,
u8 bkup);
+void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq);
void mptcp_pm_free_anno_list(struct mptcp_sock *msk);
bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk);
struct mptcp_pm_add_entry *
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [MPTCP][PATCH v4 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fail
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 2/5] mptcp: MP_FAIL suboption receiving Geliang Tang
@ 2021-07-14 10:41 ` Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 4/5] mptcp: add the mibs for MP_FAIL Geliang Tang
2021-07-15 1:46 ` [MPTCP][PATCH v4 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fail Mat Martineau
0 siblings, 2 replies; 7+ messages in thread
From: Geliang Tang @ 2021-07-14 10:41 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
When a bad checksum is detected, set the send_mp_fail flag to send out
the MP_FAIL option.
Add a new function mptcp_has_another_subflow() to check whether there's
only a single subflow.
When multiple subflows are in use, close the affected subflow with a RST
that includes an MP_FAIL option and discard the data with the bad
checksum.
Set the sk_state of the subsocket to TCP_CLOSE, then the flag
MPTCP_WORK_CLOSE_SUBFLOW will be set in subflow_sched_work_if_closed,
and the subflow will be closed.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
net/mptcp/protocol.h | 13 +++++++++++++
net/mptcp/subflow.c | 15 +++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 20f8faf0543b..260920d26935 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -601,6 +601,19 @@ static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
}
+static inline bool mptcp_has_another_subflow(struct sock *ssk)
+{
+ struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk), *tmp;
+ struct mptcp_sock *msk = mptcp_sk(subflow->conn);
+
+ mptcp_for_each_subflow(msk, tmp) {
+ if (tmp != subflow)
+ return true;
+ }
+
+ return false;
+}
+
void __init mptcp_proto_init(void);
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
int __init mptcp_proto_v6_init(void);
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 966f777d35ce..11a719fad718 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -908,6 +908,7 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff *
csum = csum_partial(&header, sizeof(header), subflow->map_data_csum);
if (unlikely(csum_fold(csum))) {
MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DATACSUMERR);
+ subflow->send_mp_fail = 1;
return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY;
}
@@ -1155,6 +1156,20 @@ static bool subflow_check_data_avail(struct sock *ssk)
fallback:
/* RFC 8684 section 3.7. */
+ if (subflow->send_mp_fail) {
+ if (mptcp_has_another_subflow(ssk)) {
+ ssk->sk_err = EBADMSG;
+ tcp_set_state(ssk, TCP_CLOSE);
+ subflow->reset_transient = 0;
+ subflow->reset_reason = MPTCP_RST_EMIDDLEBOX;
+ tcp_send_active_reset(ssk, GFP_ATOMIC);
+ while ((skb = skb_peek(&ssk->sk_receive_queue)))
+ sk_eat_skb(ssk, skb);
+ WRITE_ONCE(subflow->data_avail, 0);
+ return true;
+ }
+ }
+
if (subflow->mp_join || subflow->fully_established) {
/* fatal protocol error, close the socket.
* subflow_error_report() will introduce the appropriate barriers
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [MPTCP][PATCH v4 mptcp-next 4/5] mptcp: add the mibs for MP_FAIL
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fail Geliang Tang
@ 2021-07-14 10:41 ` Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 5/5] selftests: mptcp: add MP_FAIL mibs check Geliang Tang
2021-07-15 1:46 ` [MPTCP][PATCH v4 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fail Mat Martineau
1 sibling, 1 reply; 7+ messages in thread
From: Geliang Tang @ 2021-07-14 10:41 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
This patch added the mibs for MP_FAIL: MPTCP_MIB_MPFAILTX and
MPTCP_MIB_MPFAILRX.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
net/mptcp/mib.c | 2 ++
net/mptcp/mib.h | 2 ++
net/mptcp/options.c | 1 +
net/mptcp/pm.c | 1 +
net/mptcp/subflow.c | 1 +
5 files changed, 7 insertions(+)
diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c
index ff2cc0e3273d..44d342c90121 100644
--- a/net/mptcp/mib.c
+++ b/net/mptcp/mib.c
@@ -44,6 +44,8 @@ static const struct snmp_mib mptcp_snmp_list[] = {
SNMP_MIB_ITEM("RmSubflow", MPTCP_MIB_RMSUBFLOW),
SNMP_MIB_ITEM("MPPrioTx", MPTCP_MIB_MPPRIOTX),
SNMP_MIB_ITEM("MPPrioRx", MPTCP_MIB_MPPRIORX),
+ SNMP_MIB_ITEM("MPFailTx", MPTCP_MIB_MPFAILTX),
+ SNMP_MIB_ITEM("MPFailRx", MPTCP_MIB_MPFAILRX),
SNMP_MIB_ITEM("RcvPruned", MPTCP_MIB_RCVPRUNED),
SNMP_MIB_SENTINEL
};
diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h
index 0663cb12b448..0db62d5d4e38 100644
--- a/net/mptcp/mib.h
+++ b/net/mptcp/mib.h
@@ -37,6 +37,8 @@ enum linux_mptcp_mib_field {
MPTCP_MIB_RMSUBFLOW, /* Remove a subflow */
MPTCP_MIB_MPPRIOTX, /* Transmit a MP_PRIO */
MPTCP_MIB_MPPRIORX, /* Received a MP_PRIO */
+ MPTCP_MIB_MPFAILTX, /* Transmit a MP_FAIL */
+ MPTCP_MIB_MPFAILRX, /* Received a MP_FAIL */
MPTCP_MIB_RCVPRUNED, /* Incoming packet dropped due to memory limit */
__MPTCP_MIB_MAX
};
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index ed9a4a645459..9a2fa52c0bf0 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -1150,6 +1150,7 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
if (mp_opt.mp_fail) {
mptcp_pm_mp_fail_received(sk, mp_opt.fail_seq);
+ MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPFAILRX);
mp_opt.mp_fail = 0;
}
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index d4c19420194a..ccabe3b9e5ee 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -9,6 +9,7 @@
#include <net/tcp.h>
#include <net/mptcp.h>
#include "protocol.h"
+#include "mib.h"
/* path manager command handlers */
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 11a719fad718..5046ae431206 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -909,6 +909,7 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff *
if (unlikely(csum_fold(csum))) {
MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DATACSUMERR);
subflow->send_mp_fail = 1;
+ MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPFAILTX);
return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [MPTCP][PATCH v4 mptcp-next 5/5] selftests: mptcp: add MP_FAIL mibs check
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 4/5] mptcp: add the mibs for MP_FAIL Geliang Tang
@ 2021-07-14 10:41 ` Geliang Tang
0 siblings, 0 replies; 7+ messages in thread
From: Geliang Tang @ 2021-07-14 10:41 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
This patch added a function chk_fail_nr to check the mibs for MP_FAIL.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
.../testing/selftests/net/mptcp/mptcp_join.sh | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index f02f4de2f3a0..426d99c17512 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -541,6 +541,43 @@ chk_csum_nr()
fi
}
+chk_fail_nr()
+{
+ local mp_fail_nr_tx=$1
+ local mp_fail_nr_rx=$2
+ local count
+ local dump_stats
+
+ printf "%-39s %s" " " "ftx"
+ count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}'`
+ [ -z "$count" ] && count=0
+ if [ "$count" != "$mp_fail_nr_tx" ]; then
+ echo "[fail] got $count MP_FAIL[s] TX expected $mp_fail_nr_tx"
+ ret=1
+ dump_stats=1
+ else
+ echo -n "[ ok ]"
+ fi
+
+ echo -n " - frx "
+ count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}'`
+ [ -z "$count" ] && count=0
+ if [ "$count" != "$mp_fail_nr_rx" ]; then
+ echo "[fail] got $count MP_FAIL[s] RX expected $mp_fail_nr_rx"
+ ret=1
+ dump_stats=1
+ else
+ echo "[ ok ]"
+ fi
+
+ if [ "${dump_stats}" = 1 ]; then
+ echo Server ns stats
+ ip netns exec $ns1 nstat -as | grep MPTcp
+ echo Client ns stats
+ ip netns exec $ns2 nstat -as | grep MPTcp
+ fi
+}
+
chk_join_nr()
{
local msg="$1"
@@ -590,6 +627,7 @@ chk_join_nr()
fi
if [ $checksum -eq 1 ]; then
chk_csum_nr
+ chk_fail_nr 0 0
fi
}
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [MPTCP][PATCH v4 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fail
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fail Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 4/5] mptcp: add the mibs for MP_FAIL Geliang Tang
@ 2021-07-15 1:46 ` Mat Martineau
1 sibling, 0 replies; 7+ messages in thread
From: Mat Martineau @ 2021-07-15 1:46 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
On Wed, 14 Jul 2021, Geliang Tang wrote:
> When a bad checksum is detected, set the send_mp_fail flag to send out
> the MP_FAIL option.
>
> Add a new function mptcp_has_another_subflow() to check whether there's
> only a single subflow.
>
> When multiple subflows are in use, close the affected subflow with a RST
> that includes an MP_FAIL option and discard the data with the bad
> checksum.
>
> Set the sk_state of the subsocket to TCP_CLOSE, then the flag
> MPTCP_WORK_CLOSE_SUBFLOW will be set in subflow_sched_work_if_closed,
> and the subflow will be closed.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
> net/mptcp/protocol.h | 13 +++++++++++++
> net/mptcp/subflow.c | 15 +++++++++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 20f8faf0543b..260920d26935 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -601,6 +601,19 @@ static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
> inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
> }
>
> +static inline bool mptcp_has_another_subflow(struct sock *ssk)
> +{
> + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk), *tmp;
> + struct mptcp_sock *msk = mptcp_sk(subflow->conn);
> +
> + mptcp_for_each_subflow(msk, tmp) {
> + if (tmp != subflow)
> + return true;
> + }
> +
> + return false;
> +}
> +
> void __init mptcp_proto_init(void);
> #if IS_ENABLED(CONFIG_MPTCP_IPV6)
> int __init mptcp_proto_v6_init(void);
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 966f777d35ce..11a719fad718 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -908,6 +908,7 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff *
> csum = csum_partial(&header, sizeof(header), subflow->map_data_csum);
> if (unlikely(csum_fold(csum))) {
> MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DATACSUMERR);
> + subflow->send_mp_fail = 1;
> return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY;
> }
>
> @@ -1155,6 +1156,20 @@ static bool subflow_check_data_avail(struct sock *ssk)
>
> fallback:
> /* RFC 8684 section 3.7. */
> + if (subflow->send_mp_fail) {
> + if (mptcp_has_another_subflow(ssk)) {
> + ssk->sk_err = EBADMSG;
> + tcp_set_state(ssk, TCP_CLOSE);
> + subflow->reset_transient = 0;
> + subflow->reset_reason = MPTCP_RST_EMIDDLEBOX;
> + tcp_send_active_reset(ssk, GFP_ATOMIC);
> + while ((skb = skb_peek(&ssk->sk_receive_queue)))
> + sk_eat_skb(ssk, skb);
> + WRITE_ONCE(subflow->data_avail, 0);
> + return true;
> + }
> + }
> +
The above handles the multiple-subflow case...
> if (subflow->mp_join || subflow->fully_established) {
> /* fatal protocol error, close the socket.
> * subflow_error_report() will introduce the appropriate barriers
...and since the infinite-mapping code and other single-subflow logic will
be in a later patch set, should the single-subflow case be temporarily
handled here by sending MP_TCPRST instead of MP_FAIL?
--
Mat Martineau
Intel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-07-15 1:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 10:41 [MPTCP][PATCH v4 mptcp-next 0/5] MP_FAIL support Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 1/5] mptcp: MP_FAIL suboption sending Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 2/5] mptcp: MP_FAIL suboption receiving Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fail Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 4/5] mptcp: add the mibs for MP_FAIL Geliang Tang
2021-07-14 10:41 ` [MPTCP][PATCH v4 mptcp-next 5/5] selftests: mptcp: add MP_FAIL mibs check Geliang Tang
2021-07-15 1:46 ` [MPTCP][PATCH v4 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fail Mat Martineau
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).