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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZbtabpEr7I6Gy5vE@Laptop-X1>
Date: Thu, 1 Feb 2024 16:46:38 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: thinker.li@...il.com
Cc: netdev@...r.kernel.org, ast@...nel.org, martin.lau@...ux.dev,
	kernel-team@...a.com, davem@...emloft.net, dsahern@...nel.org,
	edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
	sinquersw@...il.com, kuifeng@...a.com
Subject: Re: [PATCH net-next 5/5] selftests/net: Adding test cases of
 replacing routes and route advertisements.

Hi,

On Tue, Jan 30, 2024 at 10:40:41PM -0800, thinker.li@...il.com wrote:
> +# Create a new dummy_10 to remove all associated routes.
> +reset_dummy_10()
> +{
> +	$IP link del dev dummy_10
> +
> +	$IP link add dummy_10 type dummy
> +	$IP link set dev dummy_10 up
> +	$IP -6 address add 2001:10::1/64 dev dummy_10
> +}
> +
>  fib6_gc_test()
>  {
>  	setup
> @@ -768,15 +778,19 @@ fib6_gc_test()
>  	    $IP -6 route add 2001:20::$i \
>  		via 2001:10::2 dev dummy_10 expires $EXPIRE
>  	done
> -	sleep $(($EXPIRE * 2))
> -	N_EXP_SLEEP=$($IP -6 route list |grep expires|wc -l)
> -	if [ $N_EXP_SLEEP -ne 0 ]; then
> -	    echo "FAIL: expected 0 routes with expires, got $N_EXP_SLEEP"
> +	sleep $(($EXPIRE * 2 + 1))
> +	N_EXP=$($IP -6 route list |grep expires|wc -l)
> +	if [ $N_EXP -ne 0 ]; then
> +	    echo "FAIL: expected 0 routes with expires, got $N_EXP"
>  	    ret=1
>  	else
>  	    ret=0
>  	fi
>  
> +	log_test $ret 0 "ipv6 route garbage collection"
> +
> +	reset_dummy_10

Since you reset the dummy device and will not affect the later tests. Maybe
you can log the test directly, e.g.

	if [ "$($IP -6 route list |grep expires|wc -l)" -ne 0 ]; then
		log_test $ret 0 "ipv6 route garbage collection"
	fi

Or, if you want to keep ret and also report passed log, you can wrapper the
number checking like

check_exp_number()
{
	local exp=$1
	local n_exp=$($IP -6 route list |grep expires|wc -l)
	if [ "$n_exp" -ne "$exp" ]; then
		echo "FAIL: expected $exp routes with expires, got $n_exp"
		ret=1
	else
		ret=0
	fi
}

Then we can call it without repeating the if/else lines

	check_exp_number 0
	log_test $ret 0 "ipv6 route garbage collection"

Thanks
Hangbin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ