mptcp: add ADD_ADDR timeout test case and others
Subsystems (3)
Geliang Tang
v4 cover mptcp: add ADD_ADDR timeout test case and others
v4:
- use proc_dointvec_jiffies instead of proc_douintvec.
- use the reverse x-mas tree order.
- update the 'config' file for netfilter.
v3:
- rename run_add_addr_timeout_tests to run_tests_slow, it can be reused in other test cases.
v2:
- drop add_addr_echo sysctl in v1
- use iptables rules to drop ADD_ADDR echo packets.
Geliang Tang (2):
mptcp: add a new sysctl add_addr_timeout
selftests: mptcp: add ADD_ADDR timeout test case
net/mptcp/ctrl.c | 14 ++++++ net/mptcp/pm_netlink.c | 8 +++- net/mptcp/protocol.h | 1 + tools/testing/selftests/net/mptcp/config | 6 +++ .../testing/selftests/net/mptcp/mptcp_join.sh | 43 +++++++++++++++++-- 5 files changed, 67 insertions(+), 5 deletions(-)
Signature · 1 line
2.26.2
Geliang Tang
PATCH v4 1/2 mptcp: add a new sysctl add_addr_timeout
This patch added a new sysctl, named add_addr_timeout, to control the timeout value (in seconds) of the ADD_ADDR retransmission.
--- net/mptcp/ctrl.c | 14 ++++++++++++++ net/mptcp/pm_netlink.c | 8 ++++++-- net/mptcp/protocol.h | 1 + 3 files changed, 21 insertions(+), 2 deletions(-)
net/mptcp/ctrl.c +14 -0
@@ -18,6 +18,7 @@ struct mptcp_pernet {struct ctl_table_header *ctl_table_hdr;int mptcp_enabled; +unsigned int add_addr_timeout; };static struct mptcp_pernet *mptcp_get_pernet (struct net *net)
@@ -30,6 +31,11 @@ int mptcp_is_enabled(struct net *net)return mptcp_get_pernet (net)->mptcp_enabled; } +unsigned int mptcp_get_add_addr_timeout (struct net *net) +{ +return mptcp_get_pernet (net)->add_addr_timeout; +} +static struct ctl_table mptcp_sysctl_table[] = { { .procname ="enabled" ,
@@ -40,12 +46,19 @@ static struct ctl_table mptcp_sysctl_table[] = {*/ .proc_handler = proc_dointvec, }, + { + .procname = "add_addr_timeout", + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec_jiffies, + }, {} };static void mptcp_pernet_set_defaults (struct mptcp_pernet *pernet) { pernet->mptcp_enabled =1 ; + pernet->add_addr_timeout =TCP_RTO_MAX ; }static int mptcp_pernet_new_table (struct net *net,struct mptcp_pernet *pernet)
@@ -61,6 +74,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; hdr =register_net_sysctl (net,MPTCP_SYSCTL_PATH , table);if (!hdr)
net/mptcp/pm_netlink.c +6 -2
@@ -206,6 +206,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer)struct mptcp_pm_add_entry *entry =from_timer (entry, timer, add_timer);struct mptcp_sock *msk = entry->sock;struct sock *sk = (struct sock *)msk; +struct net *net =sock_net (sk);pr_debug ("msk=%p" , msk);
@@ -232,7 +233,8 @@ static void mptcp_pm_add_timer(struct timer_list *timer) }if (entry->retrans_times <ADD_ADDR_RETRANS_MAX ) -sk_reset_timer (sk, timer, jiffies +TCP_RTO_MAX ); +sk_reset_timer (sk, timer, + jiffies +mptcp_get_add_addr_timeout (net));spin_unlock_bh (&msk->pm.lock);
@@ -264,6 +266,7 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, {struct mptcp_pm_add_entry *add_entry =NULL ;struct sock *sk = (struct sock *)msk; +struct net *net =sock_net (sk);if (lookup_anno_list_by_saddr (msk, &entry->addr))return false;
@@ -279,7 +282,8 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, add_entry->retrans_times =0 ;timer_setup (&add_entry->add_timer, mptcp_pm_add_timer,0 ); -sk_reset_timer (sk, &add_entry->add_timer, jiffies +TCP_RTO_MAX ); +sk_reset_timer (sk, &add_entry->add_timer, + jiffies +mptcp_get_add_addr_timeout (net));return true; }
net/mptcp/protocol.h +1 -0
@@ -361,6 +361,7 @@ mptcp_subflow_get_mapped_dsn(const struct mptcp_subflow_context *subflow) }int mptcp_is_enabled (struct net *net); +unsigned int mptcp_get_add_addr_timeout (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.26.2
Geliang Tang
PATCH v4 2/2 selftests: mptcp: add ADD_ADDR timeout test case
This patch added the test case for retransmitting ADD_ADDR when timeout occurs. It set NS1's add_addr_timeout to 1 second, and drop NS2's ADD_ADDR echo packets.
And we need to slow down the transfer process of all data to let the ADD_ADDR suboptions can be retransmitted three times.
--- tools/testing/selftests/net/mptcp/config | 6 +++ .../testing/selftests/net/mptcp/mptcp_join.sh | 43 +++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/config +6 -0
@@ -4,3 +4,9 @@ CONFIG_INET_DIAG=m CONFIG_INET_MPTCP_DIAG=m CONFIG_VETH=y CONFIG_NET_SCH_NETEM=m +CONFIG_NETFILTER=y +CONFIG_NETFILTER_ADVANCED=y +CONFIG_NETFILTER_XTABLES=m +CONFIG_NETFILTER_XT_MATCH_BPF=m +CONFIG_IP_NF_IPTABLES=m +CONFIG_IP_NF_FILTER=m
tools/testing/selftests/net/mptcp/mptcp_join.sh +40 -3
79 lines not on this page · raw message
Signature · 1 line
2.26.2
Matthieu Baerts
[MPTCP] Re: [MPTCP][PATCH v4 mptcp-next 2/2] selftests: mptcp: add ADD_ADDR timeout test case
Hi Geliang,
Quoted 11 lines · Geliang Tang
This patch added the test case for retransmitting
ADD_ADDRwhen timeout occurs. It set NS1'sadd_addr_timeoutto 1 second, and drop NS2'sADD_ADDRecho packets.And we need to slow down the transfer process of all data to let the
ADD_ADDRsuboptions can be retransmitted three times.Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>Suggested-by Paolo Abeni <pabeni(a)redhat.com>Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
Thank you for this useful new test! Sorry for the late review.
(...)
Quoted 7 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +0
-0@@ -82,6 +82,18 @@ reset_with_cookies() done }
tools/testing/selftests/net/mptcp/mptcp_join.sh reset_with_cookies() · line 93
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +9
-0+reset_with_add_addr_timeout() +{ + reset + + ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 + ip netns exec $ns2 iptables -A OUTPUT -p tcp \ + -m tcp --tcp-option 30 \ + -m bpf --bytecode \ + "$(nfbpf_compile '(tcp[34] & 0xf0) == 0x30')" \
I would suggest here to put the result in a variable with a comment about how to re-generate the value. Because I don't think many setups already have this dependence available by default (and many might not want to include it). Maybe you can declare something like this at the top of the file.
# generated using $(nfbpf_compile '(tcp[34] & 0xf0) == 0x30') CBPF_MPTCP_SUBTYPE_ADD_ADDR="13,48 0 0 0,84 0 0 240,21 0 9 64,48 0 0 9,21 0 7 6,40 0 0 6,69 5 0 8191,177 0 0 0,80 0 0 34,84 0 0 240,21 0 1 48,6 0 0 65535,6 0 0 0"
Quoted 24 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +5
-1+ -j DROP +} + for arg in "$@"; do if [ "$arg" = "-c" ]; then capture=1@@ -135,6 +147,7 @@ do_transfer() connect_addr="$5" rm_nr_ns1="$6" rm_nr_ns2="$7" + slow="$8" port=$((10000+$TEST_COUNT)) TEST_COUNT=$((TEST_COUNT+1))@@ -159,7 +172,7 @@ do_transfer() sleep 1 fi - if [[ $rm_nr_ns1 -eq 0 && $rm_nr_ns2 -eq 0 ]]; then + if [ $slow -eq 0 ]; then mptcp_connect="./mptcp_connect -j" else mptcp_connect="./mptcp_connect -r"
tools/testing/selftests/net/mptcp/mptcp_join.sh run_tests() · line 268
Quoted 5 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +1
-1@@ -252,7 +265,22 @@ run_tests() connect_addr="$3" lret=0 - do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} 0 0 + do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} 0 0 0
No need to modify this here but in the future, we should maybe avoid these "0/1" value but use string, e.g. "slow/fast",
Quoted 5 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +5
-0+ lret=$? + if [ $lret -ne 0 ]; then + ret=$lret + return + fi
tools/testing/selftests/net/mptcp/mptcp_join.sh run_tests() · line 283
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +10
-0+} + +run_tests_slow() +{ + listener_ns="$1" + connector_ns="$2" + connect_addr="$3" + lret=0 + + do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} 0 0 1
Maybe and if you have to modify this patch, should we avoid duplicate the code here with run_tests() and run_tests_slow()? We could have run_tests() taking an optional 4th argument, e.g.
run_tests()
{
(...)
slow="${4:-0}"
(...)
}
run_tests_slow()
{
run_tests "${@}" 1
}(or only defined run_tests() and below, call run_tests() directly with a 4th argument)
WDYT?
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Paolo Abeni
Quoted 17 lines · Geliang Tang
v4:
- useproc_dointvec_jiffiesinstead ofproc_douintvec.
- use the reverse x-mas tree order.
- update the 'config' file for netfilter.v3:
- renamerun_add_addr_timeout_teststorun_tests_slow, it can be reused in other test cases.v2:
- dropadd_addr_echosysctl in v1
- use iptables rules to dropADD_ADDRecho packets.Geliang Tang (2):
mptcp: add a new sysctladd_addr_timeout
selftests: mptcp: addADD_ADDRtimeout test case
Quoted 6 lines
net/mptcp/ctrl.c | 14 ++++++ net/mptcp/pm_netlink.c | 8 +++- net/mptcp/protocol.h | 1 + tools/testing/selftests/net/mptcp/config | 6 +++ .../testing/selftests/net/mptcp/mptcp_join.sh | 43 +++++++++++++++++-- 5 files changed, 67 insertions(+), 5 deletions(-)
LGTM, thanks!
Note: I did not explicitly check the [k]config deps in patch 2/2, but I guess problem there - if any! - could be addressed later.
/P