more MP_JOIN self-tests fixes
Subsystems (2)
Paolo Abeni
cover more MP_JOIN self-tests fixes
This series bring in more MP_JOIN self-tests fixes.
It also includes a couple of last minute fixes for add_addr hmac, please see individual patches for detailed info.
With a previous iteration of this series applied, the self-tests survided > 1500 iterations without any failures. This iteration went through smaller test-cycles, still without issues.
The rebased export branch is available here:
https://github.com/pabeni/mptcp/tree/mptcp_net-next_part3_12
options.c | 25 +++++++++++++------------ protocol.c | 16 +++++++++------- subflow.c | 4 ++-- 3 files changed, 24 insertions(+), 21 deletions(-)
Paolo Abeni
PATCH 1/4 Squash-to: "mptcp: Add ADD_ADDR handling"
a previous patch removed required initialization for mp_opt->add_addr, re-add it.
Additionally use msk's key value instead of subflow's one:
for MPJ subflows keys are uninitialized.
--- net/mptcp/options.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/mptcp/options.c +5 -4
@@ -204,6 +204,7 @@ void mptcp_parse_option(const struct sk_buff *skb, const unsigned char *ptr,break ; } + mp_opt->add_addr =1 ; mp_opt->addr_id = *ptr++;pr_debug ("ADD_ADDR: id=%d" , mp_opt->addr_id);if (mp_opt->family ==MPTCP_ADDR_IPVERSION_4 ) {
@@ -497,8 +498,8 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->suboptions |=OPTION_MPTCP_ADD_ADDR ; opts->addr_id = id; opts->addr = ((struct sockaddr_in *)&saddr)->sin_addr; - opts->ahmac =add_addr_generate_hmac (subflow->local_key, - subflow->remote_key, + opts->ahmac =add_addr_generate_hmac (msk->local_key, + msk->remote_key, opts->addr_id, &opts->addr); *size =TCPOLEN_MPTCP_ADD_ADDR ;
@@ -509,8 +510,8 @@ static bool mptcp_established_options_addr(struct sock *sk,return false; opts->suboptions |=OPTION_MPTCP_ADD_ADDR6 ; opts->addr_id = id; - opts->ahmac =add_addr6_generate_hmac (subflow->local_key, - subflow->remote_key, + opts->ahmac =add_addr6_generate_hmac (msk->local_key, + msk->remote_key, opts->addr_id, &opts->addr6); opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr;
Signature · 1 line
2.21.1
Paolo Abeni
PATCH 2/4 Squash-to: "mptcp: Add path manager interface"
In reply to Paolo AbeniWe need to move mptcp_pm_new_connection() at msk creation time, or later subflows may access an unintialized 'server_side' field.
That would lead to missing fourth ack
Additionally drop unneeded cast in the nearby code.
add_addr_hmac_valid() must use msk's keys: MPJ subflows can have uninitializated values there. Instead of copying keys on every subflow, just use msk's values.
--- net/mptcp/options.c | 16 ++++++++-------- net/mptcp/protocol.c | 2 -- net/mptcp/subflow.c | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-)
net/mptcp/options.c +8 -8
@@ -600,7 +600,7 @@ static bool check_fully_established(struct mptcp_subflow_context *subflow,return true; } -static bool add_addr_hmac_valid (struct mptcp_subflow_context *subflow, +static bool add_addr_hmac_valid (struct mptcp_sock *msk,struct mptcp_options_received *mp_opt) {u64 hmac =0 ;
@@ -609,18 +609,18 @@ static bool add_addr_hmac_valid(struct mptcp_subflow_context *subflow,return true;if (mp_opt->family ==MPTCP_ADDR_IPVERSION_4 ) - hmac =add_addr_generate_hmac (subflow->remote_key, - subflow->local_key, + hmac =add_addr_generate_hmac (msk->remote_key, + msk->local_key, mp_opt->addr_id, &mp_opt->addr);#if IS_ENABLED (CONFIG_MPTCP_IPV6 ) else - hmac =add_addr6_generate_hmac (subflow->remote_key, - subflow->local_key, + hmac =add_addr6_generate_hmac (msk->remote_key, + msk->local_key, mp_opt->addr_id, &mp_opt->addr6);#endif -pr_debug ("subflow=%p, ahmac=%llu, mp_opt->ahmac=%llu\n" , - subflow, (unsigned long long )hmac, +pr_debug ("msk=%p, ahmac=%llu, mp_opt->ahmac=%llu\n" , + msk, (unsigned long long )hmac, (unsigned long long )mp_opt->ahmac);return hmac == mp_opt->ahmac;
@@ -638,7 +638,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,if (!check_fully_established (subflow, skb, mp_opt))return ; -if (msk && mp_opt->add_addr &&add_addr_hmac_valid (subflow, mp_opt)) { +if (mp_opt->add_addr &&add_addr_hmac_valid (msk, mp_opt)) {struct mptcp_addr_info addr; addr.port =0 ;
net/mptcp/protocol.c +0 -2
@@ -917,8 +917,6 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err, msk =mptcp_sk (new_mptcp_sock); msk->first = newsk; -mptcp_pm_new_connection (msk,1 ); - newsk = new_mptcp_sock;mptcp_copy_inaddrs (newsk, ssk);list_add (&subflow->node, &msk->conn_list);
net/mptcp/subflow.c +2 -2
@@ -234,8 +234,8 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,/* new mpc subflow takes ownership of the newly * created mptcp socket */ -inet_sk_state_store ((struct sock *)new_msk, -TCP_ESTABLISHED ); +inet_sk_state_store (new_msk,TCP_ESTABLISHED ); +mptcp_pm_new_connection (mptcp_sk (new_msk),1 ); ctx->conn = new_msk; new_msk =NULL ; }
Signature · 1 line
2.21.1
Paolo Abeni
PATCH 3/4 Squash-to: "mptcp: Add handling of incoming MP_JOIN requests"
In reply to Paolo Abenifix race between mptcp_finish_join() and mptcp_stream_accept()
--- net/mptcp/protocol.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/mptcp/protocol.c +7 -5
@@ -1118,13 +1118,15 @@ bool mptcp_finish_join(struct sock *sk)if (inet_sk_state_load (parent) !=TCP_ESTABLISHED )return false; +if (!msk->pm.server_side) +return true; + +/* passive connection, attach to msk socket */ parent_sock =READ_ONCE (parent->sk_socket); -if (parent_sock && !sk->sk_socket) { -/* passive connection, attach to msk socket */ +if (parent_sock && !sk->sk_socket)mptcp_sock_graft (sk, parent_sock); -return mptcp_pm_allow_new_subflow (msk); - } -return true; + +return mptcp_pm_allow_new_subflow (msk); }bool mptcp_sk_is_subflow (const struct sock *sk)
Signature · 1 line
2.21.1
Paolo Abeni
PATCH 4/4 Squash-to: "subflow: place further subflows on new 'join_list'"
In reply to Paolo AbeniWe need to flush the join list even at shutdown time, or bad things will happen
--- net/mptcp/protocol.c | 2 ++ 1 file changed, 2 insertions(+)
net/mptcp/protocol.c +2 -0
@@ -1771,6 +1771,7 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,/* set ssk->sk_socket of accept()ed flows to mptcp socket. * This is needed so NOSPACE flag can be set from tcp stack. */ +__mptcp_flush_join_list (msk);list_for_each_entry (subflow, &msk->conn_list, node) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow);
@@ -1852,6 +1853,7 @@ static int mptcp_shutdown(struct socket *sock, int how) sock->state =SS_CONNECTED ; } +__mptcp_flush_join_list (msk);mptcp_for_each_subflow (msk, subflow) {struct sock *tcp_sk =mptcp_subflow_tcp_sock (subflow);
Signature · 1 line
2.21.1
Matthieu Baerts
Hi Paolo,
Quoted 5 lines · Paolo Abeni
This series bring in more
MP_JOINself-tests fixes.It also includes a couple of last minute fixes for
add_addrhmac, please see individual patches for detailed info.
Quoted 7 lines
With a previous iteration of this series applied, the self-tests survided > 1500 iterations without any failures. This iteration went through smaller test-cycles, still without issues.
The rebased export branch is available here:
https://github.com/pabeni/mptcp/tree/mptcp_net-next_part3_12
Thank you for the patches!
- 07ba7723f14f: "squashed" patch 1/4 in "mptcp: Add ADD_ADDR handling"
- 79ced2399cff: conflict in t/mptcp-Add-path-manager-interface
- 75fd7fbcff54..57b87fa20529: result
- 9e1e12b0253a: "squashed" patch 2/4 in "mptcp: Add path manager interface"
- a116910e09e2: conflict in t/mptcp-update-per-unacked-sequence-on-pkt-reception
- 57b87fa20529..a60d43a78ea9: result
- f1c4bd2b5b30: "squashed" patch 3/4 in "mptcp: Add handling of incoming MP_JOIN requests"
- 0a5b28b67886: conflict in t/subflow-place-further-subflows-on-new-join_list
- a60d43a78ea9..dd40c4166ba2: result
- 08ef7db1c8c7: "squashed" patch 4/4 in "subflow: place further subflows on new 'join_list'"
- dd40c4166ba2..10a5c66719de: 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