pm netlink: followup and fixes
Subsystems (3)
Paolo Abeni
v2 cover pm netlink: followup and fixes
This series bring some fixes and improvement related to the PM netlink, specifically:
- renames 4th_ack subflow field to 'fully_established':
this is hopefully more accurate
- implements support to enforce the maximum number of subflows per msk
- implements MP_JOIN 3rd ack retransmission and 4th ack delivery:
this [ab]use the TCP delack timer. I personally think the idea is nice and avoids changes to the core TCP stack, but I guess it could be disputed
- more accurare 'fully established' accounting as per RFC
- drop the msk level 'fully_established' field, as we can use the first subflow status without additional locking instead. This simplify core PM event handling
- adds more MP_JOIN related mib counters
- update the PM netlink to enforce a configurable maximum number of subflows per msk
- extend the pm netlink self-tests to check the above APIs
- uses amost all the above to fix the currently disable mp join self-tests and re-enable them
Note: mp join self tests are still unstable, e.g. can fail randomly, due to an old race between mptcp_token_update_accept() and mptcp_token_get_sock(): e.g. a client may legitly try to create a subflow after that the first one is fully established but before the server has accepted the initial socket:mptcp_token_get_sock() will fail and MP_JOIN will fail too, incrementing MPTCP_MIB_JOINNOTOKEN.
I think the above should be addressed in a separate series - otherwise this one will be too big.
The up2date branch for this series (v2) is available here:
https://github.com/pabeni/mptcp/tree/mptcp_net-next_part3_7
v1 -> v2:
- comments and readability changes in patch 04
include/uapi/linux/mptcp.h | 23 ++- net/mptcp/diag.c | 4 net/mptcp/mib.c | 3 net/mptcp/mib.h | 3 net/mptcp/options.c | 141 +++++++++++++++++------- net/mptcp/pm.c | 35 ++++- net/mptcp/pm_netlink.c | 93 +++++++++++---- net/mptcp/protocol.c | 23 ++- net/mptcp/protocol.h | 8 + net/mptcp/subflow.c | 9 + tools/testing/selftests/net/mptcp/mptcp_join.sh | 100 +++++++++++++---- tools/testing/selftests/net/mptcp/pm_netlink.sh | 17 ++ tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 46 ++++--- 13 files changed, 364 insertions(+), 141 deletions(-)
Paolo Abeni
PATCH v2 1/12 mptcp: rename fourth ack field
The name is misleading, it actually track the 'fully established' status.
--- net/mptcp/options.c | 18 +++++++++--------- net/mptcp/protocol.h | 2 +- net/mptcp/subflow.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)
net/mptcp/options.c +9 -9
@@ -259,11 +259,11 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb,struct mptcp_ext *mpext;unsigned int data_len; -pr_debug ("subflow=%p fourth_ack=%d seq=%x:%x remaining=%d" , subflow, - subflow->fourth_ack, subflow->snd_isn, +pr_debug ("subflow=%p fully established=%d seq=%x:%x remaining=%d" , + subflow, subflow->fully_established, subflow->snd_isn, skb ?TCP_SKB_CB (skb)->seq :0 , remaining); -if (subflow->mp_capable && !subflow->fourth_ack && skb && +if (subflow->mp_capable && !subflow->fully_established && skb && subflow->snd_isn ==TCP_SKB_CB (skb)->seq) {/* When skb is not available, we better over-estimate the * emitted options len. A full DSS option is longer than
@@ -424,19 +424,19 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,return false; } -static bool check_fourth_ack (struct mptcp_subflow_context *subflow, -struct sk_buff *skb, -struct mptcp_options_received *mp_opt) +static bool check_fully_established (struct mptcp_subflow_context *subflow, +struct sk_buff *skb, +struct mptcp_options_received *mp_opt) {/* here we can process OoO, in-window pkts, only in-sequence 4th ack * are relevant */ -if (likely (subflow->fourth_ack || +if (likely (subflow->fully_established ||TCP_SKB_CB (skb)->seq != subflow->ssn_offset +1 ))return true;if (mp_opt->use_ack) - subflow->fourth_ack =1 ; + subflow->fully_established =1 ;if (subflow->can_ack)return true;
@@ -462,7 +462,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,struct mptcp_ext *mpext; mp_opt = &opt_rx->mptcp; -if (!check_fourth_ack (subflow, skb, mp_opt)) +if (!check_fully_established (subflow, skb, mp_opt))return ;if (!mp_opt->dss)
net/mptcp/protocol.h +1 -1
@@ -119,7 +119,7 @@ struct mptcp_subflow_context {u32 map_data_len; u32 request_mptcp : 1, /* send MP_CAPABLE */ mp_capable : 1, /* remote is MPTCP capable */ - fourth_ack : 1, /* send initial DSS */ + fully_established : 1, /* path validated */ conn_finished : 1, map_valid : 1, mpc_map : 1,
net/mptcp/subflow.c +1 -1
@@ -794,7 +794,7 @@ static void subflow_ulp_clone(const struct request_sock *req, new_ctx->tcp_state_change = old_ctx->tcp_state_change; new_ctx->tcp_write_space = old_ctx->tcp_write_space; new_ctx->mp_capable =1 ; - new_ctx->fourth_ack = subflow_req->remote_key_valid; + new_ctx->fully_established = subflow_req->remote_key_valid; new_ctx->can_ack = subflow_req->remote_key_valid; new_ctx->remote_key = subflow_req->remote_key; new_ctx->local_key = subflow_req->local_key;
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 2/12 Squash-to: "mptcp: Add ADD_ADDR handling"
In reply to Paolo AbeniNeed a new hook to limit the number of per msk subflows
Also add new fields to properly account the total
subflows number
--- net/mptcp/pm.c | 9 ++++++++- net/mptcp/protocol.h | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-)
net/mptcp/pm.c +8 -1
@@ -39,6 +39,12 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, int server_side)WRITE_ONCE (pm->server_side, server_side); } +bool mptcp_pm_allow_new_subflow (struct mptcp_sock *msk) +{ +pr_debug ("msk=%p" , msk); +return false; +} +void mptcp_pm_fully_established (struct mptcp_sock *msk) {pr_debug ("msk=%p" , msk);
@@ -88,10 +94,11 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) msk->pm.add_addr_signaled =0 ; msk->pm.add_addr_accepted =0 ; msk->pm.local_addr_used =0 ; + msk->pm.subflows =0 ;WRITE_ONCE (msk->pm.work_pending, false);WRITE_ONCE (msk->pm.addr_signal, false); -WRITE_ONCE (msk->pm.fully_established, false);WRITE_ONCE (msk->pm.accept_addr, false); +WRITE_ONCE (msk->pm.accept_subflow, false); msk->pm.status =MPTCP_PM_IDLE ;spin_lock_init (&msk->pm.lock);
net/mptcp/protocol.h +4 -1
@@ -105,15 +105,17 @@ struct mptcp_pm_data {bool addr_signal;bool server_side; -bool fully_established;bool work_pending;bool accept_addr; +bool accept_subflow;u8 add_addr_signaled;u8 add_addr_accepted;u8 local_addr_used; +u8 subflows;u8 add_addr_signal_max;u8 add_addr_accept_max;u8 local_addr_max; +u8 subflows_max;enum mptcp_pm_status status;struct work_struct work;
@@ -286,6 +288,7 @@ void mptcp_pm_init(void);void mptcp_pm_data_init (struct mptcp_sock *msk);void mptcp_pm_new_connection (struct mptcp_sock *msk,int server_side);void mptcp_pm_fully_established (struct mptcp_sock *msk); +bool mptcp_pm_allow_new_subflow (struct mptcp_sock *msk);void mptcp_pm_connection_closed (struct mptcp_sock *msk);void mptcp_pm_subflow_established (struct mptcp_sock *msk,struct mptcp_subflow_context *subflow);
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 3/12 Squash-to: "mptcp: Add handling of incoming MP_JOIN requests"
In reply to Paolo AbeniSend 4th ack on 3rd acj reception for MP_JOIN pkts and enforce no data packet before 4th ack.
Let the PM limit the number of per msk subflows.
--- net/mptcp/options.c | 56 ++++++++++++++++++++++++++++++++------------ net/mptcp/protocol.c | 7 +++--- net/mptcp/protocol.h | 1 + 3 files changed, 46 insertions(+), 18 deletions(-)
net/mptcp/options.c +41 -15
@@ -553,37 +553,66 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,return false; } -static bool check_fully_established (struct mptcp_subflow_context *subflow, +static bool check_fully_established (struct mptcp_sock *msk,struct sock *sk, +struct mptcp_subflow_context *subflow,struct sk_buff *skb,struct mptcp_options_received *mp_opt) {/* here we can process OoO, in-window pkts, only in-sequence 4th ack -* are relevant +* will make the subflow fully established */ -if (likely (subflow->fully_established || -TCP_SKB_CB (skb)->seq != subflow->ssn_offset +1 )) -return true; +if (likely (subflow->fully_established)) { +/* on passive sockets, check for 3rd ack retransmission +* note that msk is always set by subflow_syn_recv_sock() +* for mp_join subflows +*/ +if (TCP_SKB_CB (skb)->seq == subflow->ssn_offset +1 && +TCP_SKB_CB (skb)->end_seq ==TCP_SKB_CB (skb)->seq && + subflow->mp_join && mp_opt->mp_join && +READ_ONCE (msk->pm.server_side)) +tcp_send_ack (sk); + goto fully_established; + } + +/* we should process OoO packets before the first subflow is fully +* established, but not expected for MP_JOIN subflows +*/ +if (TCP_SKB_CB (skb)->seq != subflow->ssn_offset +1 ) +return subflow->mp_capable;if (mp_opt->use_ack) { +/* subflows are fully established as soon as we get any +* additional ack. +*/ subflow->fully_established =1 ; -if (subflow->mp_join) -mptcp_pm_subflow_established (mptcp_sk (subflow->conn), - subflow); + goto fully_established; } -if (subflow->can_ack) -return true; +WARN_ON_ONCE (subflow->can_ack);/* If the first established packet does not contain MP_CAPABLE + data * then fallback to TCP */ if (!mp_opt->mp_capable) { subflow->mp_capable =0 ; -tcp_sk (mptcp_subflow_tcp_sock (subflow))->is_mptcp =0 ; +tcp_sk (sk)->is_mptcp =0 ;return false; } + + subflow->fully_established =1 ; subflow->remote_key = mp_opt->sndr_key; subflow->can_ack =1 ; + +fully_established: +/* msk can be null for MPC subflow on passive socket */ +if (subflow->pm_notified || !msk) +return true; + + subflow->pm_notified =1 ; +if (subflow->mp_join) +mptcp_pm_subflow_established (msk, subflow); +else +mptcp_pm_fully_established (msk);return true; }
@@ -596,7 +625,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,struct mptcp_ext *mpext; mp_opt = &opt_rx->mptcp; -if (!check_fully_established (subflow, skb, mp_opt)) +if (!check_fully_established (msk, sk, subflow, skb, mp_opt))return ;if (msk && mp_opt->add_addr) {
@@ -654,9 +683,6 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb, } mpext->data_fin = mp_opt->data_fin; - -if (msk) -mptcp_pm_fully_established (msk); }void mptcp_write_options (__be32 *ptr,struct mptcp_out_options *opts)
net/mptcp/protocol.c +4 -3
@@ -1088,9 +1088,10 @@ bool mptcp_finish_join(struct sock *sk)return false; parent_sock =READ_ONCE (parent->sk_socket); -if (parent_sock) { -if (!sk->sk_socket) -mptcp_sock_graft (sk, parent_sock); +if (parent_sock && !sk->sk_socket) { +/* passive connection, attach to msk socket */ +mptcp_sock_graft (sk, parent_sock); +return mptcp_pm_allow_new_subflow (msk); }return true; }
net/mptcp/protocol.h +1 -0
@@ -198,6 +198,7 @@ struct mptcp_subflow_context { mp_capable : 1, /* remote is MPTCP capable */ mp_join : 1, /* remote is JOINing */ fully_established : 1, /* path validated */ + pm_notified : 1, /* PM hook called for established status */ conn_finished : 1, map_valid : 1, mpc_map : 1,
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 4/12 Squash-to: "mptcp: Add handling of outgoing MP_JOIN requests"
In reply to Paolo AbeniSchedule 3rd ack retransmission via delack timer, and clear it on fully established event
v1 -> v2:
- clarified some comments (Mat)
- reordered expression to detect 3rd ack for clarity (Mat)
- dropped duplicate comment (Mat)
--- net/mptcp/options.c | 67 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 14 deletions(-)
net/mptcp/options.c +53 -14
@@ -341,6 +341,38 @@ void mptcp_rcv_synsent(struct sock *sk) } } +/* MP_JOIN client subflow must wait for 4th ack before sending any data: +* TCP can't schedule delack timer before the subflow is fully established. +* MPTCP uses the delack timer to do 3rd ack retransmissions +*/ +static void schedule_3rdack_retransmission (struct sock *sk) +{ +struct inet_connection_sock *icsk =inet_csk (sk); +struct tcp_sock *tp =tcp_sk (sk); +unsigned long timeout; + +/* reschedule with a timeout above RTT, as we must look only for drop */ +if (tp->srtt_us) + timeout = tp->srtt_us <<1 ; +else + timeout =TCP_TIMEOUT_INIT ; + +WARN_ON_ONCE (icsk->icsk_ack.pending &ICSK_ACK_TIMER ); + icsk->icsk_ack.pending |=ICSK_ACK_SCHED |ICSK_ACK_TIMER ; + icsk->icsk_ack.timeout = timeout; +sk_reset_timer (sk, &icsk->icsk_delack_timer, timeout); +} + +static void clear_3rdack_retransmission (struct sock *sk) +{ +struct inet_connection_sock *icsk =inet_csk (sk); + +sk_stop_timer (sk, &icsk->icsk_delack_timer); + icsk->icsk_ack.timeout =0 ; + icsk->icsk_ack.ato =0 ; + icsk->icsk_ack.pending &= ~(ICSK_ACK_SCHED |ICSK_ACK_TIMER ); +} + static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, unsigned int *size, unsigned int remaining,
@@ -350,17 +382,21 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb,struct mptcp_ext *mpext;unsigned int data_len; -pr_debug ("subflow=%p fully established=%d seq=%x:%x remaining=%d" , - subflow, subflow->fully_established, subflow->snd_isn, - skb ?TCP_SKB_CB (skb)->seq :0 , remaining); +/* When skb is not available, we better over-estimate the emitted +* options len. A full DSS option (28 bytes) is longer than +* TCPOLEN_MPTCP_MPC_ACK_DATA(22) or TCPOLEN_MPTCP_MPJ_ACK(24), so +* tell the caller to defer the estimate to +* mptcp_established_options_dss(), which will reserve enough space. +*/ +if (!skb) +return false; -if (subflow->mp_capable && !subflow->fully_established && skb && - subflow->snd_isn ==TCP_SKB_CB (skb)->seq) { -/* When skb is not available, we better over-estimate the -* emitted options len. A full DSS option is longer than -* TCPOLEN_MPTCP_MPC_ACK_DATA, so let's the caller try to fit -* that. -*/ +/* MPC/MPJ needed only on 3rd ack packet */ +if (subflow->fully_established || + subflow->snd_isn !=TCP_SKB_CB (skb)->seq) +return false; + +if (subflow->mp_capable) { mpext =mptcp_get_ext (skb); data_len = mpext ? mpext->data_len :0 ;
@@ -388,12 +424,13 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, data_len);return true; - }else if (subflow->mp_join && !subflow->fourth_ack) { + }else if (subflow->mp_join) { opts->suboptions =OPTION_MPTCP_MPJ_ACK ;memcpy (opts->hmac, subflow->hmac,MPTCPOPT_HMAC_LEN ); *size =TCPOLEN_MPTCP_MPJ_ACK ; - subflow->fourth_ack =1 ;pr_debug ("subflow=%p" , subflow); + +schedule_3rdack_retransmission (sk);return true; }return false;
@@ -633,10 +670,12 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk,return true; subflow->pm_notified =1 ; -if (subflow->mp_join) +if (subflow->mp_join) { +clear_3rdack_retransmission (sk);mptcp_pm_subflow_established (msk, subflow); -else + }else {mptcp_pm_fully_established (msk); + }return true; }
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 5/12 Squash-to: "mptcp: Implement path manager interface commands"
In reply to Paolo AbeniAdapt the mptcp_pm_fully_established() hook to the new call site. Additionally avoid useless work if we don't need to announce any address /create any subflows
--- net/mptcp/pm.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
net/mptcp/pm.c +20 -6
@@ -45,9 +45,23 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, int server_side)bool mptcp_pm_allow_new_subflow (struct mptcp_sock *msk) { -pr_debug ("msk=%p" , msk); +struct mptcp_pm_data *pm = &msk->pm; +int ret; -return false; +pr_debug ("msk=%p subflows=%d max=%d allow=%d" , msk, pm->subflows, + pm->subflows_max,READ_ONCE (pm->accept_subflow)); + +/* try to avoid acquiring the lock below */ +if (!READ_ONCE (pm->accept_subflow)) +return false; + +spin_lock_bh (&pm->lock); + ret = pm->subflows < pm->subflows_max; +if (ret && ++pm->subflows == pm->subflows_max) +WRITE_ONCE (pm->accept_subflow, false); +spin_unlock_bh (&pm->lock); + +return ret; } static bool mptcp_pm_schedule_work(struct mptcp_sock *msk,
@@ -71,13 +85,13 @@ void mptcp_pm_fully_established(struct mptcp_sock *msk)pr_debug ("msk=%p" , msk);/* try to avoid acquiring the lock below */ -if (READ_ONCE (pm->fully_established)) +if (!READ_ONCE (pm->work_pending))return ;spin_lock_bh (&pm->lock); -if (!READ_ONCE (pm->fully_established) && -mptcp_pm_schedule_work (msk,MPTCP_PM_ESTABLISHED )) -WRITE_ONCE (pm->fully_established, true); + +if (READ_ONCE (pm->work_pending)) +mptcp_pm_schedule_work (msk,MPTCP_PM_ESTABLISHED );spin_unlock_bh (&pm->lock); }
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 6/12 Squash-to: "mptcp: allow dumping subflow context to userspace"
In reply to Paolo Abenifix after field name change.
Additionally rename the exposed uAPI flags to be more consistent
--- include/uapi/linux/mptcp.h | 18 +++++++++--------- net/mptcp/diag.c | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-)
include/uapi/linux/mptcp.h +9 -9
@@ -4,15 +4,15 @@#include <linux/types.h> -#define MPTCP_SUBFLOW_FLAG_MCAP_REM BIT(0) -#define MPTCP_SUBFLOW_FLAG_MCAP_LOC BIT(1) -#define MPTCP_SUBFLOW_FLAG_JOIN_REM BIT(2) -#define MPTCP_SUBFLOW_FLAG_JOIN_LOC BIT(3) -#define MPTCP_SUBFLOW_FLAG_BKUP_REM BIT(4) -#define MPTCP_SUBFLOW_FLAG_BKUP_LOC BIT(5) -#define MPTCP_SUBFLOW_FLAG_4THACK BIT(6) -#define MPTCP_SUBFLOW_FLAG_CONNECTED BIT(7) -#define MPTCP_SUBFLOW_FLAG_MAPVALID BIT(8) +#define MPTCP_SUBFLOW_FLAG_MCAP_REM BIT(0) +#define MPTCP_SUBFLOW_FLAG_MCAP_LOC BIT(1) +#define MPTCP_SUBFLOW_FLAG_JOIN_REM BIT(2) +#define MPTCP_SUBFLOW_FLAG_JOIN_LOC BIT(3) +#define MPTCP_SUBFLOW_FLAG_BKUP_REM BIT(4) +#define MPTCP_SUBFLOW_FLAG_BKUP_LOC BIT(5) +#define MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED BIT(6) +#define MPTCP_SUBFLOW_FLAG_CONNECTED BIT(7) +#define MPTCP_SUBFLOW_FLAG_MAPVALID BIT(8)enum {MPTCP_SUBFLOW_ATTR_UNSPEC ,
net/mptcp/diag.c +2 -2
@@ -43,8 +43,8 @@ static int subflow_get_info(const struct sock *sk, struct sk_buff *skb) flags |=MPTCP_SUBFLOW_FLAG_BKUP_REM ;if (sf->request_bkup) flags |=MPTCP_SUBFLOW_FLAG_BKUP_LOC ; -if (sf->fourth_ack) - flags |=MPTCP_SUBFLOW_FLAG_4THACK ; +if (sf->fully_established) + flags |=MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED ;if (sf->conn_finished) flags |=MPTCP_SUBFLOW_FLAG_CONNECTED ;if (sf->map_valid)
Signature · 1 line
2.21.1
Matthieu Baerts
[MPTCP] Re: [PATCH v2 6/12] Squash-to: "mptcp: allow dumping subflow context to userspace"
Hi Davide,
Quoted 3 lines · Paolo Abeni
fix after field name change.
Additionally rename the exposed uAPI flags to be more consistent
[...]
net/mptcp/diag.c static int subflow_get_info(const struct sock *sk, struct sk_buff *skb) · line 47
Quoted 12 lines
net/mptcp/diag.c +2
-2@@ -43,8 +43,8 @@ static int subflow_get_info(const struct sock *sk, struct sk_buff *skb) flags |=MPTCP_SUBFLOW_FLAG_BKUP_REM ;if (sf->request_bkup) flags |=MPTCP_SUBFLOW_FLAG_BKUP_LOC ; -if (sf->fourth_ack) - flags |=MPTCP_SUBFLOW_FLAG_4THACK ; +if (sf->fully_established) + flags |=MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED ;
I guess you will have to do some changes on your side in ss code ;)
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
Paolo Abeni
PATCH v2 7/12 Squash-to: "mptcp: add MIB counter infrastructure"
In reply to Paolo AbeniAdd more MP JOIN related counters, will help self-tests
--- net/mptcp/mib.c | 3 +++ net/mptcp/mib.h | 3 +++ 2 files changed, 6 insertions(+)
net/mptcp/mib.c +3 -0
@@ -16,6 +16,9 @@ static const struct snmp_mib mptcp_snmp_list[] = {SNMP_MIB_ITEM ("MPTCPRetrans" ,MPTCP_MIB_RETRANSSEGS ),SNMP_MIB_ITEM ("MPJoinNoTokenFound" ,MPTCP_MIB_JOINNOTOKEN ),SNMP_MIB_ITEM ("MPJoinSynRx" ,MPTCP_MIB_JOINSYNRX ), +SNMP_MIB_ITEM ("MPJoinSynAckRx" ,MPTCP_MIB_JOINSYNACKRX ), +SNMP_MIB_ITEM ("MPJoinSynAckHMacFailure" ,MPTCP_MIB_JOINSYNACKMAC ), +SNMP_MIB_ITEM ("MPJoinAckRx" ,MPTCP_MIB_JOINACKRX ),SNMP_MIB_ITEM ("MPJoinAckHMacFailure" ,MPTCP_MIB_JOINACKMAC ),SNMP_MIB_ITEM ("DSSNotMatching" ,MPTCP_MIB_DSSNOMATCH ), SNMP_MIB_ITEM("InfiniteMapRx", MPTCP_MIB_INFINITEMAPRX),
net/mptcp/mib.h +3 -0
@@ -9,6 +9,9 @@ enum linux_mptcp_mib_field {MPTCP_MIB_RETRANSSEGS ,/* Segments retransmitted at the MPTCP-level */ MPTCP_MIB_JOINNOTOKEN ,/* Received MP_JOIN but the token was not found */ MPTCP_MIB_JOINSYNRX ,/* Received a SYN + MP_JOIN */ +MPTCP_MIB_JOINSYNACKRX ,/* Received a SYN/ACK + MP_JOIN */ +MPTCP_MIB_JOINSYNACKMAC ,/* HMAC was wrong on SYN/ACK + MP_JOIN */ +MPTCP_MIB_JOINACKRX ,/* Received an ACK + MP_JOIN */ MPTCP_MIB_JOINACKMAC ,/* HMAC was wrong on ACK + MP_JOIN */ MPTCP_MIB_DSSNOMATCH ,/* Received a new mapping that did not match the previous one */ MPTCP_MIB_INFINITEMAPRX, /* Received an infinite mapping */
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 8/12 Squash-to: "mptcp: increment MIB counters in a few places"
In reply to Paolo Abeniincremente the newly introduced counters
--- net/mptcp/subflow.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/mptcp/subflow.c +6 -1
@@ -252,6 +252,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) goto do_reset; subflow->conn_finished =1 ; +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_JOINSYNACKRX ); }else { do_reset:tcp_send_active_reset (sk,GFP_ATOMIC );
@@ -374,8 +375,10 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, opt_rx.mptcp.mp_join =0 ;mptcp_get_options (skb, &opt_rx);if (!opt_rx.mptcp.mp_join || - !subflow_hmac_valid (req, &opt_rx)) + !subflow_hmac_valid (req, &opt_rx)) { +SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_JOINACKMAC );return NULL ; + } } create_child:
@@ -407,6 +410,8 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, ctx->conn = (struct sock *)owner;if (!mptcp_finish_join (child)) goto close_child; + +SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_JOINACKRX ); } }
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 9/12 Squash-to: "subflow: place further subflows on new 'join_list'"
In reply to Paolo Abenido not insert the new subflow on join list, if we are going to drop it
--- net/mptcp/protocol.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
net/mptcp/protocol.c +10 -6
@@ -1519,6 +1519,7 @@ bool mptcp_finish_join(struct sock *sk)struct mptcp_sock *msk =mptcp_sk (subflow->conn);struct sock *parent = (void *)msk;struct socket *parent_sock; +bool ret;pr_debug ("msk=%p, subflow=%p" , msk, subflow);
@@ -1530,12 +1531,15 @@ bool mptcp_finish_join(struct sock *sk)if (parent_sock && !sk->sk_socket) {mptcp_sock_graft (sk, parent_sock); -/* active connections are already on conn_list */ -spin_lock_bh (&msk->join_list_lock); -if (!WARN_ON_ONCE (!list_empty (&subflow->node))) -list_add_tail (&subflow->node, &msk->join_list); -spin_unlock_bh (&msk->join_list_lock); -return mptcp_pm_allow_new_subflow (msk); + ret =mptcp_pm_allow_new_subflow (msk); +if (ret) { +/* active connections are already on conn_list */ +spin_lock_bh (&msk->join_list_lock); +if (!WARN_ON_ONCE (!list_empty (&subflow->node))) +list_add_tail (&subflow->node, &msk->join_list); +spin_unlock_bh (&msk->join_list_lock); + } +return ret; }return true; }
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 10/12 Squash-to: "mptcp: add netlink based PM"
In reply to Paolo AbeniImplement support for max subflow limits, updating the APIs. Be sure to avoid any pending work if the subflows limit will block that.
Fix an issue in local address lookup: we must traverse also the join_list.
--- include/uapi/linux/mptcp.h | 5 +- net/mptcp/pm_netlink.c | 93 +++++++++++++++++++++++++++----------- 2 files changed, 69 insertions(+), 29 deletions(-)
include/uapi/linux/mptcp.h +3 -2
@@ -45,6 +45,7 @@ enum mptcp_pm_attrs {MPTCP_PM_ATTR_ADDR ,/* nested address */ MPTCP_PM_ATTR_RCV_ADD_ADDRS ,/* u32 */ +MPTCP_PM_ATTR_SUBFLOWS ,/* u32 */ __MPTCP_PM_ATTR_MAX };
@@ -78,8 +79,8 @@ enum {MPTCP_PM_CMD_DEL_ADDR ,MPTCP_PM_CMD_GET_ADDR ,MPTCP_PM_CMD_FLUSH_ADDRS , -MPTCP_PM_CMD_SET_RCV_ADD_ADDRS , -MPTCP_PM_CMD_GET_RCV_ADD_ADDRS , +MPTCP_PM_CMD_SET_LIMITS , +MPTCP_PM_CMD_GET_LIMITS , __MPTCP_PM_CMD_AFTER_LAST };
net/mptcp/pm_netlink.c +66 -27
211 lines not on this page · raw message
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 11/12 Squash-to: "selftests: add PM netlink functional tests"
In reply to Paolo Abeniupdate to new NL APIs
add checks for subflows limits
--- .../testing/selftests/net/mptcp/pm_netlink.sh | 17 +++++-- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 46 ++++++++++++------- 2 files changed, 41 insertions(+), 22 deletions(-)
tools/testing/selftests/net/mptcp/pm_netlink.sh +12 -5
@@ -69,7 +69,8 @@ check() } check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list" -check "ip netns exec $ns1 ./pm_nl_ctl accept" "accept 0" "defaults accept add addr" +check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 +subflows 0" "defaults limits" ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo
@@ -114,10 +115,16 @@ id 8 flags signal 10.0.1.8 " "id limit" ip netns exec $ns1 ./pm_nl_ctl flush check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs" -ip netns exec $ns1 ./pm_nl_ctl accept 9 -check "ip netns exec $ns1 ./pm_nl_ctl accept" "accept 0" "above accept add_addr hard limit" +ip netns exec $ns1 ./pm_nl_ctl limits 9 1 +check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 +subflows 0" "rcv addrs above hard limit" -ip netns exec $ns1 ./pm_nl_ctl accept 8 -check "ip netns exec $ns1 ./pm_nl_ctl accept" "accept 8" "set accept add_addr" +ip netns exec $ns1 ./pm_nl_ctl limits 1 9 +check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 +subflows 0" "subflows above hard limit" + +ip netns exec $ns1 ./pm_nl_ctl limits 8 8 +check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 8 +subflows 8" "set limits" exit $ret
tools/testing/selftests/net/mptcp/pm_nl_ctl.c +29 -17
104 lines not on this page · raw message
Signature · 1 line
2.21.1
Paolo Abeni
PATCH v2 12/12 Squash-to: "selftests: add test-cases for MPTCP MP_JOIN"
In reply to Paolo AbeniAdd tests for subflows limit enforcing.
re-enable multiple subflows tests.
cleanup data gathering via appropriate nstat command line options
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 100 ++++++++++++++---- 1 file changed, 79 insertions(+), 21 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +79 -21
@@ -17,7 +17,6 @@ init() capout=$(mktemp) rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) - nstat="/tmp/.nstat.$rndh" ns1="ns1-$rndh" ns2="ns2-$rndh"
@@ -53,7 +52,6 @@ init() cleanup_partial() { rm -f "$capout" - rm -f "$nstat" for netns in "$ns1" "$ns2"; do ip netns del $netns
@@ -222,20 +220,50 @@ run_tests() chk_join_nr() { local msg="$1" - local ns=$2 - local nr=$3 + local syn_nr=$2 + local syn_ack_nr=$3 + local ack_nr=$4 local count + local dump_stats - count=`NSTAT_HISTORY=$nstat ip netns exec $ns nstat |grep MPTcpExtMPJoinSynRx | awk '{print $2}'` + printf "%-36s %s" "$msg" "syn" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'` [ -z "$count" ] && count=0 - printf "%-50s %s" "$msg" - if [ "$count" != "$nr" ]; then - echo "[fail] got $count JOIN[s] expected $nr" + if [ "$count" != "$syn_nr" ]; then + echo "[fail] got $count JOIN[s] syn expected $syn_nr" ret=1 + dump_stats=1 else - echo "[ ok ]" + echo -n "[ ok ]" fi + echo -n " - synack" + count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$syn_ack_nr" ]; then + echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - ack" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$ack_nr" ]; then + echo "[fail] got $count JOIN[s] ack expected $ack_nr" + 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 } sin=$(mktemp)
@@ -248,49 +276,79 @@ make_file "$sin" "server" trap cleanup EXIT run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "no JOIN" $ns1 "0" +chk_join_nr "no JOIN" "0" "0" "0" + +# subflow limted by client +reset +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "single subflow, limited by client" 0 0 0 + +# subflow limted by server +reset +ip netns exec $ns2 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "single subflow, limited by server" 1 1 0 # subflow reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 0 1 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "single subflow" $ns1 1 +chk_join_nr "single subflow" 1 1 1 # multiple subflows reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl limits 0 2 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "multiple subflows" $ns1 2 +chk_join_nr "multiple subflows" 2 2 2 + + +# multiple subflows limited by serverf +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "multiple subflows, limited by server" 2 2 1 # add_address, unused reset ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "unused signal address" $ns1 0 +chk_join_nr "unused signal address" 0 0 0 # accept and use add_addr reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 1 1 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal -ip netns exec $ns2 ./pm_nl_ctl accept 1 run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "signal address" $ns1 1 +chk_join_nr "signal address" 1 1 1 # accept and use add_addr with an additional subflow reset ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal -ip netns exec $ns2 ./pm_nl_ctl accept 1 +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl limits 1 2 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "subflow and signal" $ns1 2 +chk_join_nr "subflow and signal" 2 2 2 # accept and use add_addr with an additional subflows reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 3 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal -ip netns exec $ns2 ./pm_nl_ctl accept 1 +ip netns exec $ns2 ./pm_nl_ctl limits 1 3 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow -ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.2 flags signal +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow run_tests $ns1 $ns2 10.0.1.1 -chk_join_nr "multiple subflows and signal" $ns1 3 +chk_join_nr "multiple subflows and signal" 3 3 3 -exit $ret +exit $ret
Signature · 1 line
2.21.1
Mat Martineau
Quoted 29 lines · Paolo Abeni
This series bring some fixes and improvement related to the PM netlink, specifically:
- renames 4th_ack subflow field to '
fully_established':
this is hopefully more accurate
- implements support to enforce the maximum number of subflows per msk
- implementsMP_JOIN3rd ack retransmission and 4th ack delivery:
this [ab]use the TCP delack timer. I personally think the idea is nice and avoids changes to the core TCP stack, but I guess it could be disputed
- more accurare 'fully established' accounting as per RFC
- drop the msk level 'fully_established' field, as we can use the first subflow status without additional locking instead. This simplify core PM event handling
- adds moreMP_JOINrelated mib counters
- update the PM netlink to enforce a configurable maximum number of subflows per msk
- extend the pm netlink self-tests to check the above APIs
- uses amost all the above to fix the currently disable mp join self-tests and re-enable themNote: mp join self tests are still unstable, e.g. can fail randomly, due to an old race between
mptcp_token_update_accept()andmptcp_token_get_sock(): e.g. a client may legitly try to create a subflow after that the first one is fully established but before the server has accepted the initial socket:mptcp_token_get_sock()will fail andMP_JOINwill fail too, incrementingMPTCP_MIB_JOINNOTOKEN.
I think the above should be addressed in a separate series - otherwise this one will be too big.
Quoted 7 lines
The up2date branch for this series (v2) is available here:
https://github.com/pabeni/mptcp/tree/mptcp_net-next_part3_7
v1 -> v2:
- comments and readability changes in patch 04
Thanks for the fixes - I don't have any further comments, looks good to integrate in the topgit tree.
--
Mat Martineau
Intel
Matthieu Baerts
Hi Mat, Paolo,
Quoted 2 lines · Mat Martineau
On Thu, 5 Mar 2020, Paolo Abeni wrote:
[...]
Quoted 10 lines
Quoted 7 lines
The up2date branch for this series (v2) is available here:
https://github.com/pabeni/mptcp/tree/mptcp_net-next_part3_7
v1 -> v2:
- comments and readability changes in patch 04Thanks for the fixes - I don't have any further comments, looks good to integrate in the topgit tree.
Thank you for the patches and the review!
*Paolo* : there is one comment for you below:
- the first patch has been applied as a new topic (exported commit) at the beginning of the series. → t/mptcp-rename-fourth-ack-field
- 5a5f6637f84f: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
- b5b033c18651..a6e8ad2a3769: result
- 1e9a3e8639eb: "squashed" patch 2/12 in "mptcp: Add path manager interface" (not on top of "mptcp: Add ADD_ADDR handling")
- 02ebff8a2889: conflict in t/mptcp-Implement-path-manager-interface-commands
- a6e8ad2a3769..b9678d1875a3: result
- 0e515e7616d3: "squashed" patch 3/12 in "mptcp: Add handling of incoming MP_JOIN requests"
→ *Paolo*: I removed the new comment "passive connection, attach to msk socket" as you did in your branch. Was it OK?
- a8393200f126: conflict in t/subflow-place-further-subflows-on-new-join_list
- b9678d1875a3..16774063f32f: result
- d1a5f94551a0: "squashed" patch 4/12 in "mptcp: Add handling of outgoing MP_JOIN requests"
- 16774063f32f..98f82f13c815: result
- 90aea70d750f: "squashed" patch 5/12 (with conflicts) in "mptcp:
Implement path manager interface commands"
- 98f82f13c815..9f20f16976d5: result
- 55fcf97eb8a2: "squashed" patch 6/12 in "mptcp: allow dumping subflow context to userspace"
- bac8494b909d: "Signed-off-by" + "Co-developed-by"
- 9f20f16976d5..bd72cf4868c2: result
- ab0626ee746d: "squashed" patch 7/12 in "mptcp: add MIB counter infrastructure"
- 4938832cda6f: "Signed-off-by" + "Co-developed-by"
- bd72cf4868c2..9d4cccd2f4f2: result
- e73584a30099: "squashed" patch 8/12 in "mptcp: increment MIB counters in a few places"
- 9d4cccd2f4f2..565f38422c7e: result
- b163eff329fe: "squashed" patch 9/12 in "subflow: place further subflows on new 'join_list'"
- 565f38422c7e..6f8e4ee41d9b: result
- e51fa26aad11: "squashed" patch 10/12 in "mptcp: add netlink based PM"
- 6f8e4ee41d9b..4e1be8fa7025: result
- 02c781aa2467: "squashed" patch 11/12 in "selftests: add PM netlink functional tests"
- 4e1be8fa7025..284d58a7ac6d: result
- 4db8e0bf06fd: "squashed" patch 12/12 (with conflicts) in "selftests:
add test-cases for MPTCP MP_JOIN"
- 284d58a7ac6d..96df58122739: result
Tests + export will be launched soon.
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
Paolo Abeni
Quoted 15 lines · Matthieu Baerts
*Paolo* : there is one comment for you below:
- the first patch has been applied as a new topic (exported commit) at the beginning of the series. → t/mptcp-rename-fourth-ack-field
-5a5f6637f84f: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
-b5b033c18651..a6e8ad2a3769: result-
1e9a3e8639eb: "squashed" patch 2/12 in "mptcp: Add path manager interface" (not on top of "mptcp: AddADD_ADDRhandling")
-02ebff8a2889: conflict in t/mptcp-Implement-path-manager-interface-commands
-a6e8ad2a3769..b9678d1875a3: result
Quoted 4 lines
-
0e515e7616d3: "squashed" patch 3/12 in "mptcp: Add handling of incomingMP_JOINrequests"
→ *Paolo*: I removed the new comment "passive connection, attach to msk socket" as you did in your branch. Was it OK?
Yep, look good to me!
I'll have a better look at the code while working at more follow-up patches to fix sporadic self-tests failures.
Thank you for your great work!
Paolo