lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 13 Apr 2024 15:29:08 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: Benjamin Poirier <benjamin.poirier@...il.com>
Cc: netdev@...r.kernel.org, kuba@...nel.org, pabeni@...hat.com,
	davem@...emloft.net, edumazet@...gle.com, parav@...dia.com,
	mst@...hat.com, jasowang@...hat.com, xuanzhuo@...ux.alibaba.com,
	shuah@...nel.org, petrm@...dia.com, liuhangbin@...il.com,
	vladimir.oltean@....com, idosch@...dia.com,
	virtualization@...ts.linux.dev
Subject: Re: [patch net-next 5/6] selftests: forwarding: add wait_for_dev()
 helper

Fri, Apr 12, 2024 at 10:43:40PM CEST, benjamin.poirier@...il.com wrote:
>On 2024-04-12 17:13 +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@...dia.com>
>> 
>> The existing setup_wait*() helper family check the status of the
>> interface to be up. Introduce wait_for_dev() to wait for the netdevice
>> to appear, for example after test script does manual device bind.
>> 
>> Signed-off-by: Jiri Pirko <jiri@...dia.com>
>> ---
>>  tools/testing/selftests/net/forwarding/lib.sh | 19 +++++++++++++++++++
>>  1 file changed, 19 insertions(+)
>> 
>> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
>> index 959183b516ce..74859f969997 100644
>> --- a/tools/testing/selftests/net/forwarding/lib.sh
>> +++ b/tools/testing/selftests/net/forwarding/lib.sh
>> @@ -746,6 +746,25 @@ setup_wait()
>>  	sleep $WAIT_TIME
>>  }
>>  
>> +wait_for_dev()
>> +{
>> +	local dev=$1; shift
>> +	local timeout=${1:-$WAIT_TIMEOUT}; shift
>> +	local max_iterations=$(($timeout * 10))
>> +
>> +	for ((i = 1; i <= $max_iterations; ++i)); do
>> +		ip link show dev $dev up &> /dev/null
>> +		if [[ $? -ne 0 ]]; then
>> +			sleep 0.1
>> +		else
>> +			return 0
>> +		fi
>> +	done
>> +
>> +	log_test wait_for_dev ": Interface $dev did not appear."
>> +	exit 1
>> +}
>
>How about rewriting the function to make use of the `slowwait` helper as
>follows:
>
>wait_for_dev()
>{
>	local dev=$1; shift
>	local timeout=${1:-$WAIT_TIMEOUT}; shift
>
>	slowwait $timeout ip link show dev $dev up &> /dev/null
>	if (( $? )); then
>		check_err 1
>		log_test wait_for_dev "Interface $dev did not appear."
>		exit $EXIT_STATUS
>	fi
>}

Sure, will redo this. Thanks!


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ