[PATCH mptcp-next v3 12/12] selftests: mptcp: join: helper to filter TCP

Matthieu Baerts posted 12 patches 3 years, 11 months ago
Maintainers: "David S. Miller" <davem@davemloft.net>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Shuah Khan <shuah@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Matthieu Baerts <matthieu.baerts@tessares.net>
There is a newer version of this series
[PATCH mptcp-next v3 12/12] selftests: mptcp: join: helper to filter TCP
Posted by Matthieu Baerts 3 years, 11 months ago
This is more readable and reduces duplicated commands.

This might also be useful to add v6 support and switch to nftables.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 20ec31b05990..977e5eb28ba4 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -624,6 +624,15 @@ pm_nl_check_endpoint()
 	fi
 }
 
+filter_tcp_from()
+{
+	local ns="${1}"
+	local src="${2}"
+	local target="${3}"
+
+	ip netns exec "${ns}" iptables -A INPUT -s "${src}" -p tcp -j "${target}"
+}
+
 do_transfer()
 {
 	local listener_ns="$1"
@@ -1653,7 +1662,7 @@ subflows_error_tests()
 		pm_nl_set_limits $ns2 0 2
 		pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
 		pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
-		ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT
+		filter_tcp_from $ns1 10.0.3.2 REJECT
 		run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
 		chk_join_nr 1 1 1
 	fi
@@ -1664,7 +1673,7 @@ subflows_error_tests()
 		pm_nl_set_limits $ns2 0 2
 		pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
 		pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
-		ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j DROP
+		filter_tcp_from $ns1 10.0.3.2 DROP
 		run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
 		chk_join_nr 1 1 1
 	fi
@@ -1676,7 +1685,7 @@ subflows_error_tests()
 		pm_nl_set_limits $ns1 0 1
 		pm_nl_set_limits $ns2 0 1
 		pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
-		ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT
+		filter_tcp_from $ns1 10.0.3.2 REJECT
 		run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow &
 
 		# mpj subflow will be in TW after the reset
-- 
2.34.1


Re: [PATCH mptcp-next v3 12/12] selftests: mptcp: join: helper to filter TCP
Posted by Geliang Tang 3 years, 11 months ago
Hi Matt,

Matthieu Baerts <matthieu.baerts@tessares.net> 于2022年2月24日周四 21:57写道:
>
> This is more readable and reduces duplicated commands.
>
> This might also be useful to add v6 support and switch to nftables.
>
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> ---
>  tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 20ec31b05990..977e5eb28ba4 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -624,6 +624,15 @@ pm_nl_check_endpoint()
>         fi
>  }
>
> +filter_tcp_from()
> +{
> +       local ns="${1}"
> +       local src="${2}"
> +       local target="${3}"
> +
> +       ip netns exec "${ns}" iptables -A INPUT -s "${src}" -p tcp -j "${target}"

How about being compatible with ip6tables too, like in
reset_with_add_addr_timeout().

> +}
> +
>  do_transfer()
>  {
>         local listener_ns="$1"
> @@ -1653,7 +1662,7 @@ subflows_error_tests()
>                 pm_nl_set_limits $ns2 0 2
>                 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
>                 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
> -               ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT
> +               filter_tcp_from $ns1 10.0.3.2 REJECT
>                 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
>                 chk_join_nr 1 1 1
>         fi
> @@ -1664,7 +1673,7 @@ subflows_error_tests()
>                 pm_nl_set_limits $ns2 0 2
>                 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
>                 pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
> -               ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j DROP
> +               filter_tcp_from $ns1 10.0.3.2 DROP
>                 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
>                 chk_join_nr 1 1 1
>         fi
> @@ -1676,7 +1685,7 @@ subflows_error_tests()
>                 pm_nl_set_limits $ns1 0 1
>                 pm_nl_set_limits $ns2 0 1
>                 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
> -               ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT
> +               filter_tcp_from $ns1 10.0.3.2 REJECT
>                 run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow &
>
>                 # mpj subflow will be in TW after the reset
> --
> 2.34.1
>
>

Re: [PATCH mptcp-next v3 12/12] selftests: mptcp: join: helper to filter TCP
Posted by Matthieu Baerts 3 years, 11 months ago
Hi Geliang,

On 24/02/2022 15:39, Geliang Tang wrote:
> Hi Matt,
> 
> Matthieu Baerts <matthieu.baerts@tessares.net> 于2022年2月24日周四 21:57写道:
>>
>> This is more readable and reduces duplicated commands.
>>
>> This might also be useful to add v6 support and switch to nftables.
>>
>> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
>> ---
>>  tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 ++++++++++++---
>>  1 file changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> index 20ec31b05990..977e5eb28ba4 100755
>> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> @@ -624,6 +624,15 @@ pm_nl_check_endpoint()
>>         fi
>>  }
>>
>> +filter_tcp_from()
>> +{
>> +       local ns="${1}"
>> +       local src="${2}"
>> +       local target="${3}"
>> +
>> +       ip netns exec "${ns}" iptables -A INPUT -s "${src}" -p tcp -j "${target}"
> 
> How about being compatible with ip6tables too, like in
> reset_with_add_addr_timeout().

I started to add it but because there were no need for the moment, I
only added a comment in the commit message. It can easily be added in
one place later.
Or do you think it should be done now?

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

Re: selftests: mptcp: join: helper to filter TCP: Tests Results
Posted by MPTCP CI 3 years, 11 months ago
Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal:
  - Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
  - Task: https://cirrus-ci.com/task/5434161388322816
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5434161388322816/summary/summary.txt

- KVM Validation: debug:
  - Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
  - Task: https://cirrus-ci.com/task/6560061295165440
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/6560061295165440/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/c4be22d32c97

Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)