From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id 4F00E5F5D for ; Fri, 13 Apr 2018 17:31:13 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id u11so9159342wri.12 for ; Fri, 13 Apr 2018 08:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VYp5JJVyu13gGcy3UZORk6Pea8VLN8elA3AWdNvP2Wg=; b=tHnLPTZsdhpDKYEJor2AV8FnzWhBRVYbeUMCw3AKR9tfwmBnPTmpIzf05Pr9ayw+CB gCagqkTwWetLr6O8xt5BUXMruMT9lCqtjbEPTehpAIseeWKyXoBkFbBLpHwESaDwbFHW N+Al0JGr8oJuRs+9Qwo97InVQEudsPAhZch8liPm91p1Jk6nBFQo/2PXwjKCAGqVhJze q5YWmlNLp8hJVf1JkZJELisdYia9yHKP+aEPIFnAG66lUZyoP5UFV/Nwcr5TeOoYebu7 pE5Xzb2sJiA1FitmEbwhtVUOCbUmnb1Pi8EAAja8gdU+1jtYhal/51syErQpCFqwiDv3 yHpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VYp5JJVyu13gGcy3UZORk6Pea8VLN8elA3AWdNvP2Wg=; b=G5Si+kNWnQqQpT0Iu47rJsaI5ZvCG326kxkwq1ZzDjjkxyenb9sD7w7Y1W81ZrccLU zIocjKpxiWHqKZoJVaRET7KcK2p9XJ0vEGPowWsYicSFvPbmAwScbbSMUW3zgk4729K1 62VZMVt0Dv5mSrh1uPZkxhs4u8bGLR+fcRaD6UGDBiBSlHDz4yqsyz8sTew1/oPnauQx 4ualYn1Px/DP0umuYX1i7+2cy4cxuNfJoc43whscyPgeDdIIOJGl7Cple/+7PaicqgXy fHO8skzA/ZaHp0P0fHSvGEICzGI0EpI7AC7hXLCoJjxct9B/DnwEO84/lvvWw2ZP1hwF 9AvA== X-Gm-Message-State: ALQs6tCvezU78oZX6Etbr8YXkMyRWTkq6n8MtwKeLjFkNgaEzmCTvfjL z2a0C2QppHc2cqnIgP6bwHtzuuHUpPZS0ZUD3u4DZw== X-Google-Smtp-Source: AIpwx48tksAkrxJxsLJiUqFfJMbk0hTsn8I64Jbz5fIBJSc7DZWnSJyJquhjxJ9e2gvmpbEoop1o2PmML56TwMu5eYo= X-Received: by 10.80.243.16 with SMTP id p16mr21233990edm.101.1523633473083; Fri, 13 Apr 2018 08:31:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.203.69 with HTTP; Fri, 13 Apr 2018 08:31:12 -0700 (PDT) In-Reply-To: References: <20180412222208.11770-1-aconole@redhat.com> <20180412222208.11770-3-aconole@redhat.com> From: Alejandro Lucero Date: Fri, 13 Apr 2018 16:31:12 +0100 Message-ID: To: Aaron Conole Cc: dev , Adrien Mazarguil Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [RFC 2/2] nfp: allow for non-root user 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: , X-List-Received-Date: Fri, 13 Apr 2018 15:31:13 -0000 On Fri, Apr 13, 2018 at 2:31 PM, Aaron Conole wrote: > Alejandro Lucero writes: > > > Again, this patch is correct, but because NFP PMD needs to access > > /sys/bus/pci/devices/$DEVICE_PCI_STRING/resource$RESOURCE_ID, and these > files have just > > read/write accesses for root, I do not know if this is really necessary. > > > > Being honest, I have not used a DPDK app with NFP PMD and not being > root. Does it work > > with non-root users and other PMDs with same requirements regarding > sysfs resource files? > > We do run as non-root user definitely with Intel PMDs. > > I'm not very sure about other vendors, but I think mlx pmd runs as > non-root user (and it was modified to move off of sysfs for that > reason[1]). > > It is possible to not rely on sysfs resource files if device is attached to VFIO, but I think that is a must with UIO. > I'll continue to push for more information from the testing side to find > out though. > > [1]: http://dpdk.org/ml/archives/dev/2018-February/090586.html > > > On Fri, Apr 13, 2018 at 12:22 AM, Aaron Conole > wrote: > > > > Currently, the nfp lock files are taken from the global lock file > > location, which will work when the user is running as root. However, > > some distributions and applications (notably ovs 2.8+ on RHEL/Fedora) > > run as a non-root user. > > > > Signed-off-by: Aaron Conole > > --- > > drivers/net/nfp/nfp_nfpu.c | 23 ++++++++++++++++++----- > > 1 file changed, 18 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/net/nfp/nfp_nfpu.c b/drivers/net/nfp/nfp_nfpu.c > > index 2ed985ff4..ae2e07220 100644 > > --- a/drivers/net/nfp/nfp_nfpu.c > > +++ b/drivers/net/nfp/nfp_nfpu.c > > @@ -18,6 +18,22 @@ > > #define NFP_CFG_EXP_BAR 7 > > > > #define NFP_CFG_EXP_BAR_CFG_BASE 0x30000 > > +#define NFP_LOCKFILE_PATH_FMT "%s/nfp%d" > > + > > +/* get nfp lock file path (/var/lock if root, $HOME otherwise) */ > > +static void > > +nspu_get_lockfile_path(char *buffer, int bufsz, nfpu_desc_t *desc) > > +{ > > + const char *dir = "/var/lock"; > > + const char *home_dir = getenv("HOME"); > > + > > + if (getuid() != 0 && home_dir != NULL) > > + dir = home_dir; > > + > > + /* use current prefix as file path */ > > + snprintf(buffer, bufsz, NFP_LOCKFILE_PATH_FMT, dir, > > + desc->nfp); > > +} > > > > /* There could be other NFP userspace tools using the NSP interface. > > * Make sure there is no other process using it and locking the access > for > > @@ -30,9 +46,7 @@ nspv_aquire_process_lock(nfpu_desc_t *desc) > > struct flock lock; > > char lockname[30]; > > > > - memset(&lock, 0, sizeof(lock)); > > - > > - snprintf(lockname, sizeof(lockname), "/var/lock/nfp%d", > desc->nfp); > > + nspu_get_lockfile_path(lockname, sizeof(lockname), desc); > > > > /* Using S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | > S_IWOTH */ > > desc->lock = open(lockname, O_RDWR | O_CREAT, 0666); > > @@ -106,7 +120,6 @@ nfpu_close(nfpu_desc_t *desc) > > rte_free(desc->nspu); > > close(desc->lock); > > > > - snprintf(lockname, sizeof(lockname), "/var/lock/nfp%d", > desc->nfp); > > - unlink(lockname); > > + nspu_get_lockfile_path(lockname, sizeof(lockname), desc); > > return 0; > > } > > -- > > 2.14.3 >