diff mbox series

[1/2] eal: fix shared lib mode detection

Message ID 1bbaefeb069a75f57a2f49b4217efa994bed5d4b.1606229937.git.tredaelli@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series Fix shared lib detection on Fedora/CentOS/RHEL | expand

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Timothy Redaelli Nov. 24, 2020, 3:14 p.m. UTC
Commit 06c7871dde01 ("eal: restrict default plugin path to shared lib mode")
introduced a check that enabled shared lib mode when librte_eal.so can
be loaded, but it can't work, at least, on Fedora/CentOS/RHEL since .so
symlinks are not installed when you install dpdk package, but only when
you install dpdk-devel package.

This commit uses librte_eal.so.ABI_VERSION to check for shared lib,
since it exists on any linux distributions.

See Fedora Packaging Guidelines for more informations:
https://docs.fedoraproject.org/en-US/packaging-guidelines/#_devel_packages

Fixes: 06c7871dde01 ("eal: restrict default plugin path to shared lib mode")
Cc: bruce.richardson@intel.com
Cc: stable@dpdk.org
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 lib/librte_eal/common/eal_common_options.c | 3 ++-
 lib/librte_eal/common/meson.build          | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Bruce Richardson Nov. 24, 2020, 3:22 p.m. UTC | #1
On Tue, Nov 24, 2020 at 04:14:14PM +0100, Timothy Redaelli wrote:
> Commit 06c7871dde01 ("eal: restrict default plugin path to shared lib mode")
> introduced a check that enabled shared lib mode when librte_eal.so can
> be loaded, but it can't work, at least, on Fedora/CentOS/RHEL since .so
> symlinks are not installed when you install dpdk package, but only when
> you install dpdk-devel package.
> 
> This commit uses librte_eal.so.ABI_VERSION to check for shared lib,
> since it exists on any linux distributions.
> 
> See Fedora Packaging Guidelines for more informations:
> https://docs.fedoraproject.org/en-US/packaging-guidelines/#_devel_packages
> 
> Fixes: 06c7871dde01 ("eal: restrict default plugin path to shared lib mode")
> Cc: bruce.richardson@intel.com
> Cc: stable@dpdk.org
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> ---
>  lib/librte_eal/common/eal_common_options.c | 3 ++-
>  lib/librte_eal/common/meson.build          | 2 ++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
> index fc6f0cea93..e6f77ad217 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -503,7 +503,8 @@ eal_plugins_init(void)
>  	 * (Using dlopen with NOLOAD flag on EAL, will return NULL if the EAL
>  	 * shared library is not already loaded i.e. it's statically linked.)
>  	 */
> -	if (dlopen("librte_eal.so", RTLD_LAZY | RTLD_NOLOAD) != NULL &&
> +	if (dlopen("librte_eal.so."ABI_VERSION, RTLD_LAZY | RTLD_NOLOAD)
> +			!= NULL &&

Since we are not so strict on the 80-char lines, I think I'd keep the
!= NULL on the original line to improve readability.

>  			*default_solib_dir != '\0' &&
>  			stat(default_solib_dir, &sb) == 0 &&
>  			S_ISDIR(sb.st_mode))
> diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build
> index 9f32262450..39abf7a0a4 100644
> --- a/lib/librte_eal/common/meson.build
> +++ b/lib/librte_eal/common/meson.build
> @@ -3,6 +3,8 @@
>  
>  includes += include_directories('.')
>  
> +cflags += [ '-DABI_VERSION="@0@"'.format(abi_version) ]
> +
>  if is_windows
>  	sources += files(
>  		'eal_common_bus.c',
> -- 

Acked-by: Bruce Richardson <bruce.richardson@intel.com>
David Marchand Nov. 25, 2020, 9:10 a.m. UTC | #2
On Tue, Nov 24, 2020 at 4:15 PM Timothy Redaelli <tredaelli@redhat.com> wrote:
>
> Commit 06c7871dde01 ("eal: restrict default plugin path to shared lib mode")
> introduced a check that enabled shared lib mode when librte_eal.so can
> be loaded, but it can't work, at least, on Fedora/CentOS/RHEL since .so
> symlinks are not installed when you install dpdk package, but only when
> you install dpdk-devel package.
>
> This commit uses librte_eal.so.ABI_VERSION to check for shared lib,
> since it exists on any linux distributions.
>
> See Fedora Packaging Guidelines for more informations:
> https://docs.fedoraproject.org/en-US/packaging-guidelines/#_devel_packages
>
> Fixes: 06c7871dde01 ("eal: restrict default plugin path to shared lib mode")
> Cc: bruce.richardson@intel.com
> Cc: stable@dpdk.org
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>

Same comment as Bruce on the != NULL location, but otherwise lgtm.
Acked-by: David Marchand <david.marchand@redhat.com>
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index fc6f0cea93..e6f77ad217 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -503,7 +503,8 @@  eal_plugins_init(void)
 	 * (Using dlopen with NOLOAD flag on EAL, will return NULL if the EAL
 	 * shared library is not already loaded i.e. it's statically linked.)
 	 */
-	if (dlopen("librte_eal.so", RTLD_LAZY | RTLD_NOLOAD) != NULL &&
+	if (dlopen("librte_eal.so."ABI_VERSION, RTLD_LAZY | RTLD_NOLOAD)
+			!= NULL &&
 			*default_solib_dir != '\0' &&
 			stat(default_solib_dir, &sb) == 0 &&
 			S_ISDIR(sb.st_mode))
diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build
index 9f32262450..39abf7a0a4 100644
--- a/lib/librte_eal/common/meson.build
+++ b/lib/librte_eal/common/meson.build
@@ -3,6 +3,8 @@ 
 
 includes += include_directories('.')
 
+cflags += [ '-DABI_VERSION="@0@"'.format(abi_version) ]
+
 if is_windows
 	sources += files(
 		'eal_common_bus.c',