From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BDCFCA034E; Sun, 26 Dec 2021 13:21:49 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 425B640140; Sun, 26 Dec 2021 13:21:49 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 0837F4013F for ; Sun, 26 Dec 2021 13:21:46 +0100 (CET) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [RFC] eal: support systemd service convention for runtime directory Date: Sun, 26 Dec 2021 13:20:06 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D86DB1@smartserver.smartshare.dk> In-Reply-To: <20211223233907.181033-1-stephen@networkplumber.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [RFC] eal: support systemd service convention for runtime directory Thread-Index: Adf4Vk6Bjbh4uItnQGyPUkf4aQD2qQB+0Vlg References: <20211223233907.181033-1-stephen@networkplumber.org> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Stephen Hemminger" , X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Friday, 24 December 2021 00.39 >=20 > Systemd.exec supports configuring the runtime directory of a service > via RuntimeDirectory=3D. This creates the directory with the necessary > permissions which actual service may not have if running in container. >=20 > The change to DPDK is to look for the environment RUNTIME_DIRECTORY > first and use that in preference to the fallback alternatives. >=20 > Signed-off-by: Stephen Hemminger > --- > lib/eal/linux/eal.c | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) >=20 > diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c > index 60b49248388e..e729c713b393 100644 > --- a/lib/eal/linux/eal.c > +++ b/lib/eal/linux/eal.c > @@ -86,25 +86,26 @@ struct lcore_config lcore_config[RTE_MAX_LCORE]; > /* used by rte_rdtsc() */ > int rte_cycles_vmware_tsc_map; >=20 > -static const char *default_runtime_dir =3D "/var/run"; > - > int > eal_create_runtime_dir(void) > { > - const char *directory =3D default_runtime_dir; > - const char *xdg_runtime_dir =3D getenv("XDG_RUNTIME_DIR"); > - const char *fallback =3D "/tmp"; > + const char *directory; > char run_dir[PATH_MAX]; > char tmp[PATH_MAX]; > int ret; >=20 > - if (getuid() !=3D 0) { > - /* try XDG path first, fall back to /tmp */ > - if (xdg_runtime_dir !=3D NULL) > - directory =3D xdg_runtime_dir; > - else > - directory =3D fallback; > + /* from RuntimeDirectory=3D see systemd.exec */ > + directory =3D getenv("RUNTIME_DIRECTORY"); > + if (directory =3D=3D NULL) { > + if (getuid() =3D=3D 0) > + directory =3D "/var/run"; > + else { > + directory =3D getenv("XDG_RUNTIME_DIR"); > + if (directory =3D=3D NULL) > + directory =3D "/tmp"; > + } > } > + > /* create DPDK subdirectory under runtime dir */ > ret =3D snprintf(tmp, sizeof(tmp), "%s/dpdk", directory); > if (ret < 0 || ret =3D=3D sizeof(tmp)) { > -- > 2.30.2 >=20 Reviewed-by: Morten Br=F8rup Also, while reviewing this, I stumbled across eal_set_runtime_dir() in = eal_common_config.c, which I think should be fixed: int eal_set_runtime_dir(char *run_dir, size_t size) { size_t str_size; - str_size =3D strlcpy(runtime_dir, run_dir, size); - if (str_size >=3D size) { + str_size =3D strlcpy(runtime_dir, run_dir, sizeof(runtime_dir)); + if (str_size >=3D sizeof(runtime_dir)) { RTE_LOG(ERR, EAL, "Runtime directory string too long\n"); return -1; } return 0; } And I don't understand why size is passed as a parameter to = eal_set_runtime_dir().