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: Mon, 11 Dec 2023 20:44:54 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: Petr Machata <petrm@...dia.com>
Cc: "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	netdev@...r.kernel.org, Shuah Khan <shuah@...nel.org>,
	mlxsw@...dia.com
Subject: Re: [PATCH net-next] selftests: forwarding: Import top-level lib.sh
 through $lib_dir

On Mon, Dec 11, 2023 at 01:01:06PM +0100, Petr Machata wrote:
> The commit cited below moved code from net/forwarding/lib.sh to net/lib.sh,
> and had the former source the latter. This causes issues with selftests
> from directories other than net/forwarding/, in particular drivers/net/...
> For those files, the line "source ../lib.sh" would look for lib.sh in the
> directory above the script file's one, which is incorrect. The way these
> selftests source net/forwarding/lib.sh is like this:
> 
> 	lib_dir=$(dirname $0)/../../../net/forwarding
> 	source $lib_dir/lib.sh
> 
> Reuse the variable lib_dir, if set, in net/forwarding/lib.sh to source
> net/lib.sh as well.
> 
> Fixes: 25ae948b4478 ("selftests/net: add lib.sh")
> Cc: Hangbin Liu <liuhangbin@...il.com>
> Signed-off-by: Petr Machata <petrm@...dia.com>
> ---
>  tools/testing/selftests/net/forwarding/lib.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> index 038b7d956722..0feb4e400110 100755
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -38,7 +38,7 @@ if [[ -f $relative_path/forwarding.config ]]; then
>  	source "$relative_path/forwarding.config"
>  fi
>  
> -source ../lib.sh
> +source ${lib_dir-.}/../lib.sh
>  ##############################################################################
>  # Sanity checks

Hi Petr,

Thanks for the report. However, this doesn't fix the soft link scenario. e.g.
The bonding tests tools/testing/selftests/drivers/net/bonding add a soft link
net_forwarding_lib.sh and source it directly in dev_addr_lists.sh.

So how about something like:

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 8f6ca458af9a..7f90248e05d6 100755
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -38,7 +38,8 @@ if [[ -f $relative_path/forwarding.config ]]; then
        source "$relative_path/forwarding.config"
 fi

-source ../lib.sh
+forwarding_dir=$(dirname $(readlink -f $BASH_SOURCE))
+source ${forwarding_dir}/../lib.sh

Thanks
Hangbin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ