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]
Message-ID: <20240607180127.GG27689@kernel.org>
Date: Fri, 7 Jun 2024 19:01:27 +0100
From: Simon Horman <horms@...nel.org>
To: Abhinav Jain <jain.abhinav177@...il.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
	pabeni@...hat.com, shuah@...nel.org, netdev@...r.kernel.org,
	linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
	skhan@...uxfoundation.org, javier.carrasco.cruz@...il.com
Subject: Re: [PATCH] selftests: net: Add on/off checks for network interface
 non fixed features

On Thu, Jun 06, 2024 at 09:27:14PM +0000, Abhinav Jain wrote:
> This patch addresses the present TODO in the file.
> I have tested it manually on my system and added relevant filtering to
> ensure that the correct feature list is being checked.
> 
> Signed-off-by: Abhinav Jain <jain.abhinav177@...il.com>
> ---
>  tools/testing/selftests/net/netdevice.sh | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/netdevice.sh b/tools/testing/selftests/net/netdevice.sh
> index e3afcb424710..cbe2573c3827 100755
> --- a/tools/testing/selftests/net/netdevice.sh
> +++ b/tools/testing/selftests/net/netdevice.sh
> @@ -117,14 +117,31 @@ kci_netdev_ethtool()
>  		return 1
>  	fi
>  
> -	ethtool -k "$netdev" > "$TMP_ETHTOOL_FEATURES"
> +	ethtool -k "$netdev" | tail -n +2 > "$TMP_ETHTOOL_FEATURES"
>  	if [ $? -ne 0 ];then

Hi Abhinav,

I suspect this will now only report a failure if tail fails,
but ignore ethtool failures.

>  		echo "FAIL: $netdev: ethtool list features"
>  		rm "$TMP_ETHTOOL_FEATURES"
>  		return 1
>  	fi
>  	echo "PASS: $netdev: ethtool list features"
> -	#TODO for each non fixed features, try to turn them on/off
> +
> +	for feature in $(grep -v fixed "$TMP_ETHTOOL_FEATURES" | \
> +		awk '{print $1}' | sed 's/://'); do

Shellcheck warns that the above reads words rather than lines,
and recommends using read instead.

I think that is ok, because the construction reduces lines to single words.
But it does seem a bit awkward to call grep, awk and sed for this.

I wonder if the following construction nicer:

while read -r FEATURE VALUE FIXED; do
	[ "$FEAT" != "Features" ] || continue # Skip "Features" line
	[ "$FIXED" != "[fixed]" ] || continue # Skip fixed features
	feature="${FEATURE%:*}"
	...
done < "$TMP_ETHTOOL_FEATURES"


> +		ethtool --offload "$netdev" "$feature" off
> +		if [ $? -eq 0 ]; then
> +			echo "PASS: $netdev: Turned off feature: $feature"
> +		else
> +			echo "FAIL: $netdev: Failed to turn off feature: $feature"
> +		fi
> +
> +		ethtool --offload "$netdev" "$feature" on
> +		if [ $? -eq 0 ]; then
> +			echo "PASS: $netdev: Turned on feature: $feature"
> +		else
> +			echo "FAIL: $netdev: Failed to turn on feature: $feature"
> +		fi
> +	done
> +
>  	rm "$TMP_ETHTOOL_FEATURES"
>  
>  	kci_netdev_ethtool_test 74 'dump' "ethtool -d $netdev"
> -- 
> 2.34.1
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ