:p
atchew
Login
This is a new version of Geliang's series called "send MP_FAIL with MP_RST and others". The Squash-to patch is the same as the draft I previously sent but fixing a compilation issue: MP_RST can be sent with MP_FASTCLOSE and MP_FAIL but MP_FASTCLOSE cannot be sent with MP_FAIL. Patch 2/4 has not been modified. Here, you might want to start looking at "mptcp: clarify when options can be used" and check if everything is OK for you related to when options can be used together. If this is OK, the logic behind the Squash-to patch should be OK. Of course, the implementation might not be OK but that's different :) Patch 4/4 is there just to have mptcp_established_options() in sync with mptcp_write_options() (and the RFC). Happy New Year! Geliang Tang (2): Squash to "mptcp: implement fastclose xmit path" mptcp: print out reset infos of MP_RST Matthieu Baerts (2): mptcp: clarify when options can be used mptcp: allow sending both ADD_ADDR and RM_ADDR net/mptcp/options.c | 94 ++++++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 27 deletions(-) -- 2.33.1
From: Geliang Tang <geliang.tang@suse.com> MP_FAIL could be sent with RST or DSS, and FASTCLOSE can be sent with RST too. So we should use a similar xmit logic for FASTCLOSE and MP_FAIL in both mptcp_write_options() and mptcp_established_options*(). Cc: Paolo Abeni <pabeni@redhat.com> Co-developed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/options.c | 66 ++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -XXX,XX +XXX,XX @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, if (unlikely(skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST)) { if (mptcp_established_options_fastclose(sk, &opt_size, remaining, opts) || - mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts) || - mptcp_established_options_rst(sk, skb, &opt_size, remaining, opts)) { + mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts)) { + *size += opt_size; + remaining -= opt_size; + } + /* MP_RST can be used with MP_FASTCLOSE and MP_FAIL if there is room */ + if (mptcp_established_options_rst(sk, skb, &opt_size, remaining, opts)) { *size += opt_size; remaining -= opt_size; } @@ -XXX,XX +XXX,XX @@ static u16 mptcp_make_csum(const struct mptcp_ext *mpext) void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, struct mptcp_out_options *opts) { - if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) { - const struct sock *ssk = (const struct sock *)tp; - struct mptcp_subflow_context *subflow; - - subflow = mptcp_subflow_ctx(ssk); - subflow->send_mp_fail = 0; - - *ptr++ = mptcp_option(MPTCPOPT_MP_FAIL, - TCPOLEN_MPTCP_FAIL, - 0, 0); - put_unaligned_be64(opts->fail_seq, ptr); - ptr += 2; - } - - /* DSS, MPC, MPJ, ADD_ADDR, FASTCLOSE and RST are mutually exclusive, + /* DSS, MPC, MPJ, ADD_ADDR, FASTCLOSE and FAIL are mutually exclusive, * see mptcp_established_options*() */ if (likely(OPTION_MPTCP_DSS & opts->suboptions)) { @@ -XXX,XX +XXX,XX @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, TCPOPT_NOP << 8 | TCPOPT_NOP, ptr); } } + + /* We might need to add MP_FAIL options in rare cases */ + if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) + goto mp_fail; } else if (OPTIONS_MPTCP_MPC & opts->suboptions) { u8 len, flag = MPTCP_CAP_HMAC_SHA256; @@ -XXX,XX +XXX,XX @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, ptr += 1; } } - } else if (unlikely(OPTION_MPTCP_RST & opts->suboptions)) { - /* RST is mutually exclusive with everything else */ - *ptr++ = mptcp_option(MPTCPOPT_RST, - TCPOLEN_MPTCP_RST, - opts->reset_transient, - opts->reset_reason); - return; } else if (unlikely(OPTION_MPTCP_FASTCLOSE & opts->suboptions)) { - /* FASTCLOSE is mutually exclusive with everything else */ + /* FASTCLOSE is mutually exclusive with others except RST */ *ptr++ = mptcp_option(MPTCPOPT_MP_FASTCLOSE, TCPOLEN_MPTCP_FASTCLOSE, 0, 0); put_unaligned_be64(opts->rcvr_key, ptr); + + if (OPTION_MPTCP_RST & opts->suboptions) + goto mp_rst; + return; + } else if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) +mp_fail: + { + /* MP_FAIL is mutually exclusive with others except RST */ + const struct sock *ssk = (const struct sock *)tp; + struct mptcp_subflow_context *subflow; + + subflow = mptcp_subflow_ctx(ssk); + subflow->send_mp_fail = 0; + + *ptr++ = mptcp_option(MPTCPOPT_MP_FAIL, + TCPOLEN_MPTCP_FAIL, + 0, 0); + put_unaligned_be64(opts->fail_seq, ptr); + ptr += 2; + + if (OPTION_MPTCP_RST & opts->suboptions) + goto mp_rst; + return; + } else if (unlikely(OPTION_MPTCP_RST & opts->suboptions)) { +mp_rst: + *ptr++ = mptcp_option(MPTCPOPT_RST, + TCPOLEN_MPTCP_RST, + opts->reset_transient, + opts->reset_reason); return; } -- 2.33.1
From: Geliang Tang <geliang.tang@suse.com> This patch printed out the reset infos, reset_transient and reset_reason, of MP_RST in mptcp_parse_option() to show that MP_RST is received. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/options.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -XXX,XX +XXX,XX @@ static void mptcp_parse_option(const struct sk_buff *skb, flags = *ptr++; mp_opt->reset_transient = flags & MPTCP_RST_TRANSIENT; mp_opt->reset_reason = *ptr; + pr_debug("MP_RST: transient=%u reason=%u", + mp_opt->reset_transient, mp_opt->reset_reason); break; case MPTCPOPT_MP_FAIL: -- 2.33.1
RFC8684 doesn't seem to clearly specify which MPTCP options can be used together. Some options are mutually exclusive -- e.g. MP_CAPABLE and MP_JOIN --, some can be used together -- e.g. DSS + MP_PRIO --, some can but we prefer not to -- e.g. DSS + ADD_ADDR -- and some have to be used together at some points -- e.g. MP_FAIL and DSS. We need to clarify this as a base before allowing other modifications. For example, does it make sense to send a RM_ADDR with an MPC or MPJ? This remains open for possible future discussions. Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> --- net/mptcp/options.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -XXX,XX +XXX,XX @@ static u16 mptcp_make_csum(const struct mptcp_ext *mpext) void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, struct mptcp_out_options *opts) { - /* DSS, MPC, MPJ, ADD_ADDR, FASTCLOSE and FAIL are mutually exclusive, - * see mptcp_established_options*() + /* Which options can be used together? + * + * X: mutually exclusive + * O: often used together + * C: can be used together in some cases + * P: could be used together but we prefer not to (optimisations) + * + * Opt: | MPC | MPJ | DSS | ADD | RM | PRIO | FAIL | FC | + * ------|------|------|------|------|------|------|------|------| + * MPC |------|------|------|------|------|------|------|------| + * MPJ | X |------|------|------|------|------|------|------| + * DSS | X | X |------|------|------|------|------|------| + * ADD | X | X | P |------|------|------|------|------| + * RM | C | C | C | C |------|------|------|------| + * PRIO | X | C | C | C | C |------|------|------| + * FAIL | X | X | C | X | X | X |------|------| + * FC | X | X | X | X | X | X | X |------| + * RST | X | X | X | X | X | X | O | O | + * ------|------|------|------|------|------|------|------|------| + * + * The same applies in mptcp_established_options() function. */ if (likely(OPTION_MPTCP_DSS & opts->suboptions)) { struct mptcp_ext *mpext = &opts->ext_copy; -- 2.33.1
This is mainly to be sync with what is done in mptcp_write_options() where after having written the ADD_ADDR option, we check if the RM_ADDR option also needs to be added. But if we have room, it makes sense to write the two options in the same packet. So best to remove the 'else'. While at it, also mention that mptcp_established_options_add_addr() can remove options. Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> --- net/mptcp/options.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -XXX,XX +XXX,XX @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, *size += opt_size; remaining -= opt_size; + /* Note: this can remove previously set options in some conditions */ if (mptcp_established_options_add_addr(sk, skb, &opt_size, remaining, opts)) { *size += opt_size; remaining -= opt_size; ret = true; - } else if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, opts)) { + } + + if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, opts)) { *size += opt_size; remaining -= opt_size; ret = true; -- 2.33.1
v9: - drop patch 1-3 in v8, they are accepted. - drop patch 6 in v8. - add a new patch "move the declarations of ssk and subflow" to avoid the compiling errors when moving the mp_fail label. - update patch "reduce branching when writing MP_FAIL option" as Mat suggested. - Change 'ADD+RM' from 'C' to 'P' in patch "clarify when options can be used". Geliang Tang (3): mptcp: move the declarations of ssk and subflow mptcp: print out reset infos of MP_RST selftests: mptcp: add mp_fail testcases Matthieu Baerts (2): mptcp: reduce branching when writing MP_FAIL option mptcp: clarify when options can be used net/mptcp/options.c | 64 +++++++--- tools/testing/selftests/net/mptcp/config | 5 + .../testing/selftests/net/mptcp/mptcp_join.sh | 111 ++++++++++++++++-- 3 files changed, 152 insertions(+), 28 deletions(-) -- 2.31.1
Move the declarations of ssk and subflow in MP_FAIL and MP_PRIO to the beginning of the function mptcp_write_options(). Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/options.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -XXX,XX +XXX,XX @@ static u16 mptcp_make_csum(const struct mptcp_ext *mpext) void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, struct mptcp_out_options *opts) { - if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) { - const struct sock *ssk = (const struct sock *)tp; - struct mptcp_subflow_context *subflow; + const struct sock *ssk = (const struct sock *)tp; + struct mptcp_subflow_context *subflow; + if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) { subflow = mptcp_subflow_ctx(ssk); subflow->send_mp_fail = 0; @@ -XXX,XX +XXX,XX @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, } if (OPTION_MPTCP_PRIO & opts->suboptions) { - const struct sock *ssk = (const struct sock *)tp; - struct mptcp_subflow_context *subflow; - subflow = mptcp_subflow_ctx(ssk); subflow->send_mp_prio = 0; -- 2.31.1
From: Matthieu Baerts <matthieu.baerts@tessares.net> MP_FAIL should be use in very rare cases, either when the TCP RST flag is set -- with or without an MP_RST -- or with a DSS, see mptcp_established_options(). Here, we do the same in mptcp_write_options(). Co-developed-by: Geliang Tang <geliang.tang@suse.com> Signed-off-by: Geliang Tang <geliang.tang@suse.com> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> --- net/mptcp/options.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -XXX,XX +XXX,XX @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, const struct sock *ssk = (const struct sock *)tp; struct mptcp_subflow_context *subflow; - if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) { - subflow = mptcp_subflow_ctx(ssk); - subflow->send_mp_fail = 0; - - *ptr++ = mptcp_option(MPTCPOPT_MP_FAIL, - TCPOLEN_MPTCP_FAIL, - 0, 0); - put_unaligned_be64(opts->fail_seq, ptr); - ptr += 2; - } - /* DSS, MPC, MPJ, ADD_ADDR, FASTCLOSE and RST are mutually exclusive, * see mptcp_established_options*() */ @@ -XXX,XX +XXX,XX @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, } ptr += 1; } + + /* We might need to add MP_FAIL options in rare cases */ + if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) + goto mp_fail; } else if (OPTIONS_MPTCP_MPC & opts->suboptions) { u8 len, flag = MPTCP_CAP_HMAC_SHA256; @@ -XXX,XX +XXX,XX @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, put_unaligned_be64(opts->rcvr_key, ptr); ptr += 2; + if (OPTION_MPTCP_RST & opts->suboptions) + goto mp_rst; + return; + } else if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) { +mp_fail: + /* MP_FAIL is mutually exclusive with others except RST */ + subflow = mptcp_subflow_ctx(ssk); + subflow->send_mp_fail = 0; + + *ptr++ = mptcp_option(MPTCPOPT_MP_FAIL, + TCPOLEN_MPTCP_FAIL, + 0, 0); + put_unaligned_be64(opts->fail_seq, ptr); + ptr += 2; + if (OPTION_MPTCP_RST & opts->suboptions) goto mp_rst; return; -- 2.31.1
From: Matthieu Baerts <matthieu.baerts@tessares.net> RFC8684 doesn't seem to clearly specify which MPTCP options can be used together. Some options are mutually exclusive -- e.g. MP_CAPABLE and MP_JOIN --, some can be used together -- e.g. DSS + MP_PRIO --, some can but we prefer not to -- e.g. DSS + ADD_ADDR -- and some have to be used together at some points -- e.g. MP_FAIL and DSS. We need to clarify this as a base before allowing other modifications. For example, does it make sense to send a RM_ADDR with an MPC or MPJ? This remains open for possible future discussions. Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> --- v9: - Change 'ADD+RM' from 'C' to 'P'. --- net/mptcp/options.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -XXX,XX +XXX,XX @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, const struct sock *ssk = (const struct sock *)tp; struct mptcp_subflow_context *subflow; - /* DSS, MPC, MPJ, ADD_ADDR, FASTCLOSE and RST are mutually exclusive, - * see mptcp_established_options*() + /* Which options can be used together? + * + * X: mutually exclusive + * O: often used together + * C: can be used together in some cases + * P: could be used together but we prefer not to (optimisations) + * + * Opt: | MPC | MPJ | DSS | ADD | RM | PRIO | FAIL | FC | + * ------|------|------|------|------|------|------|------|------| + * MPC |------|------|------|------|------|------|------|------| + * MPJ | X |------|------|------|------|------|------|------| + * DSS | X | X |------|------|------|------|------|------| + * ADD | X | X | P |------|------|------|------|------| + * RM | C | C | C | P |------|------|------|------| + * PRIO | X | C | C | C | C |------|------|------| + * FAIL | X | X | C | X | X | X |------|------| + * FC | X | X | X | X | X | X | X |------| + * RST | X | X | X | X | X | X | O | O | + * ------|------|------|------|------|------|------|------|------| + * + * The same applies in mptcp_established_options() function. */ if (likely(OPTION_MPTCP_DSS & opts->suboptions)) { struct mptcp_ext *mpext = &opts->ext_copy; -- 2.31.1
This patch printed out the reset infos, reset_transient and reset_reason, of MP_RST in mptcp_parse_option() to show that MP_RST is received. Signed-off-by: Geliang Tang <geliang.tang@suse.com> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> --- net/mptcp/options.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -XXX,XX +XXX,XX @@ static void mptcp_parse_option(const struct sk_buff *skb, flags = *ptr++; mp_opt->reset_transient = flags & MPTCP_RST_TRANSIENT; mp_opt->reset_reason = *ptr; + pr_debug("MP_RST: transient=%u reason=%u", + mp_opt->reset_transient, mp_opt->reset_reason); break; case MPTCPOPT_MP_FAIL: -- 2.31.1
Added the test cases for MP_FAIL, use 'tc' command to trigger the checksum failure. Suggested-by: Davide Caratti <dcaratti@redhat.com> Co-developed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- tools/testing/selftests/net/mptcp/config | 5 + .../testing/selftests/net/mptcp/mptcp_join.sh | 111 ++++++++++++++++-- 2 files changed, 107 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/config b/tools/testing/selftests/net/mptcp/config index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/net/mptcp/config +++ b/tools/testing/selftests/net/mptcp/config @@ -XXX,XX +XXX,XX @@ CONFIG_IP_ADVANCED_ROUTER=y CONFIG_IP_MULTIPLE_TABLES=y CONFIG_IP_NF_TARGET_REJECT=m CONFIG_IPV6_MULTIPLE_TABLES=y +CONFIG_NET_ACT_CSUM=m +CONFIG_NET_ACT_PEDIT=m +CONFIG_NET_CLS_ACT=y +CONFIG_NET_CLS_FLOWER=m +CONFIG_NET_SCH_INGRESS=m diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index XXXXXXX..XXXXXXX 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -XXX,XX +XXX,XX @@ mptcp_connect="" capture=0 checksum=0 do_all_tests=1 +nr_fail=0 TEST_COUNT=0 @@ -XXX,XX +XXX,XX @@ init() fi done + validate_checksum=$checksum + # ns1 ns2 # ns1eth1 ns2eth1 # ns1eth2 ns2eth2 @@ -XXX,XX +XXX,XX @@ reset_with_allow_join_id0() ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable } +# Modify TCP payload without corrupting the TCP packet +# +# This rule inverts a 32-bit word at byte offset 148 for all TCP ACK +# packets carrying enough data. +# Once it is done, the TCP Checksum field is updated so the packet +# is still considered as valid at the TCP level. +# But because the MPTCP checksum, covering the TCP options and data, +# has not been updated, we will detect the modification and emit an +# MP_FAIL: what we want to validate here. +# +# Please note that this rule will produce this pr_info() message for +# each TCP ACK packets not carrying enough data: +# +# tc action pedit offset 162 out of bounds +# +# But this should be limited to a very few numbers of packets as we +# restrict this rule to outgoing TCP traffic with only the ACK flag +# + except the 3rd ACK, only packets carrying data should be seen in +# this direction. +reset_with_fail() +{ + reset + + ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1 + ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=1 + + validate_checksum=1 + nr_fail=0 + i="$1" + + tc -n $ns2 qdisc add dev ns2eth$i clsact + tc -n $ns2 filter add dev ns2eth$i egress \ + protocol ip prio 1000 \ + flower ip_proto tcp tcp_flags 0x10/0xff \ + action pedit munge offset 148 u32 invert \ + pipe csum tcp \ + index 100 +} + ip -Version > /dev/null 2>&1 if [ $? -ne 0 ];then echo "SKIP: Could not run test without ip tool" @@ -XXX,XX +XXX,XX @@ if [ $? -ne 0 ];then exit $ksft_skip fi +jq -V > /dev/null 2>&1 +if [ $? -ne 0 ];then + echo "SKIP: Could not run all tests without jq tool" + exit $ksft_skip +fi + print_file_err() { ls -l "$1" 1>&2 @@ -XXX,XX +XXX,XX @@ link_failure() done } +get_nr_fail() +{ + i="$1" + + local action=$(tc -n $ns2 -j -s action show action pedit index 100) + local packets=$(echo $action | jq '.[1].actions[0].stats.packets') + local overlimits=$(echo $action | jq '.[1].actions[0].stats.overlimits') + + let pkt=$packets-$overlimits + if [ $pkt -gt 0 ]; then + nr_fail=1 + fi + tc -n $ns2 qdisc del dev ns2eth$i clsact +} + # $1: IP address is_v6() { @@ -XXX,XX +XXX,XX @@ dump_stats() chk_csum_nr() { local msg=${1:-""} + local csum_ns1=${2:-0} + local csum_ns2=${3:-0} local count local dump_stats @@ -XXX,XX +XXX,XX @@ chk_csum_nr() printf " %-36s %s" "$msg" "sum" count=`ip netns exec $ns1 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` [ -z "$count" ] && count=0 - if [ "$count" != 0 ]; then - echo "[fail] got $count data checksum error[s] expected 0" + if [ "$count" != $csum_ns1 ]; then + echo "[fail] got $count data checksum error[s] expected $csum_ns1" ret=1 dump_stats=1 else @@ -XXX,XX +XXX,XX @@ chk_csum_nr() echo -n " - csum " count=`ip netns exec $ns2 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}'` [ -z "$count" ] && count=0 - if [ "$count" != 0 ]; then - echo "[fail] got $count data checksum error[s] expected 0" + if [ "$count" != $csum_ns2 ]; then + echo "[fail] got $count data checksum error[s] expected $csum_ns2" ret=1 dump_stats=1 else @@ -XXX,XX +XXX,XX @@ chk_join_nr() local syn_nr=$2 local syn_ack_nr=$3 local ack_nr=$4 + local fail_nr=${5:-0} + local infi_nr=${6:-0} local count local dump_stats @@ -XXX,XX +XXX,XX @@ chk_join_nr() echo "[ ok ]" fi [ "${dump_stats}" = 1 ] && dump_stats - if [ $checksum -eq 1 ]; then - chk_csum_nr - chk_fail_nr 0 0 - chk_infi_nr 0 0 + if [ $validate_checksum -eq 1 ]; then + chk_csum_nr "" $fail_nr + chk_fail_nr $fail_nr $fail_nr + chk_infi_nr $infi_nr $infi_nr fi } @@ -XXX,XX +XXX,XX @@ userspace_tests() chk_rm_nr 0 0 } +fail_tests() +{ + # multiple subflows + reset_with_fail 2 + 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.3.2 dev ns2eth3 flags subflow + ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 dev ns2eth2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 2 + get_nr_fail 2 + chk_join_nr "$nr_fail MP_FAIL, multiple subflows" 2 2 2 $nr_fail + + # single subflow + reset_with_fail 1 + ip netns exec $ns1 ./pm_nl_ctl limits 0 2 + ip netns exec $ns2 ./pm_nl_ctl limits 0 2 + run_tests $ns1 $ns2 10.0.1.1 2 + get_nr_fail 1 + chk_join_nr "$nr_fail MP_FAIL, single subflow" 0 0 0 $nr_fail $nr_fail +} + all_tests() { subflows_tests @@ -XXX,XX +XXX,XX @@ all_tests() deny_join_id0_tests fullmesh_tests userspace_tests + fail_tests } usage() @@ -XXX,XX +XXX,XX @@ usage() echo " -d deny_join_id0_tests" echo " -m fullmesh_tests" echo " -u userspace_tests" + echo " -F fail_tests" echo " -c capture pcap files" echo " -C enable data checksum" echo " -h help" @@ -XXX,XX +XXX,XX @@ if [ $do_all_tests -eq 1 ]; then exit $ret fi -while getopts 'fesltra64bpkdmuchCS' opt; do +while getopts 'fesltra64bpkdmuchCSF' opt; do case $opt in f) subflows_tests @@ -XXX,XX +XXX,XX @@ while getopts 'fesltra64bpkdmuchCS' opt; do u) userspace_tests ;; + F) + fail_tests + ;; c) ;; C) -- 2.31.1