[PATCH mptcp-next v7 2/8] selftests: mptcp: connect: add dedicated port counter

Geliang Tang posted 8 patches 9 months, 1 week ago
There is a newer version of this series
[PATCH mptcp-next v7 2/8] selftests: mptcp: connect: add dedicated port counter
Posted by Geliang Tang 9 months, 1 week ago
From: Geliang Tang <tanggeliang@kylinos.cn>

This patch adds a new dedicated counter 'PORT' instead of TEST_COUNT to
increase port numbers in mptcp_connect.sh.

This can avoid outputting discontinuous test counters.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index 0ca2960c9099..4f40221a86cb 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -33,6 +33,7 @@ do_tcp=0
 checksum=false
 filesize=0
 connect_per_transfer=1
+PORT=0
 
 if [ $tc_loss -eq 100 ];then
 	tc_loss=1%
@@ -314,7 +315,7 @@ do_transfer()
 	local extra_args="$7"
 
 	local port
-	port=$((10000+TEST_COUNT))
+	port=$((10000+PORT++))
 	TEST_COUNT=$((TEST_COUNT+1))
 
 	if [ "$rcvbuf" -gt 0 ]; then
@@ -710,7 +711,7 @@ EOF
 
 	echo "INFO: test $msg"
 
-	TEST_COUNT=10000
+	PORT=10000
 	local extra_args="-o TRANSPARENT"
 	do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \
 		    ${connect_addr} ${local_addr} "${extra_args}"
-- 
2.40.1
Re: [PATCH mptcp-next v7 2/8] selftests: mptcp: connect: add dedicated port counter
Posted by Matthieu Baerts 9 months, 1 week ago
Hi Geliang,

On 29/02/2024 10:51, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> This patch adds a new dedicated counter 'PORT' instead of TEST_COUNT to
> increase port numbers in mptcp_connect.sh.
> 
> This can avoid outputting discontinuous test counters.
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  tools/testing/selftests/net/mptcp/mptcp_connect.sh | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> index 0ca2960c9099..4f40221a86cb 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> @@ -33,6 +33,7 @@ do_tcp=0
>  checksum=false
>  filesize=0
>  connect_per_transfer=1
> +PORT=0

Sorry, I forgot to comment on the previous patch: I didn't get why you
cannot use TEST_COUNT for the increment?

So have here:

  PORT=10000

(Or 'PORT_BASE', or even 'port_base' like most "global" variables used
in this file)

>  if [ $tc_loss -eq 100 ];then
>  	tc_loss=1%
> @@ -314,7 +315,7 @@ do_transfer()
>  	local extra_args="$7"
>  
>  	local port
> -	port=$((10000+TEST_COUNT))
> +	port=$((10000+PORT++))

Here:

  port=$((PORT + TEST_COUNT))

>  	TEST_COUNT=$((TEST_COUNT+1))
>  
>  	if [ "$rcvbuf" -gt 0 ]; then
> @@ -710,7 +711,7 @@ EOF
>  
>  	echo "INFO: test $msg"
>  
> -	TEST_COUNT=10000
> +	PORT=10000

And here:

  PORT=20000

So there is only one counter, not 2. Would that not work?

>  	local extra_args="-o TRANSPARENT"
>  	do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \
>  		    ${connect_addr} ${local_addr} "${extra_args}"

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH mptcp-next v7 2/8] selftests: mptcp: connect: add dedicated port counter
Posted by Geliang Tang 9 months, 1 week ago
Hi Matt,

On Thu, Feb 29, 2024 at 12:23:54PM +0100, Matthieu Baerts wrote:
> Hi Geliang,
> 
> On 29/02/2024 10:51, Geliang Tang wrote:
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> > 
> > This patch adds a new dedicated counter 'PORT' instead of TEST_COUNT to
> > increase port numbers in mptcp_connect.sh.
> > 
> > This can avoid outputting discontinuous test counters.
> > 
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > ---
> >  tools/testing/selftests/net/mptcp/mptcp_connect.sh | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> > index 0ca2960c9099..4f40221a86cb 100755
> > --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> > +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> > @@ -33,6 +33,7 @@ do_tcp=0
> >  checksum=false
> >  filesize=0
> >  connect_per_transfer=1
> > +PORT=0
> 
> Sorry, I forgot to comment on the previous patch: I didn't get why you
> cannot use TEST_COUNT for the increment?
> 
> So have here:
> 
>   PORT=10000
> 
> (Or 'PORT_BASE', or even 'port_base' like most "global" variables used
> in this file)
> 
> >  if [ $tc_loss -eq 100 ];then
> >  	tc_loss=1%
> > @@ -314,7 +315,7 @@ do_transfer()
> >  	local extra_args="$7"
> >  
> >  	local port
> > -	port=$((10000+TEST_COUNT))
> > +	port=$((10000+PORT++))
> 
> Here:
> 
>   port=$((PORT + TEST_COUNT))

The first time here TEST_COUNT is 2, so all ports begin with 10002, not
10000. The values of port are changed.

Thanks,
-Geliang

> 
> >  	TEST_COUNT=$((TEST_COUNT+1))
> >  
> >  	if [ "$rcvbuf" -gt 0 ]; then
> > @@ -710,7 +711,7 @@ EOF
> >  
> >  	echo "INFO: test $msg"
> >  
> > -	TEST_COUNT=10000
> > +	PORT=10000
> 
> And here:
> 
>   PORT=20000
> 
> So there is only one counter, not 2. Would that not work?
> 
> >  	local extra_args="-o TRANSPARENT"
> >  	do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \
> >  		    ${connect_addr} ${local_addr} "${extra_args}"
> 
> Cheers,
> Matt
> -- 
> Sponsored by the NGI0 Core fund.
Re: [PATCH mptcp-next v7 2/8] selftests: mptcp: connect: add dedicated port counter
Posted by Matthieu Baerts 9 months, 1 week ago
On 29/02/2024 13:18, Geliang Tang wrote:
> Hi Matt,
> 
> On Thu, Feb 29, 2024 at 12:23:54PM +0100, Matthieu Baerts wrote:
>> Hi Geliang,
>>
>> On 29/02/2024 10:51, Geliang Tang wrote:
>>> From: Geliang Tang <tanggeliang@kylinos.cn>
>>>
>>> This patch adds a new dedicated counter 'PORT' instead of TEST_COUNT to
>>> increase port numbers in mptcp_connect.sh.
>>>
>>> This can avoid outputting discontinuous test counters.
>>>
>>> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
>>> ---
>>>  tools/testing/selftests/net/mptcp/mptcp_connect.sh | 5 +++--
>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
>>> index 0ca2960c9099..4f40221a86cb 100755
>>> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
>>> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
>>> @@ -33,6 +33,7 @@ do_tcp=0
>>>  checksum=false
>>>  filesize=0
>>>  connect_per_transfer=1
>>> +PORT=0
>>
>> Sorry, I forgot to comment on the previous patch: I didn't get why you
>> cannot use TEST_COUNT for the increment?
>>
>> So have here:
>>
>>   PORT=10000
>>
>> (Or 'PORT_BASE', or even 'port_base' like most "global" variables used
>> in this file)
>>
>>>  if [ $tc_loss -eq 100 ];then
>>>  	tc_loss=1%
>>> @@ -314,7 +315,7 @@ do_transfer()
>>>  	local extra_args="$7"
>>>  
>>>  	local port
>>> -	port=$((10000+TEST_COUNT))
>>> +	port=$((10000+PORT++))
>>
>> Here:
>>
>>   port=$((PORT + TEST_COUNT))
> 
> The first time here TEST_COUNT is 2, so all ports begin with 10002, not
> 10000. The values of port are changed.

This then?

   port=$((port_base + TEST_COUNT - 2))

Or port_base=9998, but it looks strange.

> 
> Thanks,
> -Geliang
> 
>>
>>>  	TEST_COUNT=$((TEST_COUNT+1))
>>>  
>>>  	if [ "$rcvbuf" -gt 0 ]; then
>>> @@ -710,7 +711,7 @@ EOF
>>>  
>>>  	echo "INFO: test $msg"
>>>  
>>> -	TEST_COUNT=10000
>>> +	PORT=10000
>>
>> And here:
>>
>>   PORT=20000

Here you can also do something like this:

  port_base=$((port_base + 10000 - TEST_COUNT))

Up to you.

>>
>> So there is only one counter, not 2. Would that not work?
>>
>>>  	local extra_args="-o TRANSPARENT"
>>>  	do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \
>>>  		    ${connect_addr} ${local_addr} "${extra_args}"
>>
>> Cheers,
>> Matt
>> -- 
>> Sponsored by the NGI0 Core fund.

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH mptcp-next v7 2/8] selftests: mptcp: connect: add dedicated port counter
Posted by Geliang Tang 9 months, 1 week ago
On Thu, 2024-02-29 at 13:22 +0100, Matthieu Baerts wrote:
> On 29/02/2024 13:18, Geliang Tang wrote:
> > Hi Matt,
> > 
> > On Thu, Feb 29, 2024 at 12:23:54PM +0100, Matthieu Baerts wrote:
> > > Hi Geliang,
> > > 
> > > On 29/02/2024 10:51, Geliang Tang wrote:
> > > > From: Geliang Tang <tanggeliang@kylinos.cn>
> > > > 
> > > > This patch adds a new dedicated counter 'PORT' instead of
> > > > TEST_COUNT to
> > > > increase port numbers in mptcp_connect.sh.
> > > > 
> > > > This can avoid outputting discontinuous test counters.
> > > > 
> > > > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > > > ---
> > > >  tools/testing/selftests/net/mptcp/mptcp_connect.sh | 5 +++--
> > > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> > > > b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> > > > index 0ca2960c9099..4f40221a86cb 100755
> > > > --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> > > > +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> > > > @@ -33,6 +33,7 @@ do_tcp=0
> > > >  checksum=false
> > > >  filesize=0
> > > >  connect_per_transfer=1
> > > > +PORT=0
> > > 
> > > Sorry, I forgot to comment on the previous patch: I didn't get
> > > why you
> > > cannot use TEST_COUNT for the increment?
> > > 
> > > So have here:
> > > 
> > >   PORT=10000
> > > 
> > > (Or 'PORT_BASE', or even 'port_base' like most "global" variables
> > > used
> > > in this file)
> > > 
> > > >  if [ $tc_loss -eq 100 ];then
> > > >  	tc_loss=1%
> > > > @@ -314,7 +315,7 @@ do_transfer()
> > > >  	local extra_args="$7"
> > > >  
> > > >  	local port
> > > > -	port=$((10000+TEST_COUNT))
> > > > +	port=$((10000+PORT++))
> > > 
> > > Here:
> > > 
> > >   port=$((PORT + TEST_COUNT))
> > 
> > The first time here TEST_COUNT is 2, so all ports begin with 10002,
> > not
> > 10000. The values of port are changed.
> 
> This then?
> 
>    port=$((port_base + TEST_COUNT - 2))
> 
> Or port_base=9998, but it looks strange.
> 
> > 
> > Thanks,
> > -Geliang
> > 
> > > 
> > > >  	TEST_COUNT=$((TEST_COUNT+1))
> > > >  
> > > >  	if [ "$rcvbuf" -gt 0 ]; then
> > > > @@ -710,7 +711,7 @@ EOF
> > > >  
> > > >  	echo "INFO: test $msg"
> > > >  
> > > > -	TEST_COUNT=10000
> > > > +	PORT=10000
> > > 
> > > And here:
> > > 
> > >   PORT=20000
> 
> Here you can also do something like this:
> 
>   port_base=$((port_base + 10000 - TEST_COUNT))
> 
> Up to you.

Thanks Matt, this works I guess. But becoming more complex. I prefer
the old one.

-Geliang

> 
> > > 
> > > So there is only one counter, not 2. Would that not work?
> > > 
> > > >  	local extra_args="-o TRANSPARENT"
> > > >  	do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP
> > > > \
> > > >  		    ${connect_addr} ${local_addr}
> > > > "${extra_args}"
> > > 
> > > Cheers,
> > > Matt
> > > -- 
> > > Sponsored by the NGI0 Core fund.
> 
> Cheers,
> Matt