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 E2901A056A; Wed, 10 Mar 2021 18:21:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C46A22A348; Wed, 10 Mar 2021 18:21:48 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id EADAD40F35 for ; Wed, 10 Mar 2021 18:21:46 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d8so8792809plg.10 for ; Wed, 10 Mar 2021 09:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BZWS29L2xK7108v9hup+H6Utu/6aGqqM0keYmGu18cU=; b=jd17TeCBTQH+UkmOGpV13tZpExzfojQMJAm8LQG9MINfy2FJpD7pPsN2Q5GCDLg2al qzG9vPjCGzDRuSrzDY0oXVs5nknU0+rcwPLMNTwYGBCb5QiXvWEh88IKf6Atwav+8nHD UethTRT6MK4yA51SQcylzehKQpTIoB1DwThnkrWeEGQncn6PHBJeCD0UwqMvMt2ZbTc4 Tg5G1NAc5WKYWFBbK97BM5TpAs1HK78ajroWl00v8zr0Zc5WQUGHKARBXKMulB2DUZKi b//Y0OdNX6BFcwwt/zL3qJs2iy0qxBgGg29cI7F51PtJw+LW8U+qrDmgv0VWVtaPM8mM gpqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BZWS29L2xK7108v9hup+H6Utu/6aGqqM0keYmGu18cU=; b=WOqXL77NujRrEoAO9r3nDuSDAkfMuXUoIIASHTseRSpQYacqTTy7Ts6G/ojBsoh7Z5 oONJbg82ZD8es/FmdLcqs1ycK4fb7X+x4ScaXJF/BHOesGY/lvRQQW48ftj5h0cH32z6 97xZpLpBQqq43inSwOQbyMQxcg7DyPnARmYb5odzGvi5Zw93WnL9serZ5SdIhTJ8gx5m PhAtH5PtK8haL9YP/ExdYS0cgD4b4zMk2I/0vawjXfaZCKnIwiv889Vy2ctnaXE8T2s1 PmzpP3mjErfYxo1T8/Oa3+MMO0wLaN8uZkYL4SvWlMe9KTNdZ2osLwrO3lDX3wS/OEw1 j9Wg== X-Gm-Message-State: AOAM530ZrxnPzU6ecHzkbSe1dpTNQjp77D6Y+HGLh36rBVzhB0A2AS1J 9pzIkpnkj2qU0w7r5K0UNwewbhy1ceYStw== X-Google-Smtp-Source: ABdhPJz6EkQS7Rv7T5aMXfIrZPbltuRqhQ3NPoAVf+oIV1mgF0dzG741R0DEvPHZCsDDUsLWXoUD1A== X-Received: by 2002:a17:90a:2e0d:: with SMTP id q13mr4734318pjd.225.1615396905477; Wed, 10 Mar 2021 09:21:45 -0800 (PST) Received: from hermes.local (76-14-218-44.or.wavecable.com. [76.14.218.44]) by smtp.gmail.com with ESMTPSA id e22sm145658pgk.56.2021.03.10.09.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 09:21:44 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 10 Mar 2021 09:21:37 -0800 Message-Id: <20210310172137.59938-1-sthemmin@microsoft.com> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] eal: allow user to override DPDK runtime path 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 Sender: "dev" There can be cases such as containers or other runtime environments where DPDK may not be able to access the default runtime path. This patch introduces DPDK_RUNTIME_DIR as an environment variable to allow controlling and overriding the path. The example we have is DPDK application running in an untrusted systemd container. In this case, it is not root, and XDG_RUNTIME_DIR is not set (since it is not a user application), and /tmp is blocked. The correct place for this application is to use /run. In any case, hard coded path assumptions are a problem. Signed-off-by: Stephen Hemminger --- lib/librte_eal/linux/eal.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 6c34ac890386..f2a5e73817d6 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -90,20 +90,26 @@ static const char *default_runtime_dir = "/var/run"; int eal_create_runtime_dir(void) { - const char *directory = default_runtime_dir; + const char *directory; const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); const char *fallback = "/tmp"; char run_dir[PATH_MAX]; char tmp[PATH_MAX]; int ret; - if (getuid() != 0) { + directory = getenv("DPDK_RUNTIME_DIR"); + if (directory != NULL) { + RTE_LOG(DEBUG, EAL, "Using DPDK runtime directory: %s\n", directory); + } else if (getuid() == 0) { + directory = default_runtime_dir; + } else { /* try XDG path first, fall back to /tmp */ if (xdg_runtime_dir != NULL) directory = xdg_runtime_dir; else directory = fallback; } + /* create DPDK subdirectory under runtime dir */ ret = snprintf(tmp, sizeof(tmp), "%s/dpdk", directory); if (ret < 0 || ret == sizeof(tmp)) { -- 2.30.1