Implement outgoing MP_JOIN
Subsystems (3)
Peter Krystad
v3 cover Implement outgoing MP_JOIN
This is several accumulated fixes that are required for MP_JOIN (secondary subflows) plus the outgoing code.
Both outgoing and incoming MP_JOIN now inter-operate with the multipath.org implementation although there is still a deadlock when incoming is fully established. Since the incoming direction did not work at all before this is an improvement. I have not yet tested running our implmentation against itself.
The final patch in the set is an "interim path manager", this is throw-away code that I include for testing purposes. For an incoming connection it is necessary for the server to advertise a secondary address and for my testing I have been hard-coding the IP address of my secondary interface when I build the kernel. Obviously not the final solution but we need to discuss what approach to use for the self tests. I also think we may not want to publish this patch on our net-next branch.
v2:
- move mptcp_options_received formatting to options.c
- resolve conflicts with Davide's crypto commit
- make helper for setting request fields
- fix locking in token_lookup()
- move token_lookup() to "Implement path manager interface commands:
(where it belongs)
- split interim path manager out of final commit, will submit seperately
- remove use of local_id in pm_create_subflow
- restrict announcing addresses to server side only
- add one more commit with get_local_id fix for incoming MP_JOIN
v3:
- Revise nested if logic in options.c
- set subflow->request_cksum correctly (do not support)
- lock mptcp_sock in subflow_connect() and take ref
- return EINPROGRESS from subflow_connect() in normal case
- cleanup socket when bind()/connect() fails in subflow_connect()
- take reference to mptcp_sock in token_join_request() and token_join_valid()
- rename token_lookup() to token_lookup_get()
- track remote token seperately in subflow (previously local token field was being overwritten, preventing cleanup)
- take long-lived reference to mptcp_sock in token_new_subflow
Peter Krystad (10):
Extend path manager interface
Fix locking in mptcp_finish_join.
Fix parsing MP_JOIN third ACK.
Re-factor and fixes for crypto_hmac_sha1()
Rename mptcp_attach_dss()
Fix return value if no DSS option is created.
Move setting request_ fields of subflow to MPTCP layer helper
mptcp: Add handling of outgoing MP_JOIN requests Use pm_get_local_id() to get the real local address id.
mptcp: Implement path manager interface commands
include/net/mptcp.h | 12 ++-- net/ipv4/tcp_input.c | 4 +- net/mptcp/crypto.c | 23 +++---- net/mptcp/options.c | 98 +++++++++++++++++++++++++++--- net/mptcp/pm.c | 140 +++++++++++++++++++++++++++++++++++++++---- net/mptcp/protocol.c | 21 +++++-- net/mptcp/protocol.h | 58 ++++++++++++++---- net/mptcp/subflow.c | 77 +++++++++++++++++++++--- net/mptcp/token.c | 111 +++++++++++++++++++++++++++------- 9 files changed, 455 insertions(+), 89 deletions(-)
Signature · 1 line
2.17.2
Peter Krystad
PATCH v3 1/10 Extend path manager interface
A little more functionality and some comments clarifying which routines are for a path manager to call and which are callbacks.
squashto: Add path manager interface
--- net/mptcp/options.c | 40 +++++++++++++++++++-- net/mptcp/pm.c | 84 +++++++++++++++++++++++++++++++++++++------- net/mptcp/protocol.c | 5 +-- net/mptcp/protocol.h | 38 +++++++++++++++----- 4 files changed, 140 insertions(+), 27 deletions(-)
net/mptcp/options.c +37 -3
@@ -411,11 +411,29 @@ static bool mptcp_established_options_addr(struct sock *sk, {struct subflow_context *subflow =subflow_ctx (sk);struct mptcp_sock *msk =mptcp_sk (subflow->conn); +struct sockaddr_storage saddr; +u8 id; -if (subflow->fourth_ack) -return pm_addr_signal (msk, size, remaining, opts); +if (!msk) +return false; -return false; +if (!msk->pm.fully_established || !msk->addr_signal) +return false; + +if (pm_addr_signal (msk, &id, &saddr)) +return false; + +if (saddr.ss_family ==AF_INET && remaining <TCPOLEN_MPTCP_ADD_ADDR ) +return false; + + opts->suboptions |=OPTION_MPTCP_ADD_ADDR ; + opts->addr_id = id; + opts->addr.s_addr = ((struct sockaddr_in *)&saddr)->sin_addr.s_addr; + *size =TCPOLEN_MPTCP_ADD_ADDR ; + + msk->addr_signal =0 ; + +return true; } bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
@@ -479,11 +497,23 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,void mptcp_attach_dss (struct sock *sk,struct sk_buff *skb,struct tcp_options_received *opt_rx) { +struct subflow_context *subflow =subflow_ctx (sk); +struct mptcp_sock *msk =mptcp_sk (subflow->conn);struct mptcp_options_received *mp_opt;struct mptcp_ext *mpext; mp_opt = &opt_rx->mptcp; +if (msk && mp_opt->add_addr) { +if (mp_opt->family ==MPTCP_ADDR_IPVERSION_4 ) +pm_add_addr (msk, &mp_opt->addr, mp_opt->addr_id); +#if IS_ENABLED (CONFIG_IPV6 ) + else if (mp_opt->family == MPTCP_ADDR_IPVERSION_6) + pm_add_addr6(msk, &mp_opt->addr6, mp_opt->addr_id); +#endif + mp_opt->add_addr =0 ; + } +if (!mp_opt->dss)return ;
@@ -510,6 +540,10 @@ void mptcp_attach_dss(struct sock *sk, struct sk_buff *skb, } mpext->data_fin = mp_opt->data_fin; + +if (msk) +pm_fully_established (msk); + }void mptcp_write_options (__be32 *ptr,struct mptcp_out_options *opts)
net/mptcp/pm.c +71 -13
111 lines not on this page · raw message
net/mptcp/protocol.c +3 -2
@@ -663,7 +663,7 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,token_update_accept (new_sock->sk, new_mptcp_sock); msk->subflow =NULL ; -pm_new_connection (msk); +pm_new_connection (msk,1 );crypto_key_sha1 (msk->remote_key,NULL , &ack_seq); msk->write_seq = subflow->idsn +1 ;
@@ -798,7 +798,7 @@ void mptcp_finish_connect(struct sock *sk, int mp_capable) msk->token = subflow->token;pr_debug ("msk=%p, token=%u" , msk, msk->token); -pm_new_connection (msk); +pm_new_connection (msk,0 );crypto_key_sha1 (msk->remote_key,NULL , &ack_seq); msk->write_seq = subflow->idsn +1 ;
@@ -1090,6 +1090,7 @@ void __init mptcp_init(void)token_init ();subflow_init (); +pm_init ();if (proto_register (&mptcp_prot,1 ) !=0 )panic ("Failed to register MPTCP proto.\n" );
net/mptcp/protocol.h +29 -9
@@ -78,15 +78,32 @@ static inline u32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field) ((nib & 0xF) << 8) | field); } -struct pm_data { -u8 addr_id; -sa_family_t family; +struct mptcp_pm_data { +u8 local_valid; +u8 local_id; +sa_family_t local_family; +union { +struct in_addr local_addr; +#if IS_ENABLED (CONFIG_IPV6 ) +struct in6_addr local_addr6; +#endif + }; +u8 remote_valid; +u8 remote_id; +sa_family_t remote_family;union { -struct in_addr addr; +struct in_addr remote_addr;#if IS_ENABLED (CONFIG_IPV6 ) -struct in6_addr addr6; +struct in6_addr remote_addr6;#endif }; +u8 server_side :1 , + fully_established :1 ; + +/* for interim path manager */ +struct work_struct addr_work; +struct work_struct subflow_work; +u32 token; };/* MPTCP connection sock */
@@ -100,7 +117,7 @@ struct mptcp_sock {u32 token;struct list_head conn_list;struct socket *subflow;/* outgoing connect/listener/!mp_capable */ -struct pm_data pm; +struct mptcp_pm_data pm;u8 addr_signal; };
@@ -223,7 +240,8 @@ static inline void crypto_key_gen_sha1(u64 *key, u32 *token, u64 *idsn)crypto_key_sha1 (*key, token, idsn); } -void pm_new_connection (struct mptcp_sock *msk); +void pm_init (void ); +void pm_new_connection (struct mptcp_sock *msk,int server_side);void pm_fully_established (struct mptcp_sock *msk);void pm_connection_closed (struct mptcp_sock *msk);void pm_subflow_established (struct mptcp_sock *msk,u8 id);
@@ -231,8 +249,10 @@ void pm_subflow_closed(struct mptcp_sock *msk, u8 id);void pm_add_addr (struct mptcp_sock *msk,const struct in_addr *addr,u8 id);void pm_add_addr6 (struct mptcp_sock *msk,const struct in6_addr *addr,u8 id);void pm_rm_addr (struct mptcp_sock *msk,u8 id); -bool pm_addr_signal (struct mptcp_sock *msk,unsigned int *size, -unsigned int remaining,struct mptcp_out_options *opts); +int pm_addr_signal (struct mptcp_sock *msk,u8 *id, +struct sockaddr_storage *saddr); +int pm_get_local_id (struct request_sock *req,struct sock *sk, +const struct sk_buff *skb);static inline struct mptcp_ext *mptcp_get_ext (struct sk_buff *skb) {
Signature · 1 line
2.17.2
Matthieu Baerts
Re: [MPTCP] [PATCH v3 01/10] Extend path manager interface
Hi Peter, Paolo, Mat,
Quoted 5 lines · Peter Krystad
A little more functionality and some comments clarifying which routines are for a path manager to call and which are callbacks.
squashto: Add path manager interface
Thank you for the patch and the reviews!
I had to split this patch in 2 parts:
- c8625a37c692: part 1: "squashed" in "mptcp: Add path manager interface"
- 4412b8e8e6c9: conflict in t/mptcp-Add-ADD_ADDR-handling
- 0757aec1b6f2: part 2: "squashed" in "mptcp: Add ADD_ADDR handling"
- b1477322bbb7..711ae3fdd44f: results
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
Peter Krystad
Re: [MPTCP] [PATCH v3 01/10] Extend path manager interface
Hi Matthieu -
It seems a hunk went missing when this was split and squashed. The following piece of code from this patch does not appear in mptcp_incoming_options() in the current export branch as I would expect to.
+ if (msk && mp_opt->add_addr) {
+ if (mp_opt->family == MPTCP_ADDR_IPVERSION_4)
+ pm_add_addr(msk, &mp_opt->addr, mp_opt->addr_id);
+#if IS_ENABLED(CONFIG_IPV6)
+ else if (mp_opt->family == MPTCP_ADDR_IPVERSION_6)
+ pm_add_addr6(msk, &mp_opt->addr6, mp_opt->addr_id);
+#endif
+ mp_opt->add_addr = 0;
+ }
+
This causes the received ADD_ADDR option to not be passed up to the path manager. I'll send a patch.
Peter.
Quoted 20 lines · Matthieu Baerts
Hi Peter, Paolo, Mat,
Quoted 5 lines · Peter Krystad
A little more functionality and some comments clarifying which routines are for a path manager to call and which are callbacks.
squashto: Add path manager interface
Thank you for the patch and the reviews!
I had to split this patch in 2 parts:
-c8625a37c692: part 1: "squashed" in "mptcp: Add path manager interface"
-4412b8e8e6c9: conflict in t/mptcp-Add-ADD_ADDR-handling
-0757aec1b6f2: part 2: "squashed" in "mptcp: AddADD_ADDRhandling"
-b1477322bbb7..711ae3fdd44f: resultsCheers,
Matt
Matthieu Baerts
Re: [MPTCP] [PATCH v3 01/10] Extend path manager interface
Hi Peter,
Quoted 18 lines · Peter Krystad
Hi Matthieu -
It seems a hunk went missing when this was split and squashed. The following piece of code from this patch does not appear in
mptcp_incoming_options()in the current export branch as I would expect to.net/mptcp/options.c +10
-0+if (msk && mp_opt->add_addr) { +if (mp_opt->family ==MPTCP_ADDR_IPVERSION_4 ) +pm_add_addr (msk, &mp_opt->addr, mp_opt->addr_id); +#if IS_ENABLED (CONFIG_IPV6 ) + else if (mp_opt->family == MPTCP_ADDR_IPVERSION_6) + pm_add_addr6(msk, &mp_opt->addr6, mp_opt->addr_id); +#endif + mp_opt->add_addr =0 ; + } +
Quoted 2 lines
This causes the received
ADD_ADDRoption to not be passed up to the path manager. I'll send a patch.
Oh sorry, I thought I carefully checked that everything was there. I will apply this missing part ASAP!
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
Peter Krystad
PATCH v3 2/10 Fix locking in mptcp_finish_join.
In reply to Peter KrystadLock was being taken on the subflow sock, not mptcp_sock.
squashto: Add handling of incoming MP_JOIN requests
--- net/mptcp/protocol.c | 9 +++++---- net/mptcp/protocol.h | 2 +- net/mptcp/subflow.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-)
net/mptcp/protocol.c +5 -4
@@ -816,18 +816,19 @@ void mptcp_finish_connect(struct sock *sk, int mp_capable)inet_sk_state_store (sk,TCP_ESTABLISHED ); } -void mptcp_finish_join (struct sock *conn,struct sock *sk) +void mptcp_finish_join (struct sock *sk) {struct subflow_context *subflow =subflow_ctx (sk); -struct mptcp_sock *msk =mptcp_sk (conn); +struct mptcp_sock *msk =mptcp_sk (subflow->conn);pr_debug ("msk=%p, subflow=%p" , msk, subflow);local_bh_disable (); -bh_lock_sock_nested (sk); +bh_lock_sock_nested (subflow->conn);list_add_tail (&subflow->node, &msk->conn_list); -bh_unlock_sock (sk); +bh_unlock_sock (subflow->conn);local_bh_enable (); +inet_sk_state_store (sk,TCP_ESTABLISHED ); }bool mptcp_sk_is_subflow (const struct sock *sk)
net/mptcp/protocol.h +1 -1
@@ -210,7 +210,7 @@ void mptcp_get_options(const struct sk_buff *skb, struct tcp_options_received *opt_rx);void mptcp_finish_connect (struct sock *sk,int mp_capable); -void mptcp_finish_join (struct sock *conn,struct sock *sk); +void mptcp_finish_join (struct sock *sk);void token_init (void );void token_new_request (struct request_sock *req,const struct sk_buff *skb);
net/mptcp/subflow.c +1 -1
@@ -165,7 +165,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,if (token_new_join (child)) goto close_child;else -mptcp_finish_join (ctx->conn, child); +mptcp_finish_join (child); } }
Signature · 1 line
2.17.2
Matthieu Baerts
Re: [MPTCP] [PATCH v3 02/10] Fix locking in mptcp_finish_join.
Hi Peter, Paolo, Mat,
Quoted 3 lines · Peter Krystad
Lock was being taken on the subflow sock, not
mptcp_sock.squashto: Add handling of incoming
MP_JOINrequests
Thank you for the patch and the reviews!
- 590cbe28643f: "squashed" in "mptcp: Add handling of incoming MP_JOIN requests"
- 711ae3fdd44f..34fd270ae102: result
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
Peter Krystad
PATCH v3 3/10 Fix parsing MP_JOIN third ACK.
In reply to Peter KrystadThere is a reserved byte of zero's in there.
squashto: Add handling of incoming MP_JOIN requests
--- net/mptcp/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/options.c +1 -1
@@ -92,7 +92,7 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize, mp_opt->backup, mp_opt->join_id, mp_opt->thmac, mp_opt->nonce); }else if (opsize ==TCPOLEN_MPTCP_MPJ_ACK ) { - ptr++; + ptr +=2 ;memcpy (mp_opt->hmac, ptr,MPTCPOPT_HMAC_LEN );pr_debug ("MP_JOIN hmac" ); }else {
Signature · 1 line
2.17.2
Matthieu Baerts
Re: [MPTCP] [PATCH v3 03/10] Fix parsing MP_JOIN third ACK.
Hi Peter, Paolo, Mat,
Quoted 3 lines · Peter Krystad
There is a reserved byte of zero's in there.
squashto: Add handling of incoming
MP_JOINrequests
Thank you for the patch and the reviews!
- 1437af3a308a: "squashed" in "mptcp: Add handling of incoming MP_JOIN requests"
- 34fd270ae102..6c6c0f074bf5: result
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
Peter Krystad
PATCH v3 4/10 Re-factor and fixes for crypto_hmac_sha1()
In reply to Peter KrystadRe-factor to use parameters specific to MPTCP use case similar to crypto_key_sha1() and get rid of var args. Also fix endianness issues.
squash to: Add key generation and token tree
and: Add handling of incoming MP_JOIN requests
--- net/mptcp/crypto.c | 23 +++++++++-------------- net/mptcp/protocol.h | 4 ++-- net/mptcp/token.c | 19 ++++++++----------- 3 files changed, 19 insertions(+), 27 deletions(-)
net/mptcp/crypto.c +9 -14
@@ -51,23 +51,23 @@ void crypto_key_sha1(u64 key, u32 *token, u64 *idsn) *idsn = ((u64 )mptcp_hashed_key[3 ] <<32 ) + mptcp_hashed_key[4 ]; } -void crypto_hmac_sha1 (u64 key1,u64 key2,u32 *hash_out, -int arg_num, ...) +void crypto_hmac_sha1 (u64 key1,u64 key2,u32 nonce1,u32 nonce2,u32 *hash_out) {u32 workspace[SHA_WORKSPACE_WORDS ];u8 input[128 ];/* 2 512-bit blocks */ int i;int index; -int length; -u8 *msg; -va_list list;u8 key_1[8 ];u8 key_2[8 ]; +u8 nonce_1[4 ]; +u8 nonce_2[4 ];memset (workspace,0 ,sizeof (workspace));put_unaligned_be64 (key1, key_1);put_unaligned_be64 (key2, key_2); +put_unaligned_be32 (nonce1, nonce_1); +put_unaligned_be32 (nonce2, nonce_2);/* Generate key xored with ipad */ memset (input,0x36 ,64 );
@@ -76,16 +76,11 @@ void crypto_hmac_sha1(u64 key1, u64 key2, u32 *hash_out,for (i =0 ; i <8 ; i++) input[i +8 ] ^= key_2[i]; -va_start (list, arg_num); index =64 ; -for (i =0 ; i < arg_num; i++) { - length =va_arg (list, int); - msg = va_arg(list, u8 *); -WARN_ON (index + length >125 );/* Message is too long */ -memcpy (&input[index], msg, length); - index += length; - } -va_end (list); +memcpy (&input[index], nonce_1,4 ); + index =68 ; +memcpy (&input[index], nonce_2,4 ); + index =72 ; input[index] =0x80 ;/* Padding: First bit after message = 1 */ memset (&input[index +1 ],0 , (126 - index));
net/mptcp/protocol.h +2 -2
@@ -226,8 +226,6 @@ void token_release(u32 token);void token_destroy (u32 token);void crypto_key_sha1 (u64 key,u32 *token,u64 *idsn); -void crypto_hmac_sha1 (u64 key1,u64 key2,u32 *hash_out,int arg_num, ...); -static inline void crypto_key_gen_sha1 (u64 *key,u32 *token,u64 *idsn) {/* we might consider a faster version that computes the key as a
@@ -239,6 +237,8 @@ static inline void crypto_key_gen_sha1(u64 *key, u32 *token, u64 *idsn)get_random_bytes (key,sizeof (u64));crypto_key_sha1 (*key, token, idsn); } +void crypto_hmac_sha1 (u64 key1,u64 key2,u32 nonce1,u32 nonce2, +u32 *hash_out);void pm_init (void );void pm_new_connection (struct mptcp_sock *msk,int server_side);
net/mptcp/token.c +8 -11
@@ -84,12 +84,11 @@ static void new_req_join(struct request_sock *req, struct sock *sk,u8 hmac[MPTCPOPT_HMAC_LEN ];get_random_bytes (&subflow_req->local_nonce,sizeof (u32)); -crypto_hmac_sha1 (msk->local_key, - msk->remote_key, - (u32 *)hmac,2 , -4 , (u8 *)&subflow_req->local_nonce, -4 , (u8 *)&subflow_req->remote_nonce); - subflow_req->thmac = *(u64 *)hmac; +crypto_hmac_sha1 (msk->local_key, msk->remote_key, + subflow_req->local_nonce, subflow_req->remote_nonce, + (u32 *)hmac); + + subflow_req->thmac =get_unaligned_be64 (hmac);pr_debug ("local_nonce=%u, thmac=%llu" , subflow_req->local_nonce, subflow_req->thmac); }
@@ -101,11 +100,9 @@ static int new_join_valid(struct request_sock *req, struct sock *sk,struct mptcp_sock *msk =mptcp_sk (sk);u8 hmac[MPTCPOPT_HMAC_LEN ]; -crypto_hmac_sha1 (msk->remote_key, - msk->local_key, - (u32 *)hmac,2 , -4 , (u8 *)&subflow_req->remote_nonce, -4 , (u8 *)&subflow_req->local_nonce); +crypto_hmac_sha1 (msk->remote_key, msk->local_key, + subflow_req->remote_nonce, subflow_req->local_nonce, + (u32 *)hmac);return memcmp (hmac, (char *)rx_opt->mptcp.hmac,MPTCPOPT_HMAC_LEN ); }
Signature · 1 line
2.17.2
Matthieu Baerts
Re: [MPTCP] [PATCH v3 04/10] Re-factor and fixes for crypto_hmac_sha1()
Hi Peter, Mat, Paolo,
Quoted 5 lines · Peter Krystad
Re-factor to use parameters specific to MPTCP use case similar to
crypto_key_sha1()and get rid of var args. Also fix endianness issues.squash to: Add key generation and token tree
and: Add handling of incomingMP_JOINrequests
Thank you for the patch and the reviews!
- bc31e4f64971: part 1: "squashed" in "mptcp: Add key generation and token tree"
- f282f6b36b49: part 2: "squahsed" in "mptcp: Add handling of incoming MP_JOIN requests"
- f7938dd15948..009b132dc29d: result
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
Peter Krystad
PATCH v3 5/10 Rename mptcp_attach_dss()
In reply to Peter KrystadOther incoming MPTCP options will be handled in this routine.
squashto: Implement MPTCP receive path
--- include/net/mptcp.h | 10 +++++----- net/ipv4/tcp_input.c | 4 ++-- net/mptcp/options.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
include/net/mptcp.h +5 -5
@@ -68,9 +68,8 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,bool mptcp_established_options (struct sock *sk,struct sk_buff *skb,unsigned int *size,unsigned int remaining,struct mptcp_out_options *opts); - -void mptcp_attach_dss (struct sock *sk,struct sk_buff *skb, -struct tcp_options_received *opt_rx); +void mptcp_incoming_options (struct sock *sk,struct sk_buff *skb, +struct tcp_options_received *opt_rx);static inline bool mptcp_skb_ext_exist (const struct sk_buff *skb) {
@@ -128,8 +127,9 @@ static inline bool mptcp_established_options(struct sock *sk,return false; } -static inline void mptcp_attach_dss (struct sock *sk,struct sk_buff *skb, -struct tcp_options_received *opt_rx) +static inline void mptcp_incoming_options (struct sock *sk, +struct sk_buff *skb, +struct tcp_options_received *opt_rx) { }
net/ipv4/tcp_input.c +2 -2
@@ -5668,9 +5668,9 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)/* Process urgent data. */ tcp_urg (sk, skb, th); -/* Prepare MPTCP sequence data */ +/* Process MPTCP options */ if (sk_is_mptcp (sk)) -mptcp_attach_dss (sk, skb, &tp->rx_opt); +mptcp_incoming_options (sk, skb, &tp->rx_opt);/* step 7: process the segment text */ tcp_data_queue (sk, skb);
net/mptcp/options.c +2 -2
@@ -494,8 +494,8 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,return false; } -void mptcp_attach_dss (struct sock *sk,struct sk_buff *skb, -struct tcp_options_received *opt_rx) +void mptcp_incoming_options (struct sock *sk,struct sk_buff *skb, +struct tcp_options_received *opt_rx) {struct subflow_context *subflow =subflow_ctx (sk);struct mptcp_sock *msk =mptcp_sk (subflow->conn);
Signature · 1 line
2.17.2
Matthieu Baerts
Re: [MPTCP] [PATCH v3 05/10] Rename mptcp_attach_dss()
Hi Peter, Paolo, Mat,
Quoted 3 lines · Peter Krystad
Other incoming MPTCP options will be handled in this routine.
squashto: Implement MPTCP receive path
Thank you for the patch and the reviews!
- 3776155bf643: "squashed" in "mptcp: Implement MPTCP receive path"
- 06256d7cf989..b1477322bbb7: result
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
Peter Krystad
PATCH v3 6/10 Fix return value if no DSS option is created.
In reply to Peter KrystadStrictly speaking mptcp_established_options_dss() should return false if no DSS option is created.
squashto: Write MPTCP DSS headers to outgoing data packets
--- net/mptcp/options.c | 3 +++ 1 file changed, 3 insertions(+)
net/mptcp/options.c +3 -0
@@ -400,6 +400,9 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,WARN (1 ,"MPTCP: Ack dropped" ); } +if (!dss_size) +return false; + *size =ALIGN (dss_size,4 );return true; }
Signature · 1 line
2.17.2
Matthieu Baerts
Re: [MPTCP] [PATCH v3 06/10] Fix return value if no DSS option is created.
Hi Peter, Paolo, Mat,
Quoted 4 lines · Peter Krystad
Strictly speaking
mptcp_established_options_dss()should return false if no DSS option is created.squashto: Write MPTCP DSS headers to outgoing data packets
Thank you for the patch and the reviews!
- 7b039830202c: "squashed" in "mptcp: Write MPTCP DSS headers to outgoing data packets"
- 009b132dc29d..06256d7cf989: result
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
Peter Krystad
PATCH v3 7/10 Move setting request_ fields of subflow to MPTCP layer helper
In reply to Peter KrystadFor secondary subflows different request_ fields will be added that will be set differently based on subflow type (initial vs secondary).
squashto: Associate MPTCP context with TCP socket
--- net/mptcp/protocol.c | 6 ++++++ net/mptcp/protocol.h | 2 +- net/mptcp/subflow.c | 7 ++----- 3 files changed, 9 insertions(+), 6 deletions(-)
net/mptcp/protocol.c +6 -0
@@ -860,6 +860,7 @@ static struct proto mptcp_prot = {static struct socket *mptcp_socket_create_get (struct mptcp_sock *msk) {struct sock *sk = (struct sock *)msk; +struct subflow_context *subflow;struct socket *ssock;int err;
@@ -875,6 +876,11 @@ static struct socket *mptcp_socket_create_get(struct mptcp_sock *msk) } msk->subflow = ssock; + subflow =subflow_ctx (msk->subflow->sk); + subflow->request_mptcp =1 ;/* @@ if MPTCP enabled */ + subflow->request_cksum =0 ;/* checksum not supported */ + subflow->request_version =0 ;/* only v0 supported */ +sock_hold (ssock->sk); release:
net/mptcp/protocol.h +1 -1
@@ -168,10 +168,10 @@ struct subflow_context {u16 map_data_len; u16 request_mptcp : 1, /* send MP_CAPABLE */ request_cksum : 1, + request_version : 4, mp_capable : 1, /* remote is MPTCP capable */ mp_join : 1, /* remote is JOINing */ fourth_ack : 1, /* send initial DSS */ - version : 4, conn_finished : 1, use_checksum : 1, map_valid : 1,
net/mptcp/subflow.c +2 -5
@@ -62,8 +62,8 @@ static void subflow_v4_init_req(struct request_sock *req,if (rx_opt.mptcp.mp_capable && listener->request_mptcp) { subflow_req->mp_capable =1 ; -if (rx_opt.mptcp.version >= listener->version) - subflow_req->version = listener->version; +if (rx_opt.mptcp.version >= listener->request_version) + subflow_req->version = listener->request_version;else subflow_req->version = rx_opt.mptcp.version; if ((rx_opt.mptcp.flags & MPTCP_CAP_CHECKSUM_REQD) ||
@@ -218,9 +218,6 @@ int subflow_create_socket(struct sock *sk, struct socket **new_sock) *new_sock = sf; subflow->conn = sk; - subflow->request_mptcp =1 ;// @@ if MPTCP enabled - subflow->request_cksum =1 ;// @@ if checksum enabled - subflow->version =0 ;return 0 ; }
Signature · 1 line
2.17.2
Matthieu Baerts
Re: [MPTCP] [PATCH v3 07/10] Move setting request_ fields of subflow to MPTCP layer helper
Hi Peter, Paolo, Mat,
Quoted 5 lines · Peter Krystad
For secondary subflows different
request_fields will be added that will be set differently based on subflow type (initial vs secondary).squashto: Associate MPTCP context with TCP socket
Thank you for the patch and the reviews!
I had to split it in 3 parts:
- a831a5f64a0d: part 1: "squashed" in "mptcp: Associate MPTCP context with TCP socket"
- 4dff4a3c37ec: conflict in t/mptcp-Handle-MP_CAPABLE-options-for-outgoing-connections
- 7a108cfff657: part 2: "squashed" in "mptcp: Create SUBFLOW socket for incoming connections"
- ff3b994f4b4c: conflict in t/mptcp-Write-MPTCP-DSS-headers-to-outgoing-data-packets
- 987b6d7366be: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
- b99045fe03e0: part 3: "squashed" in "mptcp: harmonize locking on all socket operations."
- 64fb32edc6b2: signed-off
- b81ff8d90de3..f7938dd15948: result.
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
Peter Krystad
PATCH v3 8/10 mptcp: Add handling of outgoing MP_JOIN requests
In reply to Peter KrystadSubflow creation may be initiated by the path manager when the primary connection is fully established and a remote address has been received via ADD_ADDR.
Create an in-kernel sock and use kernel_connect() to initiate connection. When a valid SYN-ACK is received the new sock is added to the tail of the mptcp sock conn_list where it will not interfere with data flow on the original connection.
Data flow and connection failover not addressed by this commit.
--- include/net/mptcp.h | 2 ++ net/mptcp/options.c | 51 ++++++++++++++++++++++++++++++--- net/mptcp/protocol.c | 1 + net/mptcp/protocol.h | 11 +++++++ net/mptcp/subflow.c | 68 +++++++++++++++++++++++++++++++++++++++++++- net/mptcp/token.c | 48 +++++++++++++++++++++++++++++++ 6 files changed, 176 insertions(+), 5 deletions(-)
include/net/mptcp.h +2 -0
@@ -40,6 +40,8 @@ struct mptcp_out_options {u8 backup;u32 nonce;u64 thmac; +u32 token; +u8 hmac[20 ];struct mptcp_ext ext_copy;#endif };
net/mptcp/options.c +47 -4
105 lines not on this page · raw message
net/mptcp/protocol.c +1 -0
@@ -797,6 +797,7 @@ void mptcp_finish_connect(struct sock *sk, int mp_capable) msk->local_key = subflow->local_key; msk->token = subflow->token;pr_debug ("msk=%p, token=%u" , msk, msk->token); + msk->dport =ntohs (inet_sk (msk->subflow->sk)->inet_dport);pm_new_connection (msk,0 );
net/mptcp/protocol.h +11 -0
@@ -49,8 +49,10 @@#define TCPOLEN_MPTCP_ADD_ADDR6 20#define TCPOLEN_MPTCP_RM_ADDR 4 +/* MPTCP MP_JOIN flags */ #define MPTCPOPT_BACKUP BIT(0)#define MPTCPOPT_HMAC_LEN 20 +#define MPTCPOPT_THMAC_LEN 8/* MPTCP MP_CAPABLE flags */ #define MPTCP_VERSION_MASK (0x0F)
@@ -115,6 +117,7 @@ struct mptcp_sock {u64 write_seq;u64 ack_seq;u32 token; +u16 dport;struct list_head conn_list;struct socket *subflow;/* outgoing connect/listener/!mp_capable */ struct mptcp_pm_data pm;
@@ -167,7 +170,9 @@ struct subflow_context {u32 ssn_offset;u16 map_data_len; u16 request_mptcp : 1, /* send MP_CAPABLE */ + request_join : 1, /* send MP_JOIN */ request_cksum : 1, + request_bkup : 1, request_version : 4, mp_capable : 1, /* remote is MPTCP capable */ mp_join : 1, /* remote is JOINing */
@@ -179,6 +184,8 @@ struct subflow_context {u32 remote_nonce;u64 thmac;u32 local_nonce; +u32 remote_token; +u8 hmac[MPTCPOPT_HMAC_LEN ];u8 local_id;u8 remote_id;
@@ -202,6 +209,8 @@ mptcp_subflow_tcp_socket(const struct subflow_context *subflow) }void subflow_init (void ); +int subflow_connect (struct sock *sk,struct sockaddr_in *local, +struct sockaddr_in *remote,u8 remote_id);int subflow_create_socket (struct sock *sk,struct socket **new_sock);extern const struct inet_connection_sock_af_ops ipv4_specific;
@@ -215,10 +224,12 @@ void mptcp_finish_join(struct sock *sk);void token_init (void );void token_new_request (struct request_sock *req,const struct sk_buff *skb);int token_join_request (struct request_sock *req,const struct sk_buff *skb); +int token_join_response (struct sock *sk);int token_join_valid (struct request_sock *req,struct tcp_options_received *rx_opt);void token_destroy_request (u32 token);void token_new_connect (struct sock *sk); +void token_new_subflow (struct sock *sk);void token_new_accept (struct sock *sk);int token_new_join (struct sock *sk);void token_update_accept (struct sock *sk,struct sock *conn);
net/mptcp/subflow.c +67 -1
92 lines not on this page · raw message
net/mptcp/token.c +48 -0
66 lines not on this page · raw message
Signature · 1 line
2.17.2
Mat Martineau
Re: [MPTCP] [PATCH v3 08/10] mptcp: Add handling of outgoing MP_JOIN requests
Quoted 312 lines · Peter Krystad
Subflow creation may be initiated by the path manager when the primary connection is fully established and a remote address has been received via
ADD_ADDR.Create an in-kernel sock and use
kernel_connect()to initiate connection. When a valid SYN-ACK is received the new sock is added to the tail of the mptcp sockconn_listwhere it will not interfere with data flow on the original connection.Data flow and connection failover not addressed by this commit.
Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>---
include/net/mptcp.h | 2 ++ net/mptcp/options.c | 51 ++++++++++++++++++++++++++++++--- net/mptcp/protocol.c | 1 + net/mptcp/protocol.h | 11 +++++++ net/mptcp/subflow.c | 68 +++++++++++++++++++++++++++++++++++++++++++- net/mptcp/token.c | 48 +++++++++++++++++++++++++++++++ 6 files changed, 176 insertions(+), 5 deletions(-)include/net/mptcp.h +2
-0@@ -40,6 +40,8 @@ struct mptcp_out_options {u8 backup;u32 nonce;u64 thmac; +u32 token; +u8 hmac[20 ];struct mptcp_ext ext_copy;#endif };net/mptcp/options.c +47
-4@@ -300,6 +300,16 @@ bool mptcp_syn_options(struct sock *sk, unsigned int *size, opts->sndr_key = subflow->local_key; *size =TCPOLEN_MPTCP_MPC_SYN ;return true; + }else if (subflow->request_join) { +pr_debug ("remote_token=%u, nonce=%u" , subflow->remote_token, + subflow->local_nonce); + opts->suboptions =OPTION_MPTCP_MPJ_SYN ; + opts->join_id = subflow->remote_id; + opts->token = subflow->remote_token; + opts->nonce = subflow->local_nonce; + opts->backup = subflow->request_bkup; + *size =TCPOLEN_MPTCP_MPJ_SYN ; +return true; }return false; }@@ -309,10 +319,17 @@ void mptcp_rcv_synsent(struct sock *sk)struct tcp_sock *tp =tcp_sk (sk);struct subflow_context *subflow =subflow_ctx (sk); -pr_debug ("subflow=%p" , subflow);if (subflow->request_mptcp && tp->rx_opt.mptcp.mp_capable) { subflow->mp_capable =1 ; subflow->remote_key = tp->rx_opt.mptcp.sndr_key; +pr_debug ("subflow=%p, remote_key=%llu" , subflow, + subflow->remote_key); + }else if (subflow->request_join && tp->rx_opt.mptcp.mp_join) { + subflow->mp_join =1 ; + subflow->thmac = tp->rx_opt.mptcp.thmac; + subflow->remote_nonce = tp->rx_opt.mptcp.nonce; +pr_debug ("subflow=%p, thmac=%llu, remote_nonce=%u" , subflow, + subflow->thmac, subflow->remote_nonce); } }@@ -322,7 +339,8 @@ static bool mptcp_established_options_mp(struct sock *sk, unsigned int *size, {struct subflow_context *subflow =subflow_ctx (sk); -if (!subflow->fourth_ack && remaining >=TCPOLEN_MPTCP_MPC_ACK ) { +if (subflow->mp_capable && !subflow->fourth_ack && + remaining >=TCPOLEN_MPTCP_MPC_ACK ) { opts->suboptions =OPTION_MPTCP_MPC_ACK ; opts->sndr_key = subflow->local_key; opts->rcvr_key = subflow->remote_key;@@ -331,6 +349,14 @@ static bool mptcp_established_options_mp(struct sock *sk, unsigned int *size,pr_debug ("subflow=%p, local_key=%llu, remote_key=%llu" , subflow, subflow->local_key, subflow->remote_key);return true; + }else if (subflow->mp_join && !subflow->fourth_ack && + remaining >=TCPOLEN_MPTCP_MPJ_ACK ) { + 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); +return true; }return false; }@@ -443,10 +469,11 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, unsigned int *size, unsigned int remaining, struct mptcp_out_options *opts) { + struct subflow_context *subflow = subflow_ctx(sk);unsigned int opt_size =0 ;bool ret = false; -if (!subflow_ctx (sk)->mp_capable) +if (!subflow->mp_capable && !subflow->mp_join)return false; opts->suboptions =0 ;@@ -546,7 +573,6 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,if (msk)pm_fully_established (msk); - }void mptcp_write_options (__be32 *ptr,struct mptcp_out_options *opts)@@ -595,6 +621,16 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts) 0, opts->addr_id); } +if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) { + *ptr++ =mptcp_option (MPTCPOPT_MP_JOIN , +TCPOLEN_MPTCP_MPJ_SYN , + opts->backup, opts->join_id); +put_unaligned_be32 (opts->token, ptr); + ptr +=1 ; +put_unaligned_be32 (opts->nonce, ptr); + ptr +=1 ; + } +if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) { *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN, TCPOLEN_MPTCP_MPJ_SYNACK,@@ -605,6 +641,13 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts) ptr +=1 ; } +if (OPTION_MPTCP_MPJ_ACK & opts->suboptions) { + *ptr++ =mptcp_option (MPTCPOPT_MP_JOIN , +TCPOLEN_MPTCP_MPJ_ACK ,0 ,0 ); +memcpy (ptr, opts->hmac,MPTCPOPT_HMAC_LEN ); + ptr +=5 ; + } +if (opts->ext_copy.use_ack || opts->ext_copy.use_map) {struct mptcp_ext *mpext = &opts->ext_copy;u8 len =TCPOLEN_MPTCP_DSS_BASE ;net/mptcp/protocol.c +1
-0@@ -797,6 +797,7 @@ void mptcp_finish_connect(struct sock *sk, int mp_capable) msk->local_key = subflow->local_key; msk->token = subflow->token;pr_debug ("msk=%p, token=%u" , msk, msk->token); + msk->dport =ntohs (inet_sk (msk->subflow->sk)->inet_dport);pm_new_connection (msk,0 );net/mptcp/protocol.h +11
-0@@ -49,8 +49,10 @@#define TCPOLEN_MPTCP_ADD_ADDR6 20#define TCPOLEN_MPTCP_RM_ADDR 4 +/* MPTCP MP_JOIN flags */ #define MPTCPOPT_BACKUP BIT(0)#define MPTCPOPT_HMAC_LEN 20 +#define MPTCPOPT_THMAC_LEN 8/* MPTCP MP_CAPABLE flags */ #define MPTCP_VERSION_MASK (0x0F)@@ -115,6 +117,7 @@ struct mptcp_sock {u64 write_seq;u64 ack_seq;u32 token; +u16 dport;struct list_head conn_list;struct socket *subflow;/* outgoing connect/listener/!mp_capable */ struct mptcp_pm_data pm;@@ -167,7 +170,9 @@ struct subflow_context {u32 ssn_offset;u16 map_data_len; u16 request_mptcp : 1, /* send MP_CAPABLE */ + request_join : 1, /* send MP_JOIN */ request_cksum : 1, + request_bkup : 1, request_version : 4, mp_capable : 1, /* remote is MPTCP capable */ mp_join : 1, /* remote is JOINing */@@ -179,6 +184,8 @@ struct subflow_context {u32 remote_nonce;u64 thmac;u32 local_nonce; +u32 remote_token; +u8 hmac[MPTCPOPT_HMAC_LEN ];u8 local_id;u8 remote_id;@@ -202,6 +209,8 @@ mptcp_subflow_tcp_socket(const struct subflow_context *subflow) }void subflow_init (void ); +int subflow_connect (struct sock *sk,struct sockaddr_in *local, +struct sockaddr_in *remote,u8 remote_id);int subflow_create_socket (struct sock *sk,struct socket **new_sock);extern const struct inet_connection_sock_af_ops ipv4_specific;@@ -215,10 +224,12 @@ void mptcp_finish_join(struct sock *sk);void token_init (void );void token_new_request (struct request_sock *req,const struct sk_buff *skb);int token_join_request (struct request_sock *req,const struct sk_buff *skb); +int token_join_response (struct sock *sk);int token_join_valid (struct request_sock *req,struct tcp_options_received *rx_opt);void token_destroy_request (u32 token);void token_new_connect (struct sock *sk); +void token_new_subflow (struct sock *sk);void token_new_accept (struct sock *sk);int token_new_join (struct sock *sk);void token_update_accept (struct sock *sk,struct sock *conn);net/mptcp/subflow.c +54
-1@@ -22,6 +22,9 @@ static int subflow_rebuild_header(struct sock *sk)if (subflow->request_mptcp && !subflow->token) {pr_debug ("subflow=%p" , sk);token_new_connect (sk); + }else if (subflow->request_join && !subflow->local_nonce) { +pr_debug ("subflow=%p" , sk); +token_new_subflow (sk); }return inet_sk_rebuild_header (sk);@@ -95,7 +98,10 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)inet_sk_rx_dst_set (sk, skb); -if (subflow->conn && !subflow->conn_finished) { +if (!subflow->conn) +return ; + +if (subflow->mp_capable && !subflow->conn_finished) {pr_debug ("subflow=%p, remote_key=%llu" ,subflow_ctx (sk), subflow->remote_key);mptcp_finish_connect (subflow->conn, subflow->mp_capable);@@ -105,6 +111,17 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)pr_debug ("synack seq=%u" ,TCP_SKB_CB (skb)->seq); subflow->ssn_offset =TCP_SKB_CB (skb)->seq; } + }else if (subflow->mp_join && !subflow->conn_finished) { +pr_debug ("subflow=%p, thmac=%llu, remote_nonce=%u" , +subflow_ctx (sk), subflow->thmac, + subflow->remote_nonce); +if (token_join_response (sk)) { + subflow->mp_join =0 ; +// @@ need to trigger RST + }else { +mptcp_finish_join (sk); + subflow->conn_finished =1 ; + } } }@@ -195,6 +212,55 @@ static void subflow_data_ready(struct sock *sk) } } +int subflow_connect (struct sock *sk,struct sockaddr_in *local, +struct sockaddr_in *remote,u8 remote_id) +{ +struct mptcp_sock *msk =mptcp_sk (sk); +struct subflow_context *subflow; +struct socket *sf; +u32 remote_token; +int err; + +lock_sock (sk); + err =subflow_create_socket (sk, &sf); +if (err) { +release_sock (sk); +return err; + } + + subflow =subflow_ctx (sf->sk); + subflow->remote_key = msk->remote_key; + subflow->local_key = msk->local_key; + subflow->token = msk->token; + +sock_hold (sf->sk); +release_sock (sk); + + err =kernel_bind (sf, (struct sockaddr *)local, +sizeof (struct sockaddr_in )); +if (err) + goto failed; + +crypto_key_sha1 (subflow->remote_key, &remote_token,NULL ); +pr_debug ("msk=%p remote_token=%u" , msk, remote_token); + subflow->remote_token = remote_token; + subflow->remote_id = remote_id; + subflow->request_join =1 ; + subflow->request_bkup =1 ; +
net/mptcp/subflow.c static void subflow_data_ready(struct sock *sk) · line 260
Quoted 10 lines
net/mptcp/subflow.c +10
-0+ err =kernel_connect (sf, (struct sockaddr *)remote, +sizeof (struct sockaddr_in ),O_NONBLOCK ); +if (err && err != -EINPROGRESS ) + goto failed; + +sock_put (sf->sk); +return err; + +failed: +sock_release (sf);
Should there be a sock_put(sf->sk) on this path too? Looks like sock_release() will free the subflow context but not the struct sock itself.
Mat
Quoted 87 lines
net/mptcp/subflow.c +3
-0+return err; +} +int subflow_create_socket (struct sock *sk,struct socket **new_sock) {struct subflow_context *subflow;net/mptcp/token.c +48
-0@@ -93,6 +93,28 @@ static void new_req_join(struct request_sock *req, struct sock *sk, subflow_req->thmac); } +static int new_rsp_join (struct sock *sk) +{ +struct subflow_context *subflow =subflow_ctx (sk); +u8 hmac[MPTCPOPT_HMAC_LEN ]; +u64 thmac; + +crypto_hmac_sha1 (subflow->remote_key, subflow->local_key, + subflow->remote_nonce, subflow->local_nonce, + (u32 *)hmac); + + thmac =get_unaligned_be64 (hmac); +pr_debug ("thmac=%llu" , thmac); +if (thmac != subflow->thmac) +return -1 ; + +crypto_hmac_sha1 (subflow->local_key, subflow->remote_key, + subflow->local_nonce, subflow->remote_nonce, + (u32 *)subflow->hmac); + +return 0 ; +} +static int new_join_valid (struct request_sock *req,struct sock *sk,struct tcp_options_received *rx_opt) {@@ -210,6 +232,15 @@ int token_join_request(struct request_sock *req, const struct sk_buff *skb)return -1 ; } +/* validate received truncated hmac and create hmac for third ACK */ +int token_join_response (struct sock *sk) +{ +struct subflow_context *subflow =subflow_ctx (sk); + +pr_debug ("subflow=%p, token=%u" , subflow, subflow->token); +return new_rsp_join (sk); +} +/* validate hmac received in third ACK */ int token_join_valid (struct request_sock *req,struct tcp_options_received *rx_opt)@@ -247,6 +278,23 @@ void token_new_connect(struct sock *sk)spin_unlock_bh (&token_tree_lock); } +/* take reference to connection and create nonce for secondary subflow */ +void token_new_subflow (struct sock *sk) +{ +struct subflow_context *subflow =subflow_ctx (sk); +struct sock *conn; + +pr_debug ("subflow=%p" , subflow); + +spin_lock_bh (&token_tree_lock); + conn =lookup_token (subflow->token); +if (conn) +sock_hold (conn); +spin_unlock_bh (&token_tree_lock); + +get_random_bytes (&subflow->local_nonce,sizeof (u32)); +} +void token_new_accept (struct sock *sk) {struct subflow_context *subflow =subflow_ctx (sk);Signature · 6 lines
2.17.2 _______________________________________________ mptcp mailing list mptcp(a)lists.01.org https://lists.01.org/mailman/listinfo/mptcp
--
Mat Martineau
Intel
Matthieu Baerts
Re: [MPTCP] [PATCH v3 08/10] mptcp: Add handling of outgoing MP_JOIN requests
Hi Mat, Peter,
Quoted 1 line · Mat Martineau
On Wed, 7 Aug 2019, Peter Krystad wrote:
(...)
Quoted 4 lines
Quoted 4 lines
net/mptcp/subflow.c +0
-0
(...)
Quoted 46 lines
Quoted 46 lines
net/mptcp/subflow.c +42
-0@@ -195,6 +212,55 @@ static void subflow_data_ready(struct sock *sk) } } +int subflow_connect (struct sock *sk,struct sockaddr_in *local, + struct sockaddr_in *remote, u8 remote_id) +{ + struct mptcp_sock *msk = mptcp_sk(sk); + struct subflow_context *subflow; + struct socket *sf; + u32 remote_token; + int err; + + lock_sock(sk); + err = subflow_create_socket(sk, &sf); + if (err) { + release_sock(sk); + return err; + } + + subflow = subflow_ctx(sf->sk); + subflow->remote_key = msk->remote_key; + subflow->local_key = msk->local_key; + subflow->token = msk->token; + + sock_hold(sf->sk); + release_sock(sk); + + err = kernel_bind(sf, (struct sockaddr *)local, + sizeof(struct sockaddr_in)); + if (err) + goto failed; + + crypto_key_sha1(subflow->remote_key, &remote_token, NULL); + pr_debug("msk=%p remote_token=%u", msk, remote_token); + subflow->remote_token = remote_token; + subflow->remote_id = remote_id; + subflow->request_join = 1; + subflow->request_bkup = 1; + + err = kernel_connect(sf, (struct sockaddr *)remote, + sizeof(struct sockaddr_in), O_NONBLOCK); + if (err && err != -EINPROGRESS) + goto failed; + + sock_put(sf->sk);
Quoted 8 lines
net/mptcp/subflow.c static void subflow_data_ready(struct sock *sk) · line 260
Quoted 4 lines
net/mptcp/subflow.c +4
-0+ return err; + +failed: + sock_release(sf);Should there be a
sock_put(sf->sk)on this path too? Looks likesock_release()will free the subflow context but not the struct sock itself.
Please note that I just applied this patch series. But do not hesitate to create a new patch to fix this if needed!
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
Peter Krystad
Re: [MPTCP] [PATCH v3 08/10] mptcp: Add handling of outgoing MP_JOIN requests
In reply to Mat MartineauQuoted 320 lines · Mat Martineau
Quoted 318 lines · Peter Krystad
Subflow creation may be initiated by the path manager when the primary connection is fully established and a remote address has been received via
ADD_ADDR.Create an in-kernel sock and use
kernel_connect()to initiate connection. When a valid SYN-ACK is received the new sock is added to the tail of the mptcp sockconn_listwhere it will not interfere with data flow on the original connection.Data flow and connection failover not addressed by this commit.
Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>---
include/net/mptcp.h | 2 ++ net/mptcp/options.c | 51 ++++++++++++++++++++++++++++++--- net/mptcp/protocol.c | 1 + net/mptcp/protocol.h | 11 +++++++ net/mptcp/subflow.c | 68 +++++++++++++++++++++++++++++++++++++++++++- net/mptcp/token.c | 48 +++++++++++++++++++++++++++++++ 6 files changed, 176 insertions(+), 5 deletions(-)include/net/mptcp.h +2
-0@@ -40,6 +40,8 @@ struct mptcp_out_options {u8 backup;u32 nonce;u64 thmac; +u32 token; +u8 hmac[20 ];struct mptcp_ext ext_copy;#endif };net/mptcp/options.c +47
-4@@ -300,6 +300,16 @@ bool mptcp_syn_options(struct sock *sk, unsigned int *size, opts->sndr_key = subflow->local_key; *size =TCPOLEN_MPTCP_MPC_SYN ;return true; + }else if (subflow->request_join) { +pr_debug ("remote_token=%u, nonce=%u" , subflow->remote_token, + subflow->local_nonce); + opts->suboptions =OPTION_MPTCP_MPJ_SYN ; + opts->join_id = subflow->remote_id; + opts->token = subflow->remote_token; + opts->nonce = subflow->local_nonce; + opts->backup = subflow->request_bkup; + *size =TCPOLEN_MPTCP_MPJ_SYN ; +return true; }return false; }@@ -309,10 +319,17 @@ void mptcp_rcv_synsent(struct sock *sk)struct tcp_sock *tp =tcp_sk (sk);struct subflow_context *subflow =subflow_ctx (sk); -pr_debug ("subflow=%p" , subflow);if (subflow->request_mptcp && tp->rx_opt.mptcp.mp_capable) { subflow->mp_capable =1 ; subflow->remote_key = tp->rx_opt.mptcp.sndr_key; +pr_debug ("subflow=%p, remote_key=%llu" , subflow, + subflow->remote_key); + }else if (subflow->request_join && tp->rx_opt.mptcp.mp_join) { + subflow->mp_join =1 ; + subflow->thmac = tp->rx_opt.mptcp.thmac; + subflow->remote_nonce = tp->rx_opt.mptcp.nonce; +pr_debug ("subflow=%p, thmac=%llu, remote_nonce=%u" , subflow, + subflow->thmac, subflow->remote_nonce); } }@@ -322,7 +339,8 @@ static bool mptcp_established_options_mp(struct sock *sk, unsigned int *size, {struct subflow_context *subflow =subflow_ctx (sk); -if (!subflow->fourth_ack && remaining >=TCPOLEN_MPTCP_MPC_ACK ) { +if (subflow->mp_capable && !subflow->fourth_ack && + remaining >=TCPOLEN_MPTCP_MPC_ACK ) { opts->suboptions =OPTION_MPTCP_MPC_ACK ; opts->sndr_key = subflow->local_key; opts->rcvr_key = subflow->remote_key;@@ -331,6 +349,14 @@ static bool mptcp_established_options_mp(struct sock *sk, unsigned int *size,pr_debug ("subflow=%p, local_key=%llu, remote_key=%llu" , subflow, subflow->local_key, subflow->remote_key);return true; + }else if (subflow->mp_join && !subflow->fourth_ack && + remaining >=TCPOLEN_MPTCP_MPJ_ACK ) { + 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); +return true; }return false; }@@ -443,10 +469,11 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, unsigned int *size, unsigned int remaining, struct mptcp_out_options *opts) { + struct subflow_context *subflow = subflow_ctx(sk);unsigned int opt_size =0 ;bool ret = false; -if (!subflow_ctx (sk)->mp_capable) +if (!subflow->mp_capable && !subflow->mp_join)return false; opts->suboptions =0 ;@@ -546,7 +573,6 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,if (msk)pm_fully_established (msk); - }void mptcp_write_options (__be32 *ptr,struct mptcp_out_options *opts)@@ -595,6 +621,16 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts) 0, opts->addr_id); } +if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) { + *ptr++ =mptcp_option (MPTCPOPT_MP_JOIN , +TCPOLEN_MPTCP_MPJ_SYN , + opts->backup, opts->join_id); +put_unaligned_be32 (opts->token, ptr); + ptr +=1 ; +put_unaligned_be32 (opts->nonce, ptr); + ptr +=1 ; + } +if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) { *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN, TCPOLEN_MPTCP_MPJ_SYNACK,@@ -605,6 +641,13 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts) ptr +=1 ; } +if (OPTION_MPTCP_MPJ_ACK & opts->suboptions) { + *ptr++ =mptcp_option (MPTCPOPT_MP_JOIN , +TCPOLEN_MPTCP_MPJ_ACK ,0 ,0 ); +memcpy (ptr, opts->hmac,MPTCPOPT_HMAC_LEN ); + ptr +=5 ; + } +if (opts->ext_copy.use_ack || opts->ext_copy.use_map) {struct mptcp_ext *mpext = &opts->ext_copy;u8 len =TCPOLEN_MPTCP_DSS_BASE ;net/mptcp/protocol.c +1
-0@@ -797,6 +797,7 @@ void mptcp_finish_connect(struct sock *sk, int mp_capable) msk->local_key = subflow->local_key; msk->token = subflow->token;pr_debug ("msk=%p, token=%u" , msk, msk->token); + msk->dport =ntohs (inet_sk (msk->subflow->sk)->inet_dport);pm_new_connection (msk,0 );net/mptcp/protocol.h +11
-0@@ -49,8 +49,10 @@#define TCPOLEN_MPTCP_ADD_ADDR6 20#define TCPOLEN_MPTCP_RM_ADDR 4 +/* MPTCP MP_JOIN flags */ #define MPTCPOPT_BACKUP BIT(0)#define MPTCPOPT_HMAC_LEN 20 +#define MPTCPOPT_THMAC_LEN 8/* MPTCP MP_CAPABLE flags */ #define MPTCP_VERSION_MASK (0x0F)@@ -115,6 +117,7 @@ struct mptcp_sock {u64 write_seq;u64 ack_seq;u32 token; +u16 dport;struct list_head conn_list;struct socket *subflow;/* outgoing connect/listener/!mp_capable */ struct mptcp_pm_data pm;@@ -167,7 +170,9 @@ struct subflow_context {u32 ssn_offset;u16 map_data_len; u16 request_mptcp : 1, /* send MP_CAPABLE */ + request_join : 1, /* send MP_JOIN */ request_cksum : 1, + request_bkup : 1, request_version : 4, mp_capable : 1, /* remote is MPTCP capable */ mp_join : 1, /* remote is JOINing */@@ -179,6 +184,8 @@ struct subflow_context {u32 remote_nonce;u64 thmac;u32 local_nonce; +u32 remote_token; +u8 hmac[MPTCPOPT_HMAC_LEN ];u8 local_id;u8 remote_id;@@ -202,6 +209,8 @@ mptcp_subflow_tcp_socket(const struct subflow_context *subflow) }void subflow_init (void ); +int subflow_connect (struct sock *sk,struct sockaddr_in *local, +struct sockaddr_in *remote,u8 remote_id);int subflow_create_socket (struct sock *sk,struct socket **new_sock);extern const struct inet_connection_sock_af_ops ipv4_specific;@@ -215,10 +224,12 @@ void mptcp_finish_join(struct sock *sk);void token_init (void );void token_new_request (struct request_sock *req,const struct sk_buff *skb);int token_join_request (struct request_sock *req,const struct sk_buff *skb); +int token_join_response (struct sock *sk);int token_join_valid (struct request_sock *req,struct tcp_options_received *rx_opt);void token_destroy_request (u32 token);void token_new_connect (struct sock *sk); +void token_new_subflow (struct sock *sk);void token_new_accept (struct sock *sk);int token_new_join (struct sock *sk);void token_update_accept (struct sock *sk,struct sock *conn);net/mptcp/subflow.c +60
-1@@ -22,6 +22,9 @@ static int subflow_rebuild_header(struct sock *sk)if (subflow->request_mptcp && !subflow->token) {pr_debug ("subflow=%p" , sk);token_new_connect (sk); + }else if (subflow->request_join && !subflow->local_nonce) { +pr_debug ("subflow=%p" , sk); +token_new_subflow (sk); }return inet_sk_rebuild_header (sk);@@ -95,7 +98,10 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)inet_sk_rx_dst_set (sk, skb); -if (subflow->conn && !subflow->conn_finished) { +if (!subflow->conn) +return ; + +if (subflow->mp_capable && !subflow->conn_finished) {pr_debug ("subflow=%p, remote_key=%llu" ,subflow_ctx (sk), subflow->remote_key);mptcp_finish_connect (subflow->conn, subflow->mp_capable);@@ -105,6 +111,17 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)pr_debug ("synack seq=%u" ,TCP_SKB_CB (skb)->seq); subflow->ssn_offset =TCP_SKB_CB (skb)->seq; } + }else if (subflow->mp_join && !subflow->conn_finished) { +pr_debug ("subflow=%p, thmac=%llu, remote_nonce=%u" , +subflow_ctx (sk), subflow->thmac, + subflow->remote_nonce); +if (token_join_response (sk)) { + subflow->mp_join =0 ; +// @@ need to trigger RST + }else { +mptcp_finish_join (sk); + subflow->conn_finished =1 ; + } } }@@ -195,6 +212,55 @@ static void subflow_data_ready(struct sock *sk) } } +int subflow_connect (struct sock *sk,struct sockaddr_in *local, +struct sockaddr_in *remote,u8 remote_id) +{ +struct mptcp_sock *msk =mptcp_sk (sk); +struct subflow_context *subflow; +struct socket *sf; +u32 remote_token; +int err; + +lock_sock (sk); + err =subflow_create_socket (sk, &sf); +if (err) { +release_sock (sk); +return err; + } + + subflow =subflow_ctx (sf->sk); + subflow->remote_key = msk->remote_key; + subflow->local_key = msk->local_key; + subflow->token = msk->token; + +sock_hold (sf->sk); +release_sock (sk); + + err =kernel_bind (sf, (struct sockaddr *)local, +sizeof (struct sockaddr_in )); +if (err) + goto failed; + +crypto_key_sha1 (subflow->remote_key, &remote_token,NULL ); +pr_debug ("msk=%p remote_token=%u" , msk, remote_token); + subflow->remote_token = remote_token; + subflow->remote_id = remote_id; + subflow->request_join =1 ; + subflow->request_bkup =1 ; + + err =kernel_connect (sf, (struct sockaddr *)remote, +sizeof (struct sockaddr_in ),O_NONBLOCK ); +if (err && err != -EINPROGRESS ) + goto failed; + +sock_put (sf->sk);
Quoted 9 lines
net/mptcp/subflow.c static void subflow_data_ready(struct sock *sk) · line 260
Quoted 4 lines
net/mptcp/subflow.c +4
-0+return err; + +failed: +sock_release (sf);Should there be a
sock_put(sf->sk)on this path too? Looks likesock_release()will free the subflow context but not the struct sock itself.
Yes. Since this is already merged I'll submit a separate patch.
Peter.
Quoted 94 lines
Mat
Quoted 87 lines
net/mptcp/subflow.c +3
-0+return err; +} +int subflow_create_socket (struct sock *sk,struct socket **new_sock) {struct subflow_context *subflow;net/mptcp/token.c +48
-0@@ -93,6 +93,28 @@ static void new_req_join(struct request_sock *req, struct sock *sk, subflow_req->thmac); } +static int new_rsp_join (struct sock *sk) +{ +struct subflow_context *subflow =subflow_ctx (sk); +u8 hmac[MPTCPOPT_HMAC_LEN ]; +u64 thmac; + +crypto_hmac_sha1 (subflow->remote_key, subflow->local_key, + subflow->remote_nonce, subflow->local_nonce, + (u32 *)hmac); + + thmac =get_unaligned_be64 (hmac); +pr_debug ("thmac=%llu" , thmac); +if (thmac != subflow->thmac) +return -1 ; + +crypto_hmac_sha1 (subflow->local_key, subflow->remote_key, + subflow->local_nonce, subflow->remote_nonce, + (u32 *)subflow->hmac); + +return 0 ; +} +static int new_join_valid (struct request_sock *req,struct sock *sk,struct tcp_options_received *rx_opt) {@@ -210,6 +232,15 @@ int token_join_request(struct request_sock *req, const struct sk_buff *skb)return -1 ; } +/* validate received truncated hmac and create hmac for third ACK */ +int token_join_response (struct sock *sk) +{ +struct subflow_context *subflow =subflow_ctx (sk); + +pr_debug ("subflow=%p, token=%u" , subflow, subflow->token); +return new_rsp_join (sk); +} +/* validate hmac received in third ACK */ int token_join_valid (struct request_sock *req,struct tcp_options_received *rx_opt)@@ -247,6 +278,23 @@ void token_new_connect(struct sock *sk)spin_unlock_bh (&token_tree_lock); } +/* take reference to connection and create nonce for secondary subflow */ +void token_new_subflow (struct sock *sk) +{ +struct subflow_context *subflow =subflow_ctx (sk); +struct sock *conn; + +pr_debug ("subflow=%p" , subflow); + +spin_lock_bh (&token_tree_lock); + conn =lookup_token (subflow->token); +if (conn) +sock_hold (conn); +spin_unlock_bh (&token_tree_lock); + +get_random_bytes (&subflow->local_nonce,sizeof (u32)); +} +void token_new_accept (struct sock *sk) {struct subflow_context *subflow =subflow_ctx (sk);Signature · 6 lines
2.17.2 _______________________________________________ mptcp mailing list mptcp(a)lists.01.org https://lists.01.org/mailman/listinfo/mptcp--
Mat Martineau
Intel
Matthieu Baerts
Re: [MPTCP] [PATCH v3 08/10] mptcp: Add handling of outgoing MP_JOIN requests
In reply to Peter KrystadHi Peter, Paolo, Mat,
Quoted 11 lines · Peter Krystad
Subflow creation may be initiated by the path manager when the primary connection is fully established and a remote address has been received via
ADD_ADDR.Create an in-kernel sock and use
kernel_connect()to initiate connection. When a valid SYN-ACK is received the new sock is added to the tail of the mptcp sockconn_listwhere it will not interfere with data flow on the original connection.Data flow and connection failover not addressed by this commit.
Thank you for the patch and the reviews!
Added at the end of the series:
- 31bf10533d43: "new commit" in
t/mptcp-Add-handling-of-outgoing-MP_JOIN-requests
- 417bdddfeedd..f7d9e8ce4717: result
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
Peter Krystad
PATCH v3 9/10 Use pm_get_local_id() to get the real local address id.
In reply to Peter KrystadAlso, take reference to mptcp sock while using it
squashto: Add handling of incoming MP_JOIN requests
--- net/mptcp/token.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-)
net/mptcp/token.c +22 -9
@@ -222,14 +222,22 @@ int token_join_request(struct request_sock *req, const struct sk_buff *skb)pr_debug ("subflow_req=%p, token=%u" , subflow_req, subflow_req->token);spin_lock_bh (&token_tree_lock); conn =lookup_token (subflow_req->token); +if (conn) +sock_hold (conn);spin_unlock_bh (&token_tree_lock); -if (conn) { -// @@ get real local address id for this skb->saddr - subflow_req->local_id =0 ; -new_req_join (req, conn, skb); -return 0 ; + +if (!conn) +return -1 ; + +if (pm_get_local_id (req, conn, skb)) { +sock_put (conn); +return -1 ; } -return -1 ; + +new_req_join (req, conn, skb); + +sock_put (conn); +return 0 ; }/* validate received truncated hmac and create hmac for third ACK */
@@ -247,15 +255,20 @@ int token_join_valid(struct request_sock *req, {struct subflow_request_sock *subflow_req =subflow_rsk (req);struct sock *conn; +int err;pr_debug ("subflow_req=%p, token=%u" , subflow_req, subflow_req->token);spin_lock_bh (&token_tree_lock); conn =lookup_token (subflow_req->token); -spin_unlock_bh (&token_tree_lock);if (conn) -return new_join_valid (req, conn, rx_opt); +sock_hold (conn); +spin_unlock_bh (&token_tree_lock); +if (!conn) +return -1 ; -return -1 ; + err =new_join_valid (req, conn, rx_opt); +sock_put (conn); +return err; }/* create new local key, idsn, and token for subflow */
Signature · 1 line
2.17.2
Matthieu Baerts
Re: [MPTCP] [PATCH v3 09/10] Use pm_get_local_id() to get the real local address id.
Hi Peter, Paolo, Mat,
Quoted 3 lines · Peter Krystad
Also, take reference to mptcp sock while using it
squashto: Add handling of incoming
MP_JOINrequests
Thank you for the patch and the reviews!
- 05f13c173cb5: "squashed" in "mptcp: Add handling of incoming MP_JOIN requests"
- 6c6c0f074bf5..417bdddfeedd: result
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
Peter Krystad
PATCH v3 10/10 mptcp: Implement path manager interface commands
In reply to Peter KrystadUse the addr_signal flag to indicate to the subflow layer that a local address may be announced, and call subflow_connect() to initiate a secondary subflow.
--- net/mptcp/pm.c | 62 +++++++++++++++++++++++++++++++++++++++++--- net/mptcp/protocol.h | 1 + net/mptcp/token.c | 13 ++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-)
net/mptcp/pm.c +59 -3
@@ -13,17 +13,73 @@int pm_announce_addr (u32 token,sa_family_t family,u8 local_id,struct in_addr *addr) { -return -ENOTSUPP ; +struct mptcp_sock *msk =mptcp_sk (token_lookup_get (token)); +int err =0 ; + +if (!msk) +return -EINVAL ; + +if (msk->pm.local_valid) { + err = -EBADR ; + goto announce_put; + } + +pr_debug ("msk=%p, local_id=%d, addr=%x" , msk, local_id, addr->s_addr); + msk->pm.local_valid =1 ; + msk->pm.local_id = local_id; + msk->pm.local_family = family; + msk->pm.local_addr.s_addr = addr->s_addr; + msk->addr_signal =1 ; + +announce_put: +sock_put ((struct sock *)msk); +return err; }int pm_remove_addr (u32 token,u8 local_id) { -return -ENOTSUPP ; +struct mptcp_sock *msk =mptcp_sk (token_lookup_get (token)); + +if (!msk) +return -EINVAL ; + +pr_debug ("msk=%p" , msk); + msk->pm.local_valid =0 ; + +sock_put ((struct sock *)msk); +return 0 ; }int pm_create_subflow (u32 token,u8 remote_id) { -return -ENOTSUPP ; +struct mptcp_sock *msk =mptcp_sk (token_lookup_get (token)); +struct sockaddr_in remote; +struct sockaddr_in local; +int err; + +if (!msk) +return -EINVAL ; + +pr_debug ("msk=%p" , msk); + +if (!msk->pm.remote_valid || remote_id != msk->pm.remote_id) { + err = -EBADR ; + goto create_put; + } + + local.sin_family =AF_INET ; + local.sin_port =0 ; + local.sin_addr.s_addr =INADDR_ANY ; + + remote.sin_family = msk->pm.remote_family; + remote.sin_port =htons (msk->dport); + remote.sin_addr.s_addr =htonl (msk->pm.remote_addr.s_addr); + + err =subflow_connect ((struct sock *)msk, &local, &remote, remote_id); + +create_put: +sock_put ((struct sock *)msk); +return err; }int pm_remove_subflow (u32 token,u8 remote_id)
net/mptcp/protocol.h +1 -0
@@ -233,6 +233,7 @@ void token_new_subflow(struct sock *sk);void token_new_accept (struct sock *sk);int token_new_join (struct sock *sk);void token_update_accept (struct sock *sk,struct sock *conn); +struct sock *token_lookup_get (u32 token);void token_release (u32 token);void token_destroy (u32 token);
net/mptcp/token.c +13 -0
@@ -348,6 +348,19 @@ int token_new_join(struct sock *sk)return -1 ; } +struct sock *token_lookup_get (u32 token) +{ +struct sock *conn; + +spin_lock_bh (&token_tree_lock); + conn =lookup_token (token); +if (conn) +sock_hold (conn); + +spin_unlock_bh (&token_tree_lock); +return conn; +} +void token_destroy_request (u32 token) {pr_debug ("token=%u" , token);
Signature · 1 line
2.17.2
Matthieu Baerts
Re: [MPTCP] [PATCH v3 10/10] mptcp: Implement path manager interface commands
Hi Peter, Paolo, Mat,
Quoted 3 lines · Peter Krystad
Use the
addr_signalflag to indicate to the subflow layer that a local address may be announced, and callsubflow_connect()to initiate a secondary subflow.
Thank you for the patch and the reviews!
Added at the end of the series:
- 9ad3c22dcab0: "new commit" in
t/mptcp-Implement-path-manager-interface-commands
- f7d9e8ce4717..2038a22e9690: result
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
Hi all,
Quoted 31 lines · Peter Krystad
This is several accumulated fixes that are required for
MP_JOIN(secondary subflows) plus the outgoing code.Both outgoing and incoming
MP_JOINnow inter-operate with the multipath.org implementation although there is still a deadlock when incoming is fully established. Since the incoming direction did not work at all before this is an improvement. I have not yet tested running our implmentation against itself.The final patch in the set is an "interim path manager", this is throw-away code that I include for testing purposes. For an incoming connection it is necessary for the server to advertise a secondary address and for my testing I have been hard-coding the IP address of my secondary interface when I build the kernel. Obviously not the final solution but we need to discuss what approach to use for the self tests. I also think we may not want to publish this patch on our net-next branch.
v2:
- movemptcp_options_receivedformatting tooptions.c
- resolve conflicts with Davide's crypto commit
- make helper for setting request fields
- fix locking intoken_lookup()
- movetoken_lookup()to "Implement path manager interface commands:
(where it belongs)
- split interim path manager out of final commit, will submit seperately
- remove use oflocal_idinpm_create_subflow
- restrict announcing addresses to server side only
- add one more commit withget_local_idfix for incomingMP_JOIN
Quoted 12 lines
v3:
- Revise nested if logic inoptions.c
- setsubflow->request_cksumcorrectly (do not support)
- lockmptcp_sockinsubflow_connect()and take ref
- return EINPROGRESS fromsubflow_connect()in normal case
- cleanup socket when bind()/connect() fails insubflow_connect()
- take reference tomptcp_sockintoken_join_request()andtoken_join_valid()
- renametoken_lookup()totoken_lookup_get()
- track remote token seperately in subflow (previously local token field was being overwritten, preventing cleanup)
- take long-lived reference tomptcp_sockintoken_new_subflow
I went through the whole series and it looks like all my comments has been addressed, thank you Peter!
LGMT!
Paolo
Matthieu Baerts
Hi Peter, Paolo, Mat,
Quoted 46 lines · Paolo Abeni
Hi all,
Quoted 31 lines · Peter Krystad
This is several accumulated fixes that are required for
MP_JOIN(secondary subflows) plus the outgoing code.Both outgoing and incoming
MP_JOINnow inter-operate with the multipath.org implementation although there is still a deadlock when incoming is fully established. Since the incoming direction did not work at all before this is an improvement. I have not yet tested running our implmentation against itself.The final patch in the set is an "interim path manager", this is throw-away code that I include for testing purposes. For an incoming connection it is necessary for the server to advertise a secondary address and for my testing I have been hard-coding the IP address of my secondary interface when I build the kernel. Obviously not the final solution but we need to discuss what approach to use for the self tests. I also think we may not want to publish this patch on our net-next branch.
v2:
- movemptcp_options_receivedformatting tooptions.c
- resolve conflicts with Davide's crypto commit
- make helper for setting request fields
- fix locking intoken_lookup()
- movetoken_lookup()to "Implement path manager interface commands:
(where it belongs)
- split interim path manager out of final commit, will submit seperately
- remove use oflocal_idinpm_create_subflow
- restrict announcing addresses to server side only
- add one more commit withget_local_idfix for incomingMP_JOINQuoted 12 lines
v3:
- Revise nested if logic inoptions.c
- setsubflow->request_cksumcorrectly (do not support)
- lockmptcp_sockinsubflow_connect()and take ref
- return EINPROGRESS fromsubflow_connect()in normal case
- cleanup socket when bind()/connect() fails insubflow_connect()
- take reference tomptcp_sockintoken_join_request()andtoken_join_valid()
- renametoken_lookup()totoken_lookup_get()
- track remote token seperately in subflow (previously local token field was being overwritten, preventing cleanup)
- take long-lived reference tomptcp_sockintoken_new_subflow
Quoted 2 lines
I went through the whole series and it looks like all my comments has been addressed, thank you Peter!
Thank you for the patches and the reviews!
I just applied these 10 patches. Please check that everything looks good to you, especially the patches that I had to split in multiple ones and squash in different commits. Do not hesitate to tell me if the squashes were not in the right commits or if I have to change stuffs.
Note that I just saw Mat's email on the patch number 8. Feel free to continue the discussions there and create a new patch if needed.
The compilation is still OK. Tests are in progress. I will tell you tomorrow if there is an issue with them.
I think I applied all accepted patches on the list. Do not hesitate to tell me if other are also good to be applied ;)
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