From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8F82AA0523; Tue, 30 Jun 2020 17:39:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DDFF71C0B3; Tue, 30 Jun 2020 17:39:08 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 7D7AA1C07E for ; Tue, 30 Jun 2020 17:39:06 +0200 (CEST) IronPort-SDR: RMK9+ll/S7CfQR18IsZyzOP1BZ7n1mt08QEbY8BlAqCQDbIJOCYVv+BlhwqXsUUPWA7dpaj7Et U+0+Omaz0rsw== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="144445603" X-IronPort-AV: E=Sophos;i="5.75,297,1589266800"; d="scan'208";a="144445603" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 08:39:05 -0700 IronPort-SDR: kZBJ1tx/V1S+LdlJXgqBk/S5pOXh0SxyvRvoB2sJJGg6kf8phq8AHzeeIZDFHeOAcNs8CGiPhB h3lxefzAIQQw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,297,1589266800"; d="scan'208";a="281274404" Received: from orsmsx109.amr.corp.intel.com ([10.22.240.7]) by orsmga006.jf.intel.com with ESMTP; 30 Jun 2020 08:39:05 -0700 Received: from orsmsx154.amr.corp.intel.com (10.22.226.12) by ORSMSX109.amr.corp.intel.com (10.22.240.7) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jun 2020 08:39:04 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX154.amr.corp.intel.com (10.22.226.12) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jun 2020 08:39:04 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.103) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jun 2020 08:39:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QQ3HY5vJhNYAlNR0c273nHwvfxS82eVwK2guUv4ldhDp0/Ym7exU4GZTfdtqn6n1mtIiFv2P10B4O96bJPZTBBkkec5VWJ84M34MLlJsaL1mJT7GhNI1c0m7w6rCyU4xOE47mCrns+zochMYEdk39soI86GjprvIXnZOi/SngFkvmXvzQBYpaAMcoBXD7WDnyKbeV4GuNZVpdHGNVnf9G6K2EIZDnB0xFeYzKgS/ptO5f+3xT6cbouNf1njFXQrfpNquZTswVvMqgCYStkr4NUQgCz7vqqdIh+rDy3ZMQjqoVE8fuRB/7HTSguAIJIsWGqlUblWFEUgWwRv1ZXvV/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cSgn7PbMYcRJDVi4UciLq9cwzz5Gx+/LpAelPPeP710=; b=KqoheI1kR5hI0CAomHVO98ZFgJSQO9BpjMzXlwJdwaQBk0OXpv/ZeWc1cI2ODvHQny5+R2+ShDnAKqp8OxL50d+7liDT6b4O4c8quRDZJH4yAaR3o5zDmAwDrto9iyAcDpTYgC4uvOd0kZcCNVprrYGDQUwr6tSVQz/t9wirpSvrtXRyXnPJMhIzPe/cgCv7FJu1EqClub9u3gaYsaR3XkeL3J7Arha+PjUUojY27r5QOFLX+eppG0qUGL0xCG3oIusmtsk2VlOPMTamKkxZkFuSA+jA1odqzBCXJbJY24y3FstlIiTDd7arcC8x60oWNj3DLJfFHhv71JXzallnVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cSgn7PbMYcRJDVi4UciLq9cwzz5Gx+/LpAelPPeP710=; b=YObXlez7vq2nKp9RT0hrldkhYXz9D0lAGKijbHWSQnWIPLhSNyjbGjqSEqrDvKj+aHK4MkN0p8xb/gVizxIfu43ncqc+TttPEr/sWJ3KErmDctDq7Xeq4w1PUNCoNYlOcHN9ub3rYUWyLF/S3l/T+zFww3+Nec0y404ij4qSy+w= Received: from MWHPR11MB1805.namprd11.prod.outlook.com (2603:10b6:300:114::14) by MWHPR1101MB2141.namprd11.prod.outlook.com (2603:10b6:301:50::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21; Tue, 30 Jun 2020 15:39:03 +0000 Received: from MWHPR11MB1805.namprd11.prod.outlook.com ([fe80::2f:26e2:8473:d215]) by MWHPR11MB1805.namprd11.prod.outlook.com ([fe80::2f:26e2:8473:d215%10]) with mapi id 15.20.3131.028; Tue, 30 Jun 2020 15:39:03 +0000 From: "Pai G, Sunil" To: "Richardson, Bruce" , "dev@dpdk.org" CC: "Richardson, Bruce" , "Stokes, Ian" Thread-Topic: [dpdk-dev] [PATCH] eal: don't use default library path for static binaries Thread-Index: AdZO7zwBHnaT30cQS86JBjC06bew6A== Date: Tue, 30 Jun 2020 15:39:02 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [106.51.109.45] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 50c8c66e-7426-496c-04c7-08d81d0bb75b x-ms-traffictypediagnostic: MWHPR1101MB2141: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 0450A714CB x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: uqLc/rVWuB8OYFIp0mjaREmDcpVbYkTf60Tjd/WotA6KN1/TIaal6TO/m8pjjQO+35hcjsNMS5drkej6PeF4l0pF0VbHukYXxNPoScmXIAIWu7e7a1+26MgwvpxRWV0tAXW87dDdYH3STkLNz8bQWEUK68OmrHPuagTRF7vr2LpJPQetiSCjLkaFq2vth9GXjSou+3TTKzy1+oJ7xDhZiD7lu8UV1n80nnPEXGmOtuIQm/KHtZVZUj7nr1Loich6FLn66tMC1qq2d6zbEdFlH2lhfHPBGzlyTVIzNf4hls9s+sEWmdw0H+oZQdv0H09j/fcWtCq6cK+ZH4WgI72PTg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1805.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(366004)(396003)(346002)(136003)(376002)(316002)(52536014)(86362001)(71200400001)(66946007)(66476007)(66556008)(66446008)(64756008)(110136005)(54906003)(107886003)(2906002)(7696005)(33656002)(9686003)(55016002)(5660300002)(478600001)(76116006)(83380400001)(6506007)(4326008)(186003)(26005)(8676002)(8936002)(55236004)(53546011); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: FJ3OTveicNwFSmyyYBMtA3C5PKXuk0pWIkwXAIa+0Pa2iPYmkaZeoxR0CmgLs6lojrPdvaVq6U4/f2GKazs896fpYUvPM/acNAtg+eNVlcP5kXwSp/0shKe6SJlHQ4g7H6g2dJWVFCvX2wKHerhdp1156LkorkpNCkHosYFN75LdkWrambIw0tL/dZ9/+cljcOjUZkGC2kO5O6gBvk25LbBSZD8FS7Vmi9YyEEcPPyiiHIcc8K4XTHtV9FRZ6w0c+SsvkdcRycMg3/FCFSiSWltqJvQx81juwQU6KPvfG5SuxrTSboKRZHPmrbtZfiPsWba7+IBOB1b4sIdVMR8XHcoJIEY+WzeXurhHVQeir9JvqCwy2DWDVjF3j7d7Y/75ZqLiefLwCwXRi9mrTbKr36n3qRgcJ4PGQOORhUWIoTr/utoOfoWdEXrkHRlMkwf6NxVj5rgGCwNfzanCOFY8s0ZRuQFAf/6a/eng8adxs80= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1805.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50c8c66e-7426-496c-04c7-08d81d0bb75b X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2020 15:39:02.8357 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lyNgZzZv3CXjZa4LEeKoMd/it+u08KalMUEfkEWVhSTEQ0zXChuZ8oJGs5YvOih8hS9TINpzT53yXALdh9ucBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2141 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] eal: don't use default library path for static binaries X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: dev On Behalf Of Bruce Richardson > Sent: Friday, June 26, 2020 8:30 PM > To: dev@dpdk.org > Cc: Richardson, Bruce > Subject: [dpdk-dev] [PATCH] eal: don't use default library path for stati= c > binaries >=20 > When using statically linked DPDK binaries, the EAL checks the default PM= D > path and tries to load any drivers there, despite the fact that all drive= rs are > normally linked into the binary. This behaviour can cause issues if the = PMD > path and lib dir is configured to a non-standard location which is not in= the > ld.so.conf paths, e.g. a build with prefix set to a home directory locati= on. In a > case such as this, EAL will try and > (unnecessarily) load the .so driver files but that load will fail as thei= r > dependent libraries, such as ethdev, for example, will not be found. >=20 > Because of this, it is better if statically linked DPDK apps do not load = drivers > from the standard paths automatically. The user can always have this > behaviour by explicitly specifying the path using -d flag, if so desired. >=20 > Not loading the libraries automatically can also prevent potential issues= with a > user building and running a statically-linked DPDK binary based off a pri= vate > copy of DPDK, while there exists on the same machine a system-wide > installation of DPDK in the default locations. Without this change, the s= ystem- > installed drivers will be loaded to the binary alongside the statically-l= inked > drivers, which is not what the user would have intended. >=20 > To detect whether we are in a statically or dynamically linked binary, we= can > have EAL try to get a dlopen handle to its own shared library, by calling > dlopen with the RTLD_NOLOAD flag. This will return NULL if there is no su= ch > shared lib loaded i.e. the code is executing from a static library, or a = handle to > the lib if it is loaded. >=20 > Signed-off-by: Bruce Richardson > --- > lib/librte_eal/common/eal_common_options.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_eal/common/eal_common_options.c > b/lib/librte_eal/common/eal_common_options.c > index 0901b493c..1d958d11e 100644 > --- a/lib/librte_eal/common/eal_common_options.c > +++ b/lib/librte_eal/common/eal_common_options.c > @@ -447,8 +447,15 @@ eal_plugins_init(void) > struct shared_driver *solib =3D NULL; > struct stat sb; >=20 > - if (*default_solib_dir !=3D '\0' && stat(default_solib_dir, &sb) =3D=3D= 0 && > - S_ISDIR(sb.st_mode)) > + /* if we are not statically linked, add default driver loading > + * path if it exists as a directory. > + * (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) !=3D NULL && > + *default_solib_dir !=3D '\0' && > + stat(default_solib_dir, &sb) =3D=3D 0 && > + S_ISDIR(sb.st_mode)) > eal_plugin_add(default_solib_dir); >=20 > TAILQ_FOREACH(solib, &solib_list, next) { > -- > 2.25.1 While trying to enable DPDK meson build for OVS , this patch turned out to = be quite beneficial when DPDK was installed using a prefix. This fixes the "Cannot open shared object file: No such file or directory" = seen when OVS is built with static DPDK libraries. Tested following scenarios with the patch and all of them function as expec= ted: 1. system installed - OVS with DPDK static libs=20 2. system installed - OVS with DPDK shared libs 3. directory installed using the prefix - OVS with DPDK static libs=20 4. directory installed using the prefix - OVS with DPDK shared libs OVS community would be grateful if this could be back ported to 19.11=20 Acked-by: Sunil Pai G