mptcp: add ADD_ADDR timeout test case and others
Subsystems (3)
Geliang Tang
v5 cover mptcp: add ADD_ADDR timeout test case and others
v5:
- fix nfbpf_compile dependence
- add optional arguments for run_test, drop run_tests_slow and run_remove_tests
- use 'slow/fast' in do_transfer
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 | 73 +++++++++++++------ 5 files changed, 76 insertions(+), 26 deletions(-)
Signature · 1 line
2.26.2
Geliang Tang
PATCH v5 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 v5 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.
Here we need to slow down the transfer process of all data to let the ADD_ADDR suboptions can be retransmitted three times. So we added a new parameter "speed" for do_transfer, it can be set with fast or slow.
We also added three new optional parameters for run_tests, and dropped run_remove_tests function.
Since we added the netfilter rules in this test case, we need to update the "config" file.
--- tools/testing/selftests/net/mptcp/config | 6 ++ .../testing/selftests/net/mptcp/mptcp_join.sh | 73 +++++++++++++------ 2 files changed, 55 insertions(+), 24 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 +49 -24
140 lines not on this page · raw message
Signature · 1 line
2.26.2
Geliang Tang
[MPTCP] Re: [MPTCP][PATCH v5 mptcp-next 2/2] selftests: mptcp: add ADD_ADDR timeout test case
Hi Matt,
As I mentioned in the last meeting, I want to add ADD_ADDR timeout IPv6 test case. My patch is something like this:
+reset_with_add_addr6_timeout()
+{
+ reset
+
+ ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
+ ip netns exec $ns2 ip6tables -A OUTPUT -p tcp \
+ -m tcp --tcp-option 30 \
+ -m bpf --bytecode \
+ "$(nfbpf_compile '(tcp[34] & 0xf0) == 0x30')" \
+ -j DROP
+}
+
for arg in "$@"; do
if [ "$arg" = "-c" ]; then
capture=1@@ -590,6 +604,22 @@ ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow
run_tests $ns1 $ns2 dead:beef:1::1 0 0 slow
chk_join_nr "single subflow IPv6" 1 1 1
+# add_addr timeout IPv6 +reset_with_add_addr6_timeout
+ip netns exec $ns1 ./pm_nl_ctl limits 0 1
+ip netns exec $ns2 ./pm_nl_ctl limits 1 1
+ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal +run_tests $ns1 $ns2 dead:beef:1::1 0 0 slow +chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 +chk_add_nr 4 0
+
# signal address IPv6 reset ip netns exec $ns1 ./pm_nl_ctl limits 0 1
But this BPF (tcp[34] & 0xf0) == 0x30') is not working on IPv6, please give me some help
about how to get this right offset value on IPv6. Thanks very much.
-Geliang
Quoted 194 lines · Geliang Tang <geliangtang(a)gmail.com> 于2020年10月1日周四 下午3:26写道:
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.Here we need to slow down the transfer process of all data to let the
ADD_ADDRsuboptions can be retransmitted three times. So we added a new parameter "speed" fordo_transfer, it can be set with fast or slow.We also added three new optional parameters for
run_tests, and droppedrun_remove_testsfunction.Since we added the netfilter rules in this test case, we need to update the "config" file.
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>--- tools/testing/selftests/net/mptcp/config | 6 ++ .../testing/selftests/net/mptcp/mptcp_join.sh | 73 +++++++++++++------ 2 files changed, 55 insertions(+), 24 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=mtools/testing/selftests/net/mptcp/mptcp_join.sh +49
-25@@ -13,6 +13,22 @@ capture=0 TEST_COUNT=0 +# generated using "nfbpf_compile '(tcp[34] & 0xf0) == 0x30'" +CBPF_MPTCP_SUBOPTION_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" + init() { capout=$(mktemp)@@ -82,6 +98,18 @@ reset_with_cookies() done } +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 \ + "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ + -j DROP +} + for arg in "$@"; do if [ "$arg" = "-c" ]; then capture=1@@ -135,6 +163,7 @@ do_transfer() connect_addr="$5" rm_nr_ns1="$6" rm_nr_ns2="$7" + speed="$8" port=$((10000+$TEST_COUNT)) TEST_COUNT=$((TEST_COUNT+1))@@ -159,7 +188,7 @@ do_transfer() sleep 1 fi - if [[ $rm_nr_ns1 -eq 0 && $rm_nr_ns2 -eq 0 ]]; then + if [ $speed = "fast" ]; then mptcp_connect="./mptcp_connect -j" else mptcp_connect="./mptcp_connect -r"@@ -250,26 +279,13 @@ run_tests() listener_ns="$1" connector_ns="$2" connect_addr="$3" + rm_nr_ns1="${4:-0}" + rm_nr_ns2="${5:-0}" + speed="${6:-fast}" lret=0 - do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} 0 0 - lret=$? - if [ $lret -ne 0 ]; then - ret=$lret - return - fi -} - -run_remove_tests() -{ - listener_ns="$1" - connector_ns="$2" - connect_addr="$3" - rm_nr_ns1="$4" - rm_nr_ns2="$5" - lret=0 - - do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} ${rm_nr_ns1} ${rm_nr_ns2} + do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ + ${rm_nr_ns1} ${rm_nr_ns2} ${speed} lret=$? if [ $lret -ne 0 ]; then ret=$lret@@ -491,12 +507,21 @@ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr "multiple subflows and signal" 3 3 3 chk_add_nr 1 1 +# add_addr timeout +reset_with_add_addr_timeout +ip netns exec $ns1 ./pm_nl_ctl limits 0 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 0 0 slow +chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1 +chk_add_nr 4 0 + # single subflow, remove reset ip netns exec $ns1 ./pm_nl_ctl limits 0 1 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow -run_remove_tests $ns1 $ns2 10.0.1.1 0 1 +run_tests $ns1 $ns2 10.0.1.1 0 1 slow chk_join_nr "remove single subflow" 1 1 1 chk_rm_nr 1 1@@ -506,7 +531,7 @@ ip netns exec $ns1 ./pm_nl_ctl limits 0 2 ip netns exec $ns2 ./pm_nl_ctl limits 0 2 ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow -run_remove_tests $ns1 $ns2 10.0.1.1 0 2 +run_tests $ns1 $ns2 10.0.1.1 0 2 slow chk_join_nr "remove multiple subflows" 2 2 2 chk_rm_nr 2 2@@ -515,7 +540,7 @@ reset ip netns exec $ns1 ./pm_nl_ctl limits 0 1 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal ip netns exec $ns2 ./pm_nl_ctl limits 1 1 -run_remove_tests $ns1 $ns2 10.0.1.1 1 0 +run_tests $ns1 $ns2 10.0.1.1 1 0 slow chk_join_nr "remove single address" 1 1 1 chk_add_nr 1 1 chk_rm_nr 0 0@@ -526,7 +551,7 @@ ip netns exec $ns1 ./pm_nl_ctl limits 0 2 ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal ip netns exec $ns2 ./pm_nl_ctl limits 1 2 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow -run_remove_tests $ns1 $ns2 10.0.1.1 1 1 +run_tests $ns1 $ns2 10.0.1.1 1 1 slow chk_join_nr "remove subflow and signal" 2 2 2 chk_add_nr 1 1 chk_rm_nr 1 1@@ -538,7 +563,7 @@ ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal ip netns exec $ns2 ./pm_nl_ctl limits 1 3 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow -run_remove_tests $ns1 $ns2 10.0.1.1 1 2 +run_tests $ns1 $ns2 10.0.1.1 1 2 slow chk_join_nr "remove subflows and signal" 3 3 3 chk_add_nr 1 1 chk_rm_nr 2 2 --2.26.2
Matthieu Baerts
[MPTCP] Re: [MPTCP][PATCH v5 mptcp-next 2/2] selftests: mptcp: add ADD_ADDR timeout test case
Hi Geliang,
Quoted 38 lines · Geliang Tang
Hi Matt,
As I mentioned in the last meeting, I want to add
ADD_ADDRtimeout IPv6 test case. My patch is something like this:tools/testing/selftests/net/mptcp/mptcp_join.sh +12
-0+reset_with_add_addr6_timeout() +{ + reset + + ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 + ip netns exec $ns2 ip6tables -A OUTPUT -p tcp \ + -m tcp --tcp-option 30 \ + -m bpf --bytecode \ + "$(nfbpf_compile '(tcp[34] & 0xf0) == 0x30')" \ + -j DROP +} + for arg in "$@"; do if [ "$arg" = "-c" ]; then capture=1@@ -590,6 +604,22 @@ ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2flags subflow
run_tests$ns1 $ns2 dead:beef:1::1 0 0 slow
chk_join_nr"single subflow IPv6" 1 1 1tools/testing/selftests/net/mptcp/mptcp_join.sh +9
-0+# add_addr timeout IPv6 +reset_with_add_addr6_timeout +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 1 1 +ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal +run_tests $ns1 $ns2 dead:beef:1::1 0 0 slow +chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 +chk_add_nr 4 0 + # signal address IPv6 reset ip netns exec $ns1 ./pm_nl_ctl limits 0 1
Quoted 3 lines
But this BPF (tcp[34] &
0xf0) ==0x30') is not working on IPv6, please give me some help
about how to get this right offset value on IPv6. Thanks very much.
It looks like it cannot get the offset correctly with TCP. The best is then to start from the IP layer and suppose there will not be any IPv6
extension: we control the selftests environment and we already check with IPTables that we have TCP.
$ docker run quay.io/casey_callendrello/nfbpf_compile RAW "(ip[54] & 0xf0) == 0x30" 8,48 0 0 0,84 0 0 240,21 0 4 64,48 0 0 54,84 0 0 240,21 0 1 48,6 0 0 65535,6 0 0 0
$ docker run quay.io/casey_callendrello/nfbpf_compile RAW "(ip6[74] & 0xf0) == 0x30" 8,48 0 0 0,84 0 0 240,21 0 4 96,48 0 0 74,84 0 0 240,21 0 1 48,6 0 0 65535,6 0 0 0
May you try with these two new bytecodes please?
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Geliang Tang
[MPTCP] Re: [MPTCP][PATCH v5 mptcp-next 2/2] selftests: mptcp: add ADD_ADDR timeout test case
Hi Matt,
Quoted 58 lines · Matthieu Baerts <matthieu.baerts(a)tessares.net> 于2020年10月16日周五 下午11:02写道:
Hi Geliang,
Quoted 38 lines · Geliang Tang
Hi Matt,
As I mentioned in the last meeting, I want to add
ADD_ADDRtimeout IPv6 test case. My patch is something like this:tools/testing/selftests/net/mptcp/mptcp_join.sh +12
-0+reset_with_add_addr6_timeout() +{ + reset + + ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 + ip netns exec $ns2 ip6tables -A OUTPUT -p tcp \ + -m tcp --tcp-option 30 \ + -m bpf --bytecode \ + "$(nfbpf_compile '(tcp[34] & 0xf0) == 0x30')" \ + -j DROP +} + for arg in "$@"; do if [ "$arg" = "-c" ]; then capture=1@@ -590,6 +604,22 @@ ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2flags subflow
run_tests$ns1 $ns2 dead:beef:1::1 0 0 slow
chk_join_nr"single subflow IPv6" 1 1 1tools/testing/selftests/net/mptcp/mptcp_join.sh +9
-0+# add_addr timeout IPv6 +reset_with_add_addr6_timeout +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 1 1 +ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal +run_tests $ns1 $ns2 dead:beef:1::1 0 0 slow +chk_join_nr "signal address, ADD_ADDR6 timeout" 1 1 1 +chk_add_nr 4 0 + # signal address IPv6 reset ip netns exec $ns1 ./pm_nl_ctl limits 0 1Quoted 3 lines
But this BPF (tcp[34] &
0xf0) ==0x30') is not working on IPv6, please give me some help
about how to get this right offset value on IPv6. Thanks very much.It looks like it cannot get the offset correctly with TCP. The best is then to start from the IP layer and suppose there will not be any IPv6
extension: we control the selftests environment and we already check with IPTables that we have TCP.$ docker run quay.io/casey_callendrello/nfbpf_compile RAW "(ip[54] & 0xf0) == 0x30" 8,48 0 0 0,84 0 0 240,21 0 4 64,48 0 0 54,84 0 0 240,21 0 1 48,6 0 0 65535,6 0 0 0
Quoted 7 lines
$ docker run quay.io/casey_callendrello/nfbpf_compile RAW "(ip6[74] & 0xf0) == 0x30" 8,48 0 0 0,84 0 0 240,21 0 4 96,48 0 0 74,84 0 0 240,21 0 1 48,6 0 0 65535,6 0 0 0May you try with these two new bytecodes please?
I have tested these two bytecodes, they all work well. I'll add them in the ADD_ADDR IPV6 testcase patch.
Thanks.
-Geliang
Quoted 6 lines
Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net