From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id D21341B04C for ; Thu, 18 Jan 2018 09:52:01 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id 141so20983469wme.3 for ; Thu, 18 Jan 2018 00:52:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=jKjxP2T0aFB/GW7ddkrpqPGTV49a3KAooU3YzGHptfk=; b=V8kxOhnUDnVGVpojw1eRZv5JkUGmK4TC92psNil1Mgs9zq+jnY/olX0HFj6QRCPiSZ BKA0HSUshaH8vElr3a6RBUA0HTkQB9y+vwTxzDOLrUml1X/6T5+pOd5Ptqt2x/WdaBK4 RAueqTYAtXrnIPXl7fbIyQ+KINm9G/+hyYnaZIu9WSgNUnOW5uEq1G+ProrcXf+npj8A U19i/utijEuIoWH5PxHPbGLiNGHj3ZUwT7Z9nJGVTcy7ZTZ+U3Xv/Qvp8MOC2BE6Y1mW ln3mJStpO2RbxPC8ImyTZbUtWrRBVHxlQ6TxbWCUu+p1FHG/pl3fJkAmcmfT8R4PFU0f WiLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=jKjxP2T0aFB/GW7ddkrpqPGTV49a3KAooU3YzGHptfk=; b=IpaGemO+RoYvXTmsNtiFGovvg+iT27XbWP34inuyCNk8EU5wIf7z75HjrBg3pMC5FT Te3MVX6xbL9Gd7yCcNqa5B+EOJaFz4zqZBI5ssrzQZtcU2liGN1/PTAMugk3zXwgbM5J jCIqnefr0a12vd22vEIuauoE2UbwnD/OZviZmcqDh1P6up/6jFn8PEFsGJUpoCL+mah1 OGBkkLIY8aBxE50nRsJCXpIOWEYEazayeSVF9Un3fHjSBnPeTHO+yxIc5rJK1XTqDE8y BJmWQKFOFejaVR712dnAe7zn6f/3Q/fuJ4KWK1ut0/Tfov+zthuAOguA3vZ1pRMciO0l BFpw== X-Gm-Message-State: AKwxytc5aVeSo8YzJYFCCzPgQfF23gOV7OmhD/2/MOzqBfa7qgLg2iBg 288pxQBOAqmrR8wzX9i5XxJWm+r2 X-Google-Smtp-Source: ACJfBoty16pVdD+GPrZuU9kYodTM7Ny8jmHQSZnLSsAU+IcEGtxlfLAtYEEl2lUGqck0mW71f4uP6w== X-Received: by 10.80.158.169 with SMTP id a38mr6900338edf.72.1516265521428; Thu, 18 Jan 2018 00:52:01 -0800 (PST) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id y3sm3585529edb.1.2018.01.18.00.52.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2018 00:52:00 -0800 (PST) Date: Thu, 18 Jan 2018 09:51:48 +0100 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Matan Azrad Cc: Ferruh Yigit , Thomas Monjalon , dev@dpdk.org, stephen@networkplumber.org, Adrien Mazarguil Message-ID: <20180118085148.5yvv46bsysou35ec@bidouze.vm.6wind.com> References: <1515509253-17834-1-git-send-email-matan@mellanox.com> <1516265026-6469-1-git-send-email-matan@mellanox.com> <1516265026-6469-3-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1516265026-6469-3-git-send-email-matan@mellanox.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v4 2/8] net/failsafe: add "fd" parameter 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: Thu, 18 Jan 2018 08:52:02 -0000 Hi Matan, You forgot to fix the fcntl call, see below, On Thu, Jan 18, 2018 at 08:43:40AM +0000, Matan Azrad wrote: > This parameter enables applications to provide device definitions through > an arbitrary file descriptor number. > > Signed-off-by: Adrien Mazarguil > Signed-off-by: Matan Azrad with the relevant fixes: Acked-by: Gaetan Rivet > --- > doc/guides/nics/fail_safe.rst | 9 ++++ > drivers/net/failsafe/failsafe_args.c | 80 ++++++++++++++++++++++++++++++++- > drivers/net/failsafe/failsafe_private.h | 3 ++ > 3 files changed, 91 insertions(+), 1 deletion(-) > > diff --git a/doc/guides/nics/fail_safe.rst b/doc/guides/nics/fail_safe.rst > index c4e3d2e..5b1b47e 100644 > --- a/doc/guides/nics/fail_safe.rst > +++ b/doc/guides/nics/fail_safe.rst > @@ -106,6 +106,15 @@ Fail-safe command line parameters > All commas within the ``shell command`` are replaced by spaces before > executing the command. This helps using scripts to specify devices. > > +- **fd()** parameter > + > + This parameter reads a device definition from an arbitrary file descriptor > + number in ```` format as described above. > + > + The file descriptor is read in non-blocking mode and is never closed in > + order to take only the last line into account (unlike ``exec()``) at every > + probe attempt. > + > - **mac** parameter [MAC address] > > This parameter allows the user to set a default MAC address to the fail-safe > diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c > index ec63ac9..db5235b 100644 > --- a/drivers/net/failsafe/failsafe_args.c > +++ b/drivers/net/failsafe/failsafe_args.c > @@ -31,7 +31,11 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > > +#include > +#include > +#include > #include > +#include > #include > > #include > @@ -161,6 +165,67 @@ typedef int (parse_cb)(struct rte_eth_dev *dev, const char *params, > } > > static int > +fs_read_fd(struct sub_device *sdev, char *fd_str) > +{ > + FILE *fp = NULL; > + int fd = -1; > + /* store possible newline as well */ > + char output[DEVARGS_MAXLEN + 1]; > + int err = -ENODEV; > + int oflags; > + int lcount; > + > + RTE_ASSERT(fd_str != NULL || sdev->fd_str != NULL); > + if (sdev->fd_str == NULL) { > + sdev->fd_str = strdup(fd_str); > + if (sdev->fd_str == NULL) { > + ERROR("Command line allocation failed"); > + return -ENOMEM; > + } > + } > + errno = 0; > + fd = strtol(fd_str, &fd_str, 0); > + if (errno || *fd_str || fd < 0) { > + ERROR("Parsing FD number failed"); > + goto error; > + } > + /* Fiddle with copy of file descriptor */ > + fd = dup(fd); > + if (fd == -1) > + goto error; > + oflags = fcntl(fd, F_GETFL); > + if (oflags == -1) > + goto error; > + if (fcntl(fd, F_SETFL, fd | O_NONBLOCK) == -1) fcntl(fd, F_SETFL, oflags | O_NONBLOCK); here > + goto error; > + fp = fdopen(fd, "r"); > + if (!fp) While you're at it, here please use if (fp != NULL) instead. Regards, -- Gaëtan Rivet 6WIND