MP_JOIN handling WIP
Subsystems (3)
Peter Krystad
cover MP_JOIN handling WIP
Current state of MP_JOIN handling. As I mentioned this is not functional yet but am sharing for visibility. The intent of this patchset is to complete the handshake for a second subflow in the incoming direction. Sending an outgoing SYN with MP_JOIN and the data path is not addressed.
It will already need some refactor due to Florian's changes to subflow list locking.
Peter Krystad (3):
mptcp: Slightly refactor mptcp_established_options_xxx()
mptcp: Add ADD_ADDR handling
mptcp: Add handling of incoming MP_JOIN requests
include/linux/tcp.h | 6 ++ include/net/mptcp.h | 44 ++++++++++++-- include/net/tcp.h | 6 ++ net/ipv4/tcp_minisocks.c | 6 ++ net/ipv4/tcp_output.c | 31 ++++++---- net/mptcp/Makefile | 2 +- net/mptcp/options.c | 127 ++++++++++++++++++++++++++++++++++++--- net/mptcp/pm.c | 24 ++++++++ net/mptcp/protocol.c | 24 ++++++++ net/mptcp/protocol.h | 45 +++++++++++++- net/mptcp/subflow.c | 42 +++++++++++++ net/mptcp/token.c | 124 ++++++++++++++++++++++++++++++++++++++ 12 files changed, 451 insertions(+), 30 deletions(-) create mode 100644 net/mptcp/pm.c
Signature · 1 line
2.17.2
Peter Krystad
RFC 1/3 mptcp: Slightly refactor mptcp_established_options_xxx()
Make mptcp_established_options_xxx() take the same parameter list and remove the restriction that MP_CAPABLE and DSS options may not be sent in the same header.
Split and squash to "Handle MP_CAPABLE options" and "Write MPTCP DSS headers".
--- include/net/mptcp.h | 7 +++++-- net/ipv4/tcp_output.c | 26 +++++++++++++------------- net/mptcp/options.c | 6 ++++-- 3 files changed, 22 insertions(+), 17 deletions(-)
include/net/mptcp.h +5 -2
@@ -69,8 +69,9 @@ bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, struct mptcp_out_options* opts);bool mptcp_synack_options (const struct request_sock *req,unsigned int *size,struct mptcp_out_options *opts); -bool mptcp_established_options (struct sock *sk,unsigned int *size, -struct mptcp_out_options *opts); +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);
@@ -126,7 +127,9 @@ static inline bool mptcp_synack_options(const struct request_sock *req, }static inline bool mptcp_established_options (struct sock *sk, +struct sk_buff *skb,unsigned int *size, +unsigned int remaining,struct mptcp_out_options *opts) {return false;
net/ipv4/tcp_output.c +13 -13
@@ -797,20 +797,20 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skbunsigned int remaining =MAX_TCP_OPTION_SPACE - size;unsigned int opt_size; -if (mptcp_established_options (sk, &opt_size, &opts->mptcp)) { -if (remaining >= opt_size) { - opts->options |=OPTION_MPTCP ; - size += opt_size; - } - }else { -unsigned int dss_size; +if (mptcp_established_options (sk, skb, &opt_size, + remaining, &opts->mptcp)) { + opts->options |=OPTION_MPTCP ; + size += opt_size; + remaining -= opt_size; + } + +if (mptcp_established_options_dss (sk, skb, &opt_size, + remaining, &opts->mptcp)) { + opts->options |=OPTION_MPTCP ; + size += opt_size; + remaining -= opt_size; + } -if (mptcp_established_options_dss (sk, skb, &dss_size, - remaining, - &opts->mptcp)) { - opts->options |=OPTION_MPTCP ; - size += dss_size; - } } }
net/mptcp/options.c +4 -2
@@ -240,13 +240,15 @@ void mptcp_rcv_synsent(struct sock *sk) } } -bool mptcp_established_options (struct sock *sk,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) {struct subflow_context *subflow =subflow_ctx (sk);pr_debug ("subflow=%p" , subflow); -if (subflow->mp_capable && !subflow->fourth_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;
Signature · 1 line
2.17.2
Paolo Abeni
Re: [MPTCP] [RFC 1/3] mptcp: Slightly refactor mptcp_established_options_xxx()
Hi,
Thank you for doing this and sharing the code early, very appreciated!
Quoted 28 lines · Peter Krystad
net/ipv4/tcp_output.c +13
-7@@ -797,20 +797,20 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skbunsigned int remaining =MAX_TCP_OPTION_SPACE - size;unsigned int opt_size; -if (mptcp_established_options (sk, &opt_size, &opts->mptcp)) { -if (remaining >= opt_size) { - opts->options |=OPTION_MPTCP ; - size += opt_size; - } - }else { -unsigned int dss_size; +if ((sk, skb, &opt_size, + remaining, &opts->mptcp)) { + opts->options |=OPTION_MPTCP ; + size += opt_size; + remaining -= opt_size; + } + +if (mptcp_established_options_dss (sk, skb, &opt_size, + remaining, &opts->mptcp)) { + opts->options |=OPTION_MPTCP ; + size += opt_size; + remaining -= opt_size; + }
net/ipv4/tcp_output.c static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb · line 816
Quoted 10 lines
net/ipv4/tcp_output.c +0
-6-if (mptcp_established_options_dss (sk, skb, &dss_size, - remaining, - &opts->mptcp)) { - opts->options |=OPTION_MPTCP ; - size += dss_size; - } } }
[Not strictly related to MP_JOIN] I think it could be possibly cleaner to expose to the TCP code a single mptcp_established_option() hook and handle there all the relevant cases ('plain', _dss() _addr() added by the next patch).
The mptcp code should not change much, and possibly it would remove a bunch of duplicate checks (about subflow->mp_capable).
Cheers,
Paolo
Peter Krystad
Re: [MPTCP] [RFC 1/3] mptcp: Slightly refactor mptcp_established_options_xxx()
Quoted 49 lines · Paolo Abeni
Hi,
Thank you for doing this and sharing the code early, very appreciated!
Quoted 28 lines · Peter Krystad
net/ipv4/tcp_output.c +13
-7@@ -797,20 +797,20 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skbunsigned int remaining =MAX_TCP_OPTION_SPACE - size;unsigned int opt_size; -if (mptcp_established_options (sk, &opt_size, &opts->mptcp)) { -if (remaining >= opt_size) { - opts->options |=OPTION_MPTCP ; - size += opt_size; - } - }else { -unsigned int dss_size; +if ((sk, skb, &opt_size, + remaining, &opts->mptcp)) { + opts->options |=OPTION_MPTCP ; + size += opt_size; + remaining -= opt_size; + } + +if (mptcp_established_options_dss (sk, skb, &opt_size, + remaining, &opts->mptcp)) { + opts->options |=OPTION_MPTCP ; + size += opt_size; + remaining -= opt_size; + }net/ipv4/tcp_output.c static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb · line 816
Quoted 10 lines
net/ipv4/tcp_output.c +0
-6-if (mptcp_established_options_dss (sk, skb, &dss_size, - remaining, - &opts->mptcp)) { - opts->options |=OPTION_MPTCP ; - size += dss_size; - } } }[Not strictly related to
MP_JOIN] I think it could be possibly cleaner to expose to the TCP code a singlemptcp_established_option()hook and handle there all the relevant cases ('plain',_dss()_addr()added by the next patch).
Quoted 2 lines
The mptcp code should not change much, and possibly it would remove a bunch of duplicate checks (about
subflow->mp_capable).
I agree a single hook is cleaner, this ended up like this to make the individual commits stand alone better as features were added. I will revise this.
Peter.
Quoted 4 lines
Cheers,
Paolo
Peter Krystad
RFC 2/3 mptcp: Add ADD_ADDR handling
In reply to Peter KrystadAdd handling for sending and receiving the ADD_ADDR, ADD_ADDR6, and RM_ADDR suboptions.
Add enough of a path manager interface to allow sending of ADD_ADDR when an incoming MPTCP connection is created. Capable of sending only a single IPv4 ADD_ADDR option. The 'pm_data' element of the connection sock will need to be expanded to handle multiple interfaces and IPv6.
--- include/net/mptcp.h | 24 ++++++++++++++++++++--- include/net/tcp.h | 3 +++ net/ipv4/tcp_output.c | 5 +++++ net/mptcp/Makefile | 2 +- net/mptcp/options.c | 44 ++++++++++++++++++++++++++++++++++++++++++- net/mptcp/pm.c | 24 +++++++++++++++++++++++ net/mptcp/protocol.c | 5 +++++ net/mptcp/protocol.h | 20 +++++++++++++++++++- 8 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 net/mptcp/pm.c
include/net/mptcp.h +21 -3
@@ -34,15 +34,21 @@ struct mptcp_ext { };/* MPTCP option subtypes */ -#define OPTION_MPTCP_MPC_SYN BIT(0) -#define OPTION_MPTCP_MPC_SYNACK BIT(1) -#define OPTION_MPTCP_MPC_ACK BIT(2) +#define OPTION_MPTCP_MPC_SYN BIT(0) +#define OPTION_MPTCP_MPC_SYNACK BIT(1) +#define OPTION_MPTCP_MPC_ACK BIT(2) +#define OPTION_MPTCP_ADD_ADDR BIT(6) +#define OPTION_MPTCP_ADD_ADDR6 BIT(7) +#define OPTION_MPTCP_RM_ADDR BIT(8)struct mptcp_out_options {#if IS_ENABLED (CONFIG_MPTCP )u16 suboptions;u64 sndr_key;u64 rcvr_key; +struct in_addr addr; +struct in6_addr addr6; +u8 address_id;struct mptcp_ext ext_copy;#endif };
@@ -72,6 +78,9 @@ 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); +bool mptcp_established_options_addr (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);
@@ -135,6 +144,15 @@ static inline bool mptcp_established_options(struct sock *sk,return false; } +static inline bool mptcp_established_options_addr (struct sock *sk, +struct sk_buff *skb, +unsigned int *size, +unsigned int remaining, +struct mptcp_out_options *opts) +{ +return false; +} +static inline void mptcp_attach_dss (struct sock *sk,struct sk_buff *skb,struct tcp_options_received *opt_rx) {
include/net/tcp.h +3 -0
@@ -225,6 +225,9 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);#define TCPOLEN_MPTCP_DSS_MAP32 10#define TCPOLEN_MPTCP_DSS_MAP64 14#define TCPOLEN_MPTCP_DSS_CHECKSUM 2 +#define TCPOLEN_MPTCP_ADD_ADDR 8 +#define TCPOLEN_MPTCP_ADD_ADDR6 20 +#define TCPOLEN_MPTCP_RM_ADDR 4/* Flags in tp->nonagle */ #define TCP_NAGLE_OFF 1/* Nagle's algo is disabled */
net/ipv4/tcp_output.c +5 -0
@@ -811,6 +811,11 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb remaining -= opt_size; } +if (mptcp_established_options_addr (sk, skb, &opt_size, + remaining, &opts->mptcp)) { + opts->options |=OPTION_MPTCP ; + size += opt_size; + remaining -= opt_size; } }
net/mptcp/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_MPTCP) += mptcp.o -mptcp-y := protocol.o subflow.o options.o token.o crypto.o +mptcp-y := protocol.o subflow.o options.o token.o crypto.o pm.o
net/mptcp/options.c +43 -1
62 lines not on this page · raw message
net/mptcp/pm.c new file +24 -0
@@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Multipath TCP +* +* Copyright (c) 2019, Intel Corporation. +*/ +#include <linux/kernel.h> +#include <net/tcp.h> +#include <net/mptcp.h> +#include "protocol.h" + +void pm_new_session (struct mptcp_sock *msk) +{ +pr_debug ("msk=%p" , msk); +} + +bool pm_addr_signal (struct mptcp_sock *msk,unsigned *size, +unsigned int remaining,struct mptcp_out_options *opts, +struct sk_buff *skb) +{ +pr_debug ("msk=%p" , msk); + +return false; +}
net/mptcp/protocol.c +5 -0
@@ -640,6 +640,9 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,mptcp_init_sock (new_mptcp_sock); msk =mptcp_sk (new_mptcp_sock); + +pm_new_session (msk); + msk->remote_key = subflow->remote_key; msk->local_key = subflow->local_key; msk->token = subflow->token;
@@ -763,6 +766,8 @@ void mptcp_finish_connect(struct sock *sk, int mp_capable) subflow->map_seq = ack_seq; subflow->map_subflow_seq =1 ; subflow->rel_write_seq =1 ; + +pm_new_session (msk); }inet_sk_state_store (sk,TCP_ESTABLISHED ); }
net/mptcp/protocol.h +19 -1
@@ -15,18 +15,29 @@#define MPTCPOPT_MP_JOIN 1#define MPTCPOPT_DSS 2#define MPTCPOPT_ADD_ADDR 3 -#define MPTCPOPT_REMOVE_ADDR 4 +#define MPTCPOPT_RM_ADDR 4#define MPTCPOPT_MP_PRIO 5#define MPTCPOPT_MP_FAIL 6#define MPTCPOPT_MP_FASTCLOSE 7#define MPTCPOPT_VERSION_MASK 0x0F +#define MPTCP_IPVERSION_4 4 +#define MPTCP_IPVERSION_6 6 +/* MPTCP handshake flags */ #define MPTCP_CAP_CHECKSUM_REQD (1 << 7)#define MPTCP_CAP_EXTENSIBILITY (1 << 6)#define MPTCP_CAP_HMAC_SHA1 (1 << 0) +struct pm_data { +u8 address_id; +union { +struct in_addr addr; +struct in6_addr addr6; + }; +}; +/* MPTCP connection sock */ struct mptcp_sock {/* inet_connection_sock must be the first member */
@@ -39,6 +50,8 @@ struct mptcp_sock {spinlock_t conn_list_lock;struct list_head conn_list;struct socket *subflow;/* outgoing connect/listener/!mp_capable */ +u8 addr_signal; +struct pm_data pm; };#define mptcp_for_each_subflow (__msk, __subflow) \
@@ -139,6 +152,11 @@ void crypto_key_sha1(u64 key, u32 *token, u64 *idsn);void crypto_hmac_sha1 (u64 key1,u64 key2,u32 *hash_out,int arg_num, ...); +void pm_new_session (struct mptcp_sock *msk); +bool pm_addr_signal (struct mptcp_sock *msk,unsigned *size, +unsigned int remaining,struct mptcp_out_options *opts, +struct sk_buff *skb); +static inline struct mptcp_ext *mptcp_get_ext (struct sk_buff *skb) {return (struct mptcp_ext *)skb_ext_find (skb,SKB_EXT_MPTCP );
Signature · 1 line
2.17.2
Peter Krystad
RFC 3/3 mptcp: Add handling of incoming MP_JOIN requests
In reply to Peter KrystadProcess the MP_JOIN option in a SYN packet with the same flow as MP_CAPABLE but when the third ACK is received add the subflow to the MPTCP socket subflow list instead of adding it to the TCP socket accept queue.
The subflow is added at the end of the subflow list so it will not interfere with the existing subflows operation and no data is expected to be transmitted on it.
--- include/linux/tcp.h | 6 ++ include/net/mptcp.h | 13 ++++ include/net/tcp.h | 3 + net/ipv4/tcp_minisocks.c | 6 ++ net/ipv4/tcp_output.c | 8 +-- net/mptcp/options.c | 85 ++++++++++++++++++++++++--- net/mptcp/protocol.c | 19 ++++++ net/mptcp/protocol.h | 25 +++++++- net/mptcp/subflow.c | 42 +++++++++++++ net/mptcp/token.c | 124 +++++++++++++++++++++++++++++++++++++++ 10 files changed, 316 insertions(+), 15 deletions(-)
include/linux/tcp.h +6 -0
@@ -116,6 +116,7 @@ struct tcp_options_received { u8 mp_capable : 1, mp_join : 1, dss : 1, + backup : 1, version : 4;u8 flags; u8 use_map:1,
@@ -125,6 +126,11 @@ struct tcp_options_received { use_ack:1, ack64:1, __unused:2; +u8 address_id; +u32 token; +u32 nonce; +u64 thmac; + u8 hmac[20]; } mptcp;#endif };
include/net/mptcp.h +13 -0
@@ -37,6 +37,9 @@ struct mptcp_ext {#define OPTION_MPTCP_MPC_SYN BIT(0)#define OPTION_MPTCP_MPC_SYNACK BIT(1)#define OPTION_MPTCP_MPC_ACK BIT(2) +#define OPTION_MPTCP_MPJ_SYN BIT(3) +#define OPTION_MPTCP_MPJ_SYNACK BIT(4) +#define OPTION_MPTCP_MPJ_ACK BIT(5)#define OPTION_MPTCP_ADD_ADDR BIT(6)#define OPTION_MPTCP_ADD_ADDR6 BIT(7)#define OPTION_MPTCP_RM_ADDR BIT(8)
@@ -49,6 +52,9 @@ struct mptcp_out_options {struct in_addr addr;struct in6_addr addr6;u8 address_id; +u8 backup; +u32 nonce; +u64 thmac;struct mptcp_ext ext_copy;#endif };
@@ -92,6 +98,8 @@ static inline bool mptcp_skb_ext_exist(const struct sk_buff *skb)void mptcp_write_options (__be32 *ptr,struct mptcp_out_options *opts); +bool mptcp_sk_is_subflow (const struct sock *sk); +#else static inline bool sk_is_mptcp (const struct sock *sk)
@@ -163,5 +171,10 @@ static inline bool mptcp_skb_ext_exist(const struct sk_buff *skb)return false; } +static inline book mptcp_sk_is_subflow (const struct sock *sk) +{ +return false; +} +#endif /* CONFIG_MPTCP */ #endif /* __NET_MPTCP_H */
include/net/tcp.h +3 -0
@@ -219,6 +219,9 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);#define TCPOLEN_MPTCP_MPC_SYN 12#define TCPOLEN_MPTCP_MPC_SYNACK 20#define TCPOLEN_MPTCP_MPC_ACK 20 +#define TCPOLEN_MPTCP_MPJ_SYN 12 +#define TCPOLEN_MPTCP_MPJ_SYNACK 16 +#define TCPOLEN_MPTCP_MPJ_ACK 24#define TCPOLEN_MPTCP_DSS_BASE 4#define TCPOLEN_MPTCP_DSS_ACK32 4#define TCPOLEN_MPTCP_DSS_ACK64 8
net/ipv4/tcp_minisocks.c +6 -0
@@ -764,6 +764,12 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,if (!child) goto listen_overflow; +if (own_req &&sk_is_mptcp (child) &&mptcp_sk_is_subflow (child)) { +inet_csk_reqsk_queue_drop (sk, req); +reqsk_queue_removed (&inet_csk (sk)->icsk_accept_queue, req); +return child; + } +sock_rps_save_rxhash (child, skb);tcp_synack_rtt_meas (child, req); *req_stolen = !own_req;
net/ipv4/tcp_output.c +4 -4
@@ -804,15 +804,15 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb remaining -= opt_size; } -if (mptcp_established_options_dss (sk, skb, &opt_size, - remaining, &opts->mptcp)) { +if (mptcp_established_options_addr (sk, skb, &opt_size, + remaining, &opts->mptcp)) { opts->options |=OPTION_MPTCP ; size += opt_size; remaining -= opt_size; } -if (mptcp_established_options_addr (sk, skb, &opt_size, - remaining, &opts->mptcp)) { +if (mptcp_established_options_dss (sk, skb, &opt_size, + remaining, &opts->mptcp)) { opts->options |=OPTION_MPTCP ; size += opt_size; remaining -= opt_size;
net/mptcp/options.c +76 -9
145 lines not on this page · raw message
net/mptcp/protocol.c +19 -0
@@ -772,6 +772,25 @@ 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) +{ +struct mptcp_sock *msk =mptcp_sk (conn); +struct subflow_context *subflow =subflow_ctx (sk); + +pr_debug ("msk=%p, subflow=%p" , msk, subflow); + +spin_lock_bh (&msk->conn_list_lock); +list_add_tail_rcu (&subflow->node, &msk->conn_list); +spin_unlock_bh (&msk->conn_list_lock); +} + +bool mptcp_sk_is_subflow (const struct sock *sk) +{ +struct subflow_context *subflow =subflow_ctx (sk); + +return subflow->mp_join ==1 ; +} +static struct proto mptcp_prot = { .name ="MPTCP" , .owner =THIS_MODULE ,
net/mptcp/protocol.h +23 -2
@@ -21,6 +21,8 @@#define MPTCPOPT_MP_FASTCLOSE 7#define MPTCPOPT_VERSION_MASK 0x0F +#define MPTCPOPT_BACKUP (1 << 0) +#define MPTCPOPT_HMAC_LEN 20#define MPTCP_IPVERSION_4 4#define MPTCP_IPVERSION_6 6
@@ -69,11 +71,16 @@ struct subflow_request_sock { checksum : 1, backup : 1, version : 4; +u8 local_id; +u8 remote_id;u64 local_key;u64 remote_key;u64 idsn;u32 token;u32 ssn_offset; +u64 thmac; +u32 local_nonce; +u32 remote_nonce; }; static inline
@@ -96,15 +103,23 @@ struct subflow_context {u16 map_data_len; u16 request_mptcp : 1, /* send MP_CAPABLE */ request_cksum : 1, - mp_capable : 1, /* remote is MPTCP capable */ + 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; + map_valid : 1, + backup : 1; +u32 remote_nonce; +u64 thmac; +u32 local_nonce; +u8 local_id; +u8 remote_id;struct socket *tcp_sock;/* underlying tcp_sock */ struct sock *conn;/* parent mptcp_sock */ +void (*tcp_sk_data_ready)(struct sock *sk); };
@@ -128,13 +143,19 @@ 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 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_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_accept (struct sock *sk); +int token_new_join (struct sock *sk);void token_update_accept (struct sock *sk,struct sock *conn); +void token_release (u32 token);void token_destroy (u32 token);void crypto_init (void );
net/mptcp/subflow.c +42 -0
74 lines not on this page · raw message
net/mptcp/token.c +124 -0
154 lines not on this page · raw message
Signature · 1 line
2.17.2
Paolo Abeni
Re: [MPTCP] [RFC 3/3] mptcp: Add handling of incoming MP_JOIN requests
Hi,
Quoted 30 lines · Peter Krystad
net/mptcp/options.c +4
-3@@ -45,24 +45,55 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,break ;/* MPTCPOPT_MP_JOIN -* * Initial SYN * 0: 4MSB=subtype, 000, 1LSB=Backup * 1: Address ID * 2-5: Receiver token * 6-9: Sender random number -* * SYN/ACK response * 0: 4MSB=subtype, 000, 1LSB=Backup * 1: Address ID * 2-9: Sender truncated HMAC * 10-13: Sender random number -* * Third ACK * 0: 4MSB=subtype, 0000 * 1: 0 (Reserved) * 2-21: Sender HMAC */ +case MPTCPOPT_MP_JOIN : +pr_debug ("MP_JOIN" ); + opt_rx->mptcp.mp_join =1 ; +if (opsize ==TCPOLEN_MPTCP_MPJ_SYN ) {
net/mptcp/options.c void mptcp_parse_option(const unsigned char *ptr, int opsize, · line 76
Quoted 10 lines
net/mptcp/options.c +10
-0+ opt_rx->mptcp.backup = *ptr++ &MPTCPOPT_BACKUP ; +pr_debug ("backup=%u" , opt_rx->mptcp.backup); + opt_rx->mptcp.address_id = *ptr++; +pr_debug ("address_id=%u" , opt_rx->mptcp.address_id); + opt_rx->mptcp.token =get_unaligned_be32 (ptr); +pr_debug ("token=%u" , opt_rx->mptcp.token); + ptr +=4 ; + opt_rx->mptcp.nonce =get_unaligned_be32 (ptr); +pr_debug ("nonce=%u" , opt_rx->mptcp.nonce); + ptr +=4 ;
Very minor note here: when I enable debugging on MPTCP, I'm flooded with possibly too many messages and it's sometime difficult for me to find the useful information.
I think using a single pr_debug() with all the relevant info (nonce, token, address, backup) would help.
The same applies to others places below, too.
[...]
net/mptcp/options.c static struct sock *subflow_syn_recv_sock(const struct sock *sk, · line 179
Quoted 10 lines
net/mptcp/options.c +6
-0@@ -151,6 +171,18 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, child =NULL ; }else if (ctx->mp_capable) {token_new_accept (child); + }else if (ctx->mp_join) { +if (token_new_join (child)) { +inet_sk_set_state (child,TCP_CLOSE ); +sock_set_flag (child,SOCK_DEAD ); +inet_csk_destroy_sock (child); + child =NULL ;
There is a very similar block of code a few lines above. I think we can unify them in an error path reached via a 'goto' statement.
net/mptcp/options.c static struct sock *subflow_syn_recv_sock(const struct sock *sk, · line 185
Quoted 6 lines
net/mptcp/options.c +6
-0+ }else { +mptcp_finish_join (ctx->conn, child); + } + }else { + ctx->mp_capable =0 ; + ctx->mp_join =0 ;
Why do we need to clear mp_capable and mp_join here ?
[...]
Quoted 7 lines
net/mptcp/token.c +0
-0@@ -55,6 +55,15 @@ static bool find_token(u32 token)return (used !=NULL ); }
net/mptcp/token.c static bool find_token(u32 token) · line 66
Quoted 10 lines
net/mptcp/token.c +9
-0+static struct sock *lookup_token (u32 token) +{ +void *conn; + +pr_debug ("token=%u" , token); + conn =radix_tree_lookup (&token_tree, token); +return (struct sock *) conn; +} +
Possibly out of the scope for this patch, but don't we need to take in account the netns, too, while doing the token lookup?
Thanks,
Paolo
Peter Krystad
Re: [MPTCP] [RFC 3/3] mptcp: Add handling of incoming MP_JOIN requests
Thnaks for your comments Paolo.
Quoted 48 lines · Paolo Abeni
Hi,
Quoted 30 lines · Peter Krystad
net/mptcp/options.c +4
-3@@ -45,24 +45,55 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,break ;/* MPTCPOPT_MP_JOIN -* * Initial SYN * 0: 4MSB=subtype, 000, 1LSB=Backup * 1: Address ID * 2-5: Receiver token * 6-9: Sender random number -* * SYN/ACK response * 0: 4MSB=subtype, 000, 1LSB=Backup * 1: Address ID * 2-9: Sender truncated HMAC * 10-13: Sender random number -* * Third ACK * 0: 4MSB=subtype, 0000 * 1: 0 (Reserved) * 2-21: Sender HMAC */ +case MPTCPOPT_MP_JOIN : +pr_debug ("MP_JOIN" ); + opt_rx->mptcp.mp_join =1 ; +if (opsize ==TCPOLEN_MPTCP_MPJ_SYN ) {net/mptcp/options.c void mptcp_parse_option(const unsigned char *ptr, int opsize, · line 76
Quoted 10 lines
net/mptcp/options.c +10
-0+ opt_rx->mptcp.backup = *ptr++ &MPTCPOPT_BACKUP ; +pr_debug ("backup=%u" , opt_rx->mptcp.backup); + opt_rx->mptcp.address_id = *ptr++; +pr_debug ("address_id=%u" , opt_rx->mptcp.address_id); + opt_rx->mptcp.token =get_unaligned_be32 (ptr); +pr_debug ("token=%u" , opt_rx->mptcp.token); + ptr +=4 ; + opt_rx->mptcp.nonce =get_unaligned_be32 (ptr); +pr_debug ("nonce=%u" , opt_rx->mptcp.nonce); + ptr +=4 ;Very minor note here: when I enable debugging on MPTCP, I'm flooded with possibly too many messages and it's sometime difficult for me to find the useful information.
Quoted 4 lines
I think using a single
pr_debug()with all the relevant info (nonce, token, address, backup) would help.The same applies to others places below, too.
I've been meaning to do this for some time, I'll submit a separate patch to remove a lot of these messages from early debugging days.
Quoted 16 lines
[...]
net/mptcp/options.c static struct sock *subflow_syn_recv_sock(const struct sock *sk, · line 179
Quoted 10 lines
net/mptcp/options.c +6
-0@@ -151,6 +171,18 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, child =NULL ; }else if (ctx->mp_capable) {token_new_accept (child); + }else if (ctx->mp_join) { +if (token_new_join (child)) { +inet_sk_set_state (child,TCP_CLOSE ); +sock_set_flag (child,SOCK_DEAD ); +inet_csk_destroy_sock (child); + child =NULL ;There is a very similar block of code a few lines above. I think we can unify them in an error path reached via a 'goto' statement.
Quoted 8 lines
net/mptcp/options.c static struct sock *subflow_syn_recv_sock(const struct sock *sk, · line 185
Quoted 6 lines
net/mptcp/options.c +6
-0+ }else { +mptcp_finish_join (ctx->conn, child); + } + }else { + ctx->mp_capable =0 ; + ctx->mp_join =0 ;Why do we need to clear
mp_capableandmp_joinhere ?
This is a remnant of a previous approach, I'll remove.
Quoted 10 lines
[...]
Quoted 8 lines
net/mptcp/token.c +0
-0@@ -55,6 +55,15 @@ static bool find_token(u32 token)return (used !=NULL ); }
Quoted 12 lines
net/mptcp/token.c static bool find_token(u32 token) · line 66
Quoted 9 lines
net/mptcp/token.c +9
-0+static struct sock *lookup_token (u32 token) +{ +void *conn; + +pr_debug ("token=%u" , token); + conn =radix_tree_lookup (&token_tree, token); +return (struct sock *) conn; +} +Possibly out of the scope for this patch, but don't we need to take in account the netns, too, while doing the token lookup?
No, you're right, this does need to be taken into account. I'll investigate.
Peter.
Quoted 5 lines
Thanks,
Paolo
Paolo Abeni
Re: [MPTCP] [RFC 3/3] mptcp: Add handling of incoming MP_JOIN requests
In reply to Peter KrystadHi,
I'm sorry for the late feedback, I'm still looking at this code...
Quoted 5 lines · Peter Krystad
net/ipv4/tcp_minisocks.c +0
-0
net/ipv4/tcp_minisocks.c struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, · line 772
Quoted 9 lines
net/ipv4/tcp_minisocks.c +6
-0@@ -764,6 +764,12 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,if (!child) goto listen_overflow; +if (own_req &&sk_is_mptcp (child) &&mptcp_sk_is_subflow (child)) { +inet_csk_reqsk_queue_drop (sk, req); +reqsk_queue_removed (&inet_csk (sk)->icsk_accept_queue, req); +return child; + } +
Don't we need to check this is not a fastopen before dropping the req?
Can't we avoid the above hunck anyway, handling the special MP_JOIN scenario in mptcp_accept() ? so that we reduce hooking, the user-space is notified of a new subflow - 'accept()' would probably return a specific error code, not a new fd!!! - and we enforce some limits on the number of pending/new subflows.
WDYT?
Thanks,
Paolo
Peter Krystad
Re: [MPTCP] [RFC 3/3] mptcp: Add handling of incoming MP_JOIN requests
Quoted 13 lines · Paolo Abeni
Hi,
I'm sorry for the late feedback, I'm still looking at this code...
Quoted 8 lines · Peter Krystad
net/ipv4/tcp_minisocks.c +0
-0@@ -764,6 +764,12 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,if (!child) goto listen_overflow;
Quoted 8 lines
net/ipv4/tcp_minisocks.c struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, · line 772
Quoted 6 lines
net/ipv4/tcp_minisocks.c +6
-0+if (own_req &&sk_is_mptcp (child) &&mptcp_sk_is_subflow (child)) { +inet_csk_reqsk_queue_drop (sk, req); +reqsk_queue_removed (&inet_csk (sk)->icsk_accept_queue, req); +return child; + } +Don't we need to check this is not a fastopen before dropping the req?
I was thinking we would initially not support fastopen for MPTCP connections, meaning we would ignore cookie requests in a SYN with MP_CAPABLE. I haven't added this check, what do others think about fastopen as a requirement for MPTCP?
Quoted 6 lines
Can't we avoid the above hunck anyway, handling the special
MP_JOINscenario inmptcp_accept()? so that we reduce hooking, the user-space is notified of a new subflow - 'accept()' would probably return a specific error code, not a new fd!!! - and we enforce some limits on the number of pending/new subflows.
I was not thinking of forcing a change to the typical user accept() handling so this is how that is avoided. In earlier discussions it seemed making the user use a new protocol value was enough of a hurdle.
Peter.
Quoted 6 lines
WDYT?
Thanks,
Paolo
Paolo Abeni
Re: [MPTCP] [RFC 3/3] mptcp: Add handling of incoming MP_JOIN requests
Hi,
Quoted 19 lines · Peter Krystad
Quoted 9 lines · Paolo Abeni
Quoted 8 lines · Peter Krystad
net/ipv4/tcp_minisocks.c +0
-0@@ -764,6 +764,12 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,if (!child) goto listen_overflow;Quoted 8 lines
net/ipv4/tcp_minisocks.c struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, · line 772
Quoted 6 lines
net/ipv4/tcp_minisocks.c +6
-0+if (own_req &&sk_is_mptcp (child) &&mptcp_sk_is_subflow (child)) { +inet_csk_reqsk_queue_drop (sk, req); +reqsk_queue_removed (&inet_csk (sk)->icsk_accept_queue, req); +return child; + } +Don't we need to check this is not a fastopen before dropping the req?
Quoted 4 lines
I was thinking we would initially not support fastopen for MPTCP connections, meaning we would ignore cookie requests in a SYN with
MP_CAPABLE. I haven't added this check, what do others think about fastopen as a requirement for MPTCP?
I'm sorry, I was not clear enough. I think fastopen is _NOT_ a requirement for MPTCP. My doubt is: can we hit the above conditional with a fast-open socket? (regardless of MPTCP code implementing support for fast-open). If so, should we explicitly fail the MP_JOIN to avoid messing with the tcp socket status?
Not sure if the above is now more clear ;)
Quoted 9 lines
Quoted 5 lines
Can't we avoid the above hunck anyway, handling the special
MP_JOINscenario inmptcp_accept()? so that we reduce hooking, the user-space is notified of a new subflow - 'accept()' would probably return a specific error code, not a new fd!!! - and we enforce some limits on the number of pending/new subflows.I was not thinking of forcing a change to the typical user
accept()handling so this is how that is avoided. In earlier discussions it seemed making the user use a new protocol value was enough of a hurdle.
Ok, understood. I agree that we should avoid uAPI changes; before I did not consider such aspect. I'm fine with the current impl in this regard.
Thanks,
Paolo
Peter Krystad
Re: [MPTCP] [RFC 3/3] mptcp: Add handling of incoming MP_JOIN requests
Quoted 27 lines · Paolo Abeni
Hi,
Quoted 19 lines · Peter Krystad
Quoted 9 lines · Paolo Abeni
Quoted 8 lines · Peter Krystad
net/ipv4/tcp_minisocks.c +0
-0@@ -764,6 +764,12 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,if (!child) goto listen_overflow;Quoted 8 lines
net/ipv4/tcp_minisocks.c struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, · line 772
Quoted 6 lines
net/ipv4/tcp_minisocks.c +6
-0+if (own_req &&sk_is_mptcp (child) &&mptcp_sk_is_subflow (child)) { +inet_csk_reqsk_queue_drop (sk, req); +reqsk_queue_removed (&inet_csk (sk)->icsk_accept_queue, req); +return child; + } +Don't we need to check this is not a fastopen before dropping the req?
Quoted 4 lines
I was thinking we would initially not support fastopen for MPTCP connections, meaning we would ignore cookie requests in a SYN with
MP_CAPABLE. I haven't added this check, what do others think about fastopen as a requirement for MPTCP?
Quoted 5 lines
I'm sorry, I was not clear enough. I think fastopen is _NOT_ a requirement for MPTCP. My doubt is: can we hit the above conditional with a fast-open socket? (regardless of MPTCP code implementing support for fast-open). If so, should we explicitly fail the
MP_JOINto avoid messing with the tcp socket status?
Thanks Paolo - I understand your point. But my thinking was it would be better to avoid worrying about fastopen sockets here by rejecting them (forcing them to fall back to 3-way handshake) when the initial SYN is received, this way if it is a MPTCP subflow socket it is NOT fastopen and the above clause would never be hit.
Peter.
Quoted 20 lines
Not sure if the above is now more clear ;)
Quoted 9 lines
Quoted 5 lines
Can't we avoid the above hunck anyway, handling the special
MP_JOINscenario inmptcp_accept()? so that we reduce hooking, the user-space is notified of a new subflow - 'accept()' would probably return a specific error code, not a new fd!!! - and we enforce some limits on the number of pending/new subflows.I was not thinking of forcing a change to the typical user
accept()handling so this is how that is avoided. In earlier discussions it seemed making the user use a new protocol value was enough of a hurdle.Ok, understood. I agree that we should avoid uAPI changes; before I did not consider such aspect. I'm fine with the current impl in this regard.
Thanks,
Paolo