add MP_CAPABLE 'C' flag
Subsystems (4)
v3 cover add MP_CAPABLE 'C' flag
v3:
- use 'u8 allow_join_initial_addr_port'
- drop the spinlock in patch 3
v2:
- rename join_denied to allow_join_id0 in mptcp_out_options
- rename join_denied to deny_join_id0 in mptcp_options_received
- add a new function mptcp_pm_deny_join_id0_received
- move deny_join_id0 flag from mptcp_sock to mptcp_pm_data
- check deny_join_id0 flag in mptcp_pm_create_subflow_or_signal_addr
instead of in mptcp_syn_options.
Geliang Tang (4):
mptcp: add sysctl allow_join_initial_addr_port
mptcp: add allow_join_id0 in mptcp_out_options
mptcp: add deny_join_id0 in mptcp_options_received
selftests: mptcp: add deny_join_id0 testcases
Documentation/networking/mptcp-sysctl.rst | 13 +++++ include/net/mptcp.h | 3 +- net/mptcp/ctrl.c | 16 ++++++ net/mptcp/options.c | 16 +++++- net/mptcp/pm.c | 1 + net/mptcp/pm_netlink.c | 4 +- net/mptcp/protocol.h | 11 +++- net/mptcp/subflow.c | 3 + .../testing/selftests/net/mptcp/mptcp_join.sh | 55 ++++++++++++++++++- 9 files changed, 114 insertions(+), 8 deletions(-)
Signature · 1 line
2.30.2
PATCH v3 1/4 mptcp: add sysctl allow_join_initial_addr_port
This patch added a new sysctl, named allow_join_initial_addr_port, to control whether allow peers to send join requests to the IP address and port number used by the initial subflow.
--- Documentation/networking/mptcp-sysctl.rst | 13 +++++++++++++ net/mptcp/ctrl.c | 16 ++++++++++++++++ net/mptcp/protocol.h | 1 + 3 files changed, 30 insertions(+)
Documentation/networking/mptcp-sysctl.rst +13 -0
@@ -24,3 +24,16 @@ add_addr_timeout - INTEGER (seconds) sysctl. Default: 120 + +allow_join_initial_addr_port - INTEGER + Allow peers to send join requests to the IP address and port number used + by the initial subflow if the value is 1. This controls a flag that is + sent to the peer at connection time, and whether such join requests are + accepted or denied. + + Joins to addresses advertised with ADD_ADDR are not affected by this + value. + + This is a per-namespace sysctl. + + Default: 1
net/mptcp/ctrl.c +16 -0
@@ -19,6 +19,7 @@ struct mptcp_pernet {u8 mptcp_enabled;unsigned int add_addr_timeout; +u8 allow_join_initial_addr_port; };static struct mptcp_pernet *mptcp_get_pernet (struct net *net)
@@ -36,6 +37,11 @@ unsigned int mptcp_get_add_addr_timeout(struct net *net)return mptcp_get_pernet (net)->add_addr_timeout; } +int mptcp_is_allow_join_id0 (struct net *net) +{ +return mptcp_get_pernet (net)->allow_join_initial_addr_port; +} +static struct ctl_table mptcp_sysctl_table[] = { { .procname ="enabled" ,
@@ -54,6 +60,14 @@ static struct ctl_table mptcp_sysctl_table[] = { .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, + { + .procname = "allow_join_initial_addr_port", + .maxlen = sizeof(u8), + .mode = 0644, + .proc_handler = proc_dou8vec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE + }, {} };
@@ -61,6 +75,7 @@ static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet) { pernet->mptcp_enabled =1 ; pernet->add_addr_timeout =TCP_RTO_MAX ; + pernet->allow_join_initial_addr_port =1 ; }static int mptcp_pernet_new_table (struct net *net,struct mptcp_pernet *pernet)
@@ -77,6 +92,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) table[0 ].data = &pernet->mptcp_enabled; table[1 ].data = &pernet->add_addr_timeout; + table[2 ].data = &pernet->allow_join_initial_addr_port; hdr =register_net_sysctl (net,MPTCP_SYSCTL_PATH , table);if (!hdr)
net/mptcp/protocol.h +1 -0
@@ -524,6 +524,7 @@ static inline void mptcp_subflow_delegated_done(struct mptcp_subflow_context *suint mptcp_is_enabled (struct net *net);unsigned int mptcp_get_add_addr_timeout (struct net *net); +int mptcp_is_allow_join_id0 (struct net *net);void mptcp_subflow_fully_established (struct mptcp_subflow_context *subflow,struct mptcp_options_received *mp_opt);bool mptcp_subflow_data_available (struct sock *sk);
Signature · 1 line
2.30.2
PATCH v3 2/4 mptcp: add allow_join_id0 in mptcp_out_options
This patch defined a new flag MPTCP_CAP_DENY_JOIN_ID0 for the third bit, labeled "C" of the MP_CAPABLE option.
Add a new flag allow_join_id0 in struct mptcp_out_options. If this flag is set, send out the MP_CAPABLE option with the flag MPTCP_CAP_DENY_JOIN_ID0.
--- include/net/mptcp.h | 3 ++- net/mptcp/options.c | 10 ++++++++-- net/mptcp/protocol.h | 6 ++++-- net/mptcp/subflow.c | 1 + 4 files changed, 15 insertions(+), 5 deletions(-)
include/net/mptcp.h +2 -1
@@ -64,7 +64,8 @@ struct mptcp_out_options {u8 join_id;u8 backup; u8 reset_reason:4; - u8 reset_transient:1; + u8 reset_transient:1, + allow_join_id0:1;u32 nonce;u64 thmac;u32 token;
net/mptcp/options.c +8 -2
@@ -381,6 +381,7 @@ bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb, subflow->snd_isn =TCP_SKB_CB (skb)->end_seq;if (subflow->request_mptcp) { opts->suboptions =OPTION_MPTCP_MPC_SYN ; + opts->allow_join_id0 =mptcp_is_allow_join_id0 (sock_net (sk)); *size =TCPOLEN_MPTCP_MPC_SYN ;return true; }else if (subflow->request_join) {
@@ -466,6 +467,7 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, opts->suboptions =OPTION_MPTCP_MPC_ACK ; opts->sndr_key = subflow->local_key; opts->rcvr_key = subflow->remote_key; + opts->allow_join_id0 =mptcp_is_allow_join_id0 (sock_net (sk));/* Section 3.1. * The MP_CAPABLE option is carried on the SYN, SYN/ACK, and ACK
@@ -790,6 +792,7 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,if (subflow_req->mp_capable) { opts->suboptions =OPTION_MPTCP_MPC_SYNACK ; opts->sndr_key = subflow_req->local_key; + opts->allow_join_id0 = subflow_req->allow_join_id0; *size =TCPOLEN_MPTCP_MPC_SYNACK ;pr_debug ("subflow_req=%p, local_key=%llu" , subflow_req, subflow_req->local_key);
@@ -1124,7 +1127,7 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, {if ((OPTION_MPTCP_MPC_SYN |OPTION_MPTCP_MPC_SYNACK |OPTION_MPTCP_MPC_ACK ) & opts->suboptions) { -u8 len; +u8 len, flag =MPTCP_CAP_HMAC_SHA256 ;if (OPTION_MPTCP_MPC_SYN & opts->suboptions) len =TCPOLEN_MPTCP_MPC_SYN ;
@@ -1135,9 +1138,12 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,else len =TCPOLEN_MPTCP_MPC_ACK ; +if (!opts->allow_join_id0) + flag |=MPTCP_CAP_DENY_JOIN_ID0 ; + *ptr++ =mptcp_option (MPTCPOPT_MP_CAPABLE , len,MPTCP_SUPPORTED_VERSION , -MPTCP_CAP_HMAC_SHA256 ); + flag);if (!((OPTION_MPTCP_MPC_SYNACK |OPTION_MPTCP_MPC_ACK ) & opts->suboptions))
net/mptcp/protocol.h +4 -2
@@ -77,8 +77,9 @@#define MPTCP_VERSION_MASK (0x0F)#define MPTCP_CAP_CHECKSUM_REQD BIT(7)#define MPTCP_CAP_EXTENSIBILITY BIT(6) +#define MPTCP_CAP_DENY_JOIN_ID0 BIT(5)#define MPTCP_CAP_HMAC_SHA256 BIT(0) -#define MPTCP_CAP_FLAG_MASK (0x3F) +#define MPTCP_CAP_FLAG_MASK (0x1F)/* MPTCP DSS flags */ #define MPTCP_DSS_DATA_FIN BIT(4)
@@ -338,7 +339,8 @@ struct mptcp_subflow_request_sock {struct tcp_request_sock sk; u16 mp_capable : 1, mp_join : 1, - backup : 1; + backup : 1, + allow_join_id0 : 1;u8 local_id;u8 remote_id;u64 local_key;
net/mptcp/subflow.c +1 -0
@@ -108,6 +108,7 @@ static void subflow_init_req(struct request_sock *req, const struct sock *sk_lis subflow_req->mp_capable =0 ; subflow_req->mp_join =0 ; + subflow_req->allow_join_id0 =mptcp_is_allow_join_id0 (sock_net (sk_listener)); subflow_req->msk =NULL ;mptcp_token_init_request (req); }
Signature · 1 line
2.30.2
PATCH v3 3/4 mptcp: add deny_join_id0 in mptcp_options_received
This patch added a new flag named deny_join_id0 in struct mptcp_options_received. Set it when MP_CAPABLE with the flag MPTCP_CAP_DENYJOIN_ID0 is received.
Also add a new flag deny_join_id0 in struct mptcp_pm_data. When the flag mp_opt.deny_join_id0 is set, set this pm->deny_join_id0 flag.
In mptcp_pm_create_subflow_or_signal_addr, if the pm->deny_join_id0 flag is set, and the remote address id is zero, stop this connection.
--- net/mptcp/options.c | 6 ++++++ net/mptcp/pm.c | 1 + net/mptcp/pm_netlink.c | 4 +++- net/mptcp/protocol.h | 4 +++- net/mptcp/subflow.c | 2 ++ 5 files changed, 15 insertions(+), 2 deletions(-)
net/mptcp/options.c +6 -0
@@ -77,6 +77,9 @@ static void mptcp_parse_option(const struct sk_buff *skb,if (flags &MPTCP_CAP_CHECKSUM_REQD )break ; +if (flags &MPTCP_CAP_DENY_JOIN_ID0 ) + mp_opt->deny_join_id0 =1 ; + mp_opt->mp_capable =1 ;if (opsize >=TCPOLEN_MPTCP_MPC_SYNACK ) { mp_opt->sndr_key =get_unaligned_be64 (ptr);
@@ -342,6 +345,7 @@ void mptcp_get_options(const struct sk_buff *skb, mp_opt->dss =0 ; mp_opt->mp_prio =0 ; mp_opt->reset =0 ; + mp_opt->deny_join_id0 =0 ; length = (th->doff *4 ) -sizeof (struct tcphdr ); ptr = (const unsigned char *)(th +1 );
@@ -1012,6 +1016,8 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) }mptcp_get_options (skb, &mp_opt); +if (mp_opt.deny_join_id0) +WRITE_ONCE (msk->pm.deny_join_id0, true);if (!check_fully_established (msk, sk, subflow, skb, &mp_opt))return ;
net/mptcp/pm.c +1 -0
@@ -320,6 +320,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)WRITE_ONCE (msk->pm.addr_signal,0 );WRITE_ONCE (msk->pm.accept_addr, false);WRITE_ONCE (msk->pm.accept_subflow, false); +WRITE_ONCE (msk->pm.deny_join_id0, false); msk->pm.status =0 ;spin_lock_init (&msk->pm.lock);
net/mptcp/pm_netlink.c +3 -1
@@ -456,10 +456,12 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)if (local) {struct mptcp_addr_info remote = {0 }; +remote_address ((struct sock_common *)sk, &remote); +if (!remote.id &&READ_ONCE (msk->pm.deny_join_id0)) +return ; msk->pm.local_addr_used++; msk->pm.subflows++;check_work_pending (msk); -remote_address ((struct sock_common *)sk, &remote);spin_unlock_bh (&msk->pm.lock);__mptcp_subflow_connect (sk, &local->addr, &remote, local->flags, local->ifindex);
net/mptcp/protocol.h +3 -1
@@ -134,7 +134,8 @@ struct mptcp_options_received { rm_addr : 1, mp_prio : 1, echo : 1, - backup : 1; + backup : 1, + deny_join_id0 : 1;u32 token;u32 nonce;u64 thmac;
@@ -189,6 +190,7 @@ struct mptcp_pm_data {bool work_pending;bool accept_addr;bool accept_subflow; +bool deny_join_id0;u8 add_addr_signaled;u8 add_addr_accepted;u8 local_addr_used;
net/mptcp/subflow.c +2 -0
@@ -405,6 +405,8 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) goto fallback; } +if (mp_opt.deny_join_id0) +WRITE_ONCE (mptcp_sk (parent)->pm.deny_join_id0, true); subflow->mp_capable =1 ; subflow->can_ack =1 ; subflow->remote_key = mp_opt.sndr_key;
Signature · 1 line
2.30.2
PATCH v3 4/4 selftests: mptcp: add deny_join_id0 testcases
This patch added a new argument '-d' for mptcp_join.sh script, to invoke the testcases for the MP_CAPABLE 'C' flag.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +54 -1
@@ -124,6 +124,17 @@ reset_with_add_addr_timeout() -j DROP } +reset_with_allow_join_id0() +{ + local ns1_enable=$1 + local ns2_enable=$2 + + reset + + ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable + ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable +} + ip -Version > /dev/null 2>&1 if [ $? -ne 0 ];then echo "SKIP: Could not run test without ip tool"
@@ -1374,6 +1385,43 @@ syncookies_tests() chk_add_nr 1 1 } +deny_join_id0_tests() +{ + # subflow allow join id0 ns1 + reset_with_allow_join_id0 1 0 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "single subflow allow join id0 ns1" 1 1 1 + + # subflow allow join id0 ns2 + reset_with_allow_join_id0 0 1 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "single subflow allow join id0 ns2" 0 0 0 + + # signal address allow join id0 ns1 + reset_with_allow_join_id0 1 0 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 1 + ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "signal address allow join id0 ns1" 1 1 1 + chk_add_nr 1 1 + + # signal address allow join id0 ns2 + reset_with_allow_join_id0 0 1 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 1 + ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "signal address allow join id0 ns2" 1 1 1 + chk_add_nr 1 1 +} + all_tests() { subflows_tests
@@ -1387,6 +1435,7 @@ all_tests() backup_tests add_addr_ports_tests syncookies_tests + deny_join_id0_tests } usage()
@@ -1403,6 +1452,7 @@ usage() echo " -b backup_tests" echo " -p add_addr_ports_tests" echo " -k syncookies_tests" + echo " -d deny_join_id0_tests" echo " -c capture pcap files" echo " -h help" }
@@ -1434,7 +1484,7 @@ if [ $do_all_tests -eq 1 ]; then exit $ret fi -while getopts 'fsltra64bpkch' opt; do +while getopts 'fsltra64bpkdch' opt; do case $opt in f) subflows_tests
@@ -1469,6 +1519,9 @@ while getopts 'fsltra64bpkch' opt; do k) syncookies_tests ;; + d) + deny_join_id0_tests + ;; c) ;; h | *)
Signature · 1 line
2.30.2
Re: [MPTCP][PATCH v3 mptcp-next 4/4] selftests: mptcp: add deny_join_id0 testcases
Quoted 59 lines · Geliang Tang
This patch added a new argument '-d' for
mptcp_join.shscript, to invoke the testcases for theMP_CAPABLE'C' flag.Signed-off-by Geliang Tang <[email protected]>---
.../testing/selftests/net/mptcp/mptcp_join.sh| 55 ++++++++++++++++++-1 file changed, 54 insertions(+), 1 deletion(-)tools/testing/selftests/net/mptcp/mptcp_join.sh +11
-0@@ -124,6 +124,17 @@ reset_with_add_addr_timeout() -j DROP } +reset_with_allow_join_id0() +{ + local ns1_enable=$1 + local ns2_enable=$2 + + reset + + ip netns exec $ns1 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns1_enable + ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable +} +ip -Version >
/dev/null2>&1
if [ $? -ne 0 ];then
echo "SKIP: Could not run test without ip tool"tools/testing/selftests/net/mptcp/mptcp_join.sh +25
-0@@ -1374,6 +1385,43 @@ syncookies_tests() chk_add_nr 1 1 } +deny_join_id0_tests() +{ + # subflow allow join id0 ns1 + reset_with_allow_join_id0 1 0 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "single subflow allow join id0 ns1" 1 1 1 + + # subflow allow join id0 ns2 + reset_with_allow_join_id0 0 1 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "single subflow allow join id0 ns2" 0 0 0 + + # signal address allow join id0 ns1 + reset_with_allow_join_id0 1 0 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 1 + ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "signal address allow join id0 ns1" 1 1 1
tools/testing/selftests/net/mptcp/mptcp_join.sh syncookies_tests() · line 1422
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +10
-0+ chk_add_nr 1 1 + + # signal address allow join id0 ns2 + reset_with_allow_join_id0 0 1 + ip netns exec $ns1 ./pm_nl_ctl limits 1 1 + ip netns exec $ns2 ./pm_nl_ctl limits 1 1 + ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr "signal address allow join id0 ns2" 1 1 1 + chk_add_nr 1 1
Could you explain more what the last two tests are intended to check? They seem to have the same expected results.
I also experimented with adding a 5th test using "reset_with_allow_join_id0 1 1" and that had the same results - the only variation was the setting of the 'C' flag in the SYN / SYNACK packets when I looked at the pcaps. The different enable settings didn't seem to change anything for chk_join_nr or chk_add_nr.
- Mat
Quoted 45 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +4
-0+} + all_tests() { subflows_tests@@ -1387,6 +1435,7 @@ all_tests() backup_tests add_addr_ports_tests syncookies_tests + deny_join_id0_tests } usage()@@ -1403,6 +1452,7 @@ usage() echo " -b backup_tests" echo " -p add_addr_ports_tests" echo " -k syncookies_tests" + echo " -d deny_join_id0_tests" echo " -c capture pcap files" echo " -h help" }@@ -1434,7 +1484,7 @@ if [ $do_all_tests -eq 1 ]; then exit $retfi
tools/testing/selftests/net/mptcp/mptcp_join.sh +1
-1-while getopts 'fsltra64bpkch' opt; do +while getopts 'fsltra64bpkdch' opt; docase $opt in f) subflows_teststools/testing/selftests/net/mptcp/mptcp_join.sh +3
-0@@ -1469,6 +1519,9 @@ while getopts 'fsltra64bpkch' opt; do k) syncookies_tests ;; + d) + deny_join_id0_tests + ;; c) ;; h | *)Signature · 1 line
2.30.2
--
Mat Martineau
Intel
Re: [MPTCP][PATCH v3 mptcp-next 3/4] mptcp: add deny_join_id0 in mptcp_options_received
In reply to Geliang TangQuoted 95 lines · Geliang Tang
This patch added a new flag named
deny_join_id0in structmptcp_options_received. Set it whenMP_CAPABLEwith the flagMPTCP_CAP_DENYJOIN_ID0is received.Also add a new flag
deny_join_id0in structmptcp_pm_data. When the flag mp_opt.deny_join_id0 is set, set thispm->deny_join_id0flag.In
mptcp_pm_create_subflow_or_signal_addr, if thepm->deny_join_id0flag is set, and the remote address id is zero, stop this connection.Signed-off-by Geliang Tang <[email protected]>---
net/mptcp/options.c | 6 ++++++ net/mptcp/pm.c | 1 + net/mptcp/pm_netlink.c | 4 +++- net/mptcp/protocol.h | 4 +++- net/mptcp/subflow.c | 2 ++ 5 files changed, 15 insertions(+), 2 deletions(-)net/mptcp/options.c +6
-0@@ -77,6 +77,9 @@ static void mptcp_parse_option(const struct sk_buff *skb,if (flags &MPTCP_CAP_CHECKSUM_REQD )break ; +if (flags &MPTCP_CAP_DENY_JOIN_ID0 ) + mp_opt->deny_join_id0 =1 ; + mp_opt->mp_capable =1 ;if (opsize >=TCPOLEN_MPTCP_MPC_SYNACK ) { mp_opt->sndr_key =get_unaligned_be64 (ptr);@@ -342,6 +345,7 @@ void mptcp_get_options(const struct sk_buff *skb, mp_opt->dss =0 ; mp_opt->mp_prio =0 ; mp_opt->reset =0 ; + mp_opt->deny_join_id0 =0 ; length = (th->doff *4 ) -sizeof (struct tcphdr ); ptr = (const unsigned char *)(th +1 );@@ -1012,6 +1016,8 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) }mptcp_get_options (skb, &mp_opt); +if (mp_opt.deny_join_id0) +WRITE_ONCE (msk->pm.deny_join_id0, true);if (!check_fully_established (msk, sk, subflow, skb, &mp_opt))return ;net/mptcp/pm.c +1
-0@@ -320,6 +320,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)WRITE_ONCE (msk->pm.addr_signal,0 );WRITE_ONCE (msk->pm.accept_addr, false);WRITE_ONCE (msk->pm.accept_subflow, false); +WRITE_ONCE (msk->pm.deny_join_id0, false); msk->pm.status =0 ;spin_lock_init (&msk->pm.lock);net/mptcp/pm_netlink.c +3
-1@@ -456,10 +456,12 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)if (local) {struct mptcp_addr_info remote = {0 }; +remote_address ((struct sock_common *)sk, &remote); +if (!remote.id &&READ_ONCE (msk->pm.deny_join_id0)) +return ; msk->pm.local_addr_used++; msk->pm.subflows++;check_work_pending (msk); -remote_address ((struct sock_common *)sk, &remote);spin_unlock_bh (&msk->pm.lock);__mptcp_subflow_connect (sk, &local->addr, &remote, local->flags, local->ifindex);net/mptcp/protocol.h +2
-1@@ -134,7 +134,8 @@ struct mptcp_options_received { rm_addr : 1, mp_prio : 1, echo : 1, - backup : 1; + backup : 1, + deny_join_id0 : 1;u32 token;u32 nonce;u64 thmac;
net/mptcp/protocol.h struct mptcp_pm_data { · line 193
Quoted 4 lines
net/mptcp/protocol.h +1
-0@@ -189,6 +190,7 @@ struct mptcp_pm_data {bool work_pending;bool accept_addr;bool accept_subflow; +bool deny_join_id0;
I suggest "remote_deny_join_id0" here to clarify that this means "the peer will deny id0 joins" not "this PM will deny id0 joins". The naming in mptcp_options_received does not need to change, it is just referring to the flag.
Quoted 21 lines
net/mptcp/protocol.h +0
-0u8 add_addr_signaled;u8 add_addr_accepted;u8 local_addr_used;net/mptcp/subflow.c +2
-0@@ -405,6 +405,8 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) goto fallback; } +if (mp_opt.deny_join_id0) +WRITE_ONCE (mptcp_sk (parent)->pm.deny_join_id0, true); subflow->mp_capable =1 ; subflow->can_ack =1 ; subflow->remote_key = mp_opt.sndr_key;Signature · 1 line
2.30.2
--
Mat Martineau
Intel
Re: [MPTCP][PATCH v3 mptcp-next 2/4] mptcp: add allow_join_id0 in mptcp_out_options
In reply to Geliang TangQuoted 19 lines · Geliang Tang
This patch defined a new flag
MPTCP_CAP_DENY_JOIN_ID0for the third bit, labeled "C" of theMP_CAPABLEoption.Add a new flag
allow_join_id0in structmptcp_out_options. If this flag is set, send out theMP_CAPABLEoption with the flagMPTCP_CAP_DENY_JOIN_ID0.Signed-off-by Geliang Tang <[email protected]>---
include/net/mptcp.h | 3 ++- net/mptcp/options.c | 10 ++++++++-- net/mptcp/protocol.h | 6 ++++-- net/mptcp/subflow.c | 1 + 4 files changed, 15 insertions(+), 5 deletions(-)include/net/mptcp.h +0
-0
include/net/mptcp.h struct mptcp_out_options { · line 68
Quoted 6 lines
include/net/mptcp.h +2
-1@@ -64,7 +64,8 @@ struct mptcp_out_options {u8 join_id;u8 backup; u8 reset_reason:4; - u8 reset_transient:1; + u8 reset_transient:1, + allow_join_id0:1;
The bitfield declarations should be consistent here, either:
u8 reset_reason:4; u8 reset_transient:1; u8 allow_join_id0:1;
or:
u8 reset_reason:4, reset_transient:1, allow_join_id0:1;
Thanks,
Mat
Quoted 96 lines
include/net/mptcp.h +0
-0u32 nonce;u64 thmac;u32 token;net/mptcp/options.c +8
-2@@ -381,6 +381,7 @@ bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb, subflow->snd_isn =TCP_SKB_CB (skb)->end_seq;if (subflow->request_mptcp) { opts->suboptions =OPTION_MPTCP_MPC_SYN ; + opts->allow_join_id0 =mptcp_is_allow_join_id0 (sock_net (sk)); *size =TCPOLEN_MPTCP_MPC_SYN ;return true; }else if (subflow->request_join) {@@ -466,6 +467,7 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, opts->suboptions =OPTION_MPTCP_MPC_ACK ; opts->sndr_key = subflow->local_key; opts->rcvr_key = subflow->remote_key; + opts->allow_join_id0 =mptcp_is_allow_join_id0 (sock_net (sk));/* Section 3.1. * The MP_CAPABLE option is carried on the SYN, SYN/ACK, and ACK @@ -790,6 +792,7 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,if (subflow_req->mp_capable) { opts->suboptions =OPTION_MPTCP_MPC_SYNACK ; opts->sndr_key = subflow_req->local_key; + opts->allow_join_id0 = subflow_req->allow_join_id0; *size =TCPOLEN_MPTCP_MPC_SYNACK ;pr_debug ("subflow_req=%p, local_key=%llu" , subflow_req, subflow_req->local_key);@@ -1124,7 +1127,7 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, {if ((OPTION_MPTCP_MPC_SYN |OPTION_MPTCP_MPC_SYNACK |OPTION_MPTCP_MPC_ACK ) & opts->suboptions) { -u8 len; +u8 len, flag =MPTCP_CAP_HMAC_SHA256 ;if (OPTION_MPTCP_MPC_SYN & opts->suboptions) len =TCPOLEN_MPTCP_MPC_SYN ;@@ -1135,9 +1138,12 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,else len =TCPOLEN_MPTCP_MPC_ACK ; +if (!opts->allow_join_id0) + flag |=MPTCP_CAP_DENY_JOIN_ID0 ; + *ptr++ =mptcp_option (MPTCPOPT_MP_CAPABLE , len,MPTCP_SUPPORTED_VERSION , -MPTCP_CAP_HMAC_SHA256 ); + flag);if (!((OPTION_MPTCP_MPC_SYNACK |OPTION_MPTCP_MPC_ACK ) & opts->suboptions))net/mptcp/protocol.h +4
-2@@ -77,8 +77,9 @@#define MPTCP_VERSION_MASK (0x0F)#define MPTCP_CAP_CHECKSUM_REQD BIT(7)#define MPTCP_CAP_EXTENSIBILITY BIT(6) +#define MPTCP_CAP_DENY_JOIN_ID0 BIT(5)#define MPTCP_CAP_HMAC_SHA256 BIT(0) -#define MPTCP_CAP_FLAG_MASK (0x3F) +#define MPTCP_CAP_FLAG_MASK (0x1F)/* MPTCP DSS flags */ #define MPTCP_DSS_DATA_FIN BIT(4)@@ -338,7 +339,8 @@ struct mptcp_subflow_request_sock {struct tcp_request_sock sk; u16 mp_capable : 1, mp_join : 1, - backup : 1; + backup : 1, + allow_join_id0 : 1;u8 local_id;u8 remote_id;u64 local_key;net/mptcp/subflow.c +1
-0@@ -108,6 +108,7 @@ static void subflow_init_req(struct request_sock *req, const struct sock *sk_lis subflow_req->mp_capable =0 ; subflow_req->mp_join =0 ; + subflow_req->allow_join_id0 =mptcp_is_allow_join_id0 (sock_net (sk_listener)); subflow_req->msk =NULL ;mptcp_token_init_request (req); }Signature · 1 line
2.30.2
--
Mat Martineau
Intel
Re: [MPTCP][PATCH v3 mptcp-next 1/4] mptcp: add sysctl allow_join_initial_addr_port
In reply to Geliang TangQuoted 45 lines · Geliang Tang
This patch added a new sysctl, named
allow_join_initial_addr_port, to control whether allow peers to send join requests to the IP address and port number used by the initial subflow.Signed-off-by Geliang Tang <[email protected]>---
Documentation/networking/mptcp-sysctl.rst | 13 +++++++++++++ net/mptcp/ctrl.c | 16 ++++++++++++++++ net/mptcp/protocol.h | 1 + 3 files changed, 30 insertions(+)Documentation/networking/mptcp-sysctl.rst +13
-0@@ -24,3 +24,16 @@ add_addr_timeout - INTEGER (seconds) sysctl. Default: 120 + +allow_join_initial_addr_port - INTEGER + Allow peers to send join requests to the IP address and port number used + by the initial subflow if the value is 1. This controls a flag that is + sent to the peer at connection time, and whether such join requests are + accepted or denied. + + Joins to addresses advertised with ADD_ADDR are not affected by this + value. + + This is a per-namespace sysctl. + + Default: 1net/mptcp/ctrl.c +1
-0@@ -19,6 +19,7 @@ struct mptcp_pernet {u8 mptcp_enabled;unsigned int add_addr_timeout; +u8 allow_join_initial_addr_port; };static struct mptcp_pernet *mptcp_get_pernet (struct net *net)
net/mptcp/ctrl.c unsigned int mptcp_get_add_addr_timeout(struct net *net) · line 40
Quoted 4 lines
net/mptcp/ctrl.c +1
-0@@ -36,6 +37,11 @@ unsigned int mptcp_get_add_addr_timeout(struct net *net)return mptcp_get_pernet (net)->add_addr_timeout; } +int mptcp_is_allow_join_id0 (struct net *net)
I suggest "mptcp_allow_join_id0(struct net *net)"
Thanks,
Mat
Quoted 55 lines
net/mptcp/ctrl.c +14
-0+{ +return mptcp_get_pernet (net)->allow_join_initial_addr_port; +} +static struct ctl_table mptcp_sysctl_table[] = { { .procname ="enabled" ,@@ -54,6 +60,14 @@ static struct ctl_table mptcp_sysctl_table[] = { .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, + { + .procname = "allow_join_initial_addr_port", + .maxlen = sizeof(u8), + .mode = 0644, + .proc_handler = proc_dou8vec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE + }, {} };@@ -61,6 +75,7 @@ static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet) { pernet->mptcp_enabled =1 ; pernet->add_addr_timeout =TCP_RTO_MAX ; + pernet->allow_join_initial_addr_port =1 ; }static int mptcp_pernet_new_table (struct net *net,struct mptcp_pernet *pernet)@@ -77,6 +92,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) table[0 ].data = &pernet->mptcp_enabled; table[1 ].data = &pernet->add_addr_timeout; + table[2 ].data = &pernet->allow_join_initial_addr_port; hdr =register_net_sysctl (net,MPTCP_SYSCTL_PATH , table);if (!hdr)net/mptcp/protocol.h +1
-0@@ -524,6 +524,7 @@ static inline void mptcp_subflow_delegated_done(struct mptcp_subflow_context *suint mptcp_is_enabled (struct net *net);unsigned int mptcp_get_add_addr_timeout (struct net *net); +int mptcp_is_allow_join_id0 (struct net *net);void mptcp_subflow_fully_established (struct mptcp_subflow_context *subflow,struct mptcp_options_received *mp_opt);bool mptcp_subflow_data_available (struct sock *sk);Signature · 1 line
2.30.2
--
Mat Martineau
Intel