From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by dpdk.org (Postfix) with ESMTP id 092791E20 for ; Mon, 28 Aug 2017 09:52:32 +0200 (CEST) Received: by mail-wr0-f179.google.com with SMTP id a47so15995992wra.4 for ; Mon, 28 Aug 2017 00:52:32 -0700 (PDT) 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=hRru8IGKudKsEd0hquB+XF+eT3ggaIV80eo5/YsLDGQ=; b=TafewPOhod9LHgj4u5O4Xovm+KjC8o7kX1GYZYUCWFs5A8pZ6rcMSlSosBPaQTpxVY iA1OwGtexYe88MjGsoLSbMVGCmpfHcMURIE7GLvNn8Zs3pDODFVEsqYraXMfJbAdwtqN 0gQKpCziTD0Scy5L8BHElOz6fcHHUBbEhjCWQeI2ou16emo/sQNf18Av5JzB1ONQrhcy dF0HBF5pu6Wt2Zj0WnGgYh6N9gm3j/KFdBqvn/a3SFd27rAoikr2G6FIuzdbNprq5WSG HaWwl7oWCO67G+SwgY63QVpvqI2BdcM0bqD2j/G8Es/3LMZRlZlqkOjMMVXqXyY0QlmS 5QtA== 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=hRru8IGKudKsEd0hquB+XF+eT3ggaIV80eo5/YsLDGQ=; b=MpbEwzYlGfRocTAVeI+9BZL0bhSmaGmV4LBsmqVbXLo7Py83GcOXH4HhktTJhQ0sgk 1EhcnlBpo79HeE5dKVDO4TTNC4UlrpLyogB38YEqkx7HJKqewS/L+c5nJMGv4Rfq8VoH fM61V/34Z5j27Pd9tUsisRxUFS3AS5FDfpmRXF5BzxmiUE+Fi1pmPMdQgNxEknpx792P rtR6GjnR/RshOzx7TsPRimOnStEzwvZUd5LpWMNErJEjvgtIxLuXxSwXvpFVS9BKr8SL 4CVnSz48/pBapxy57Juqiqx9pw2gJXq8a5/8loBdfkeSuoKQI5gTZZ76GrqghB/lXLnP F/5Q== X-Gm-Message-State: AHYfb5gUeyCvpA41rkdfgEfWlXjDvo+euKVaJV7I+gZLiNfVMmH2wglS tl3F/WStHFARw7Iq56M= X-Received: by 10.223.136.228 with SMTP id g33mr3448065wrg.186.1503906752578; Mon, 28 Aug 2017 00:52:32 -0700 (PDT) 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 r135sm9567036wmg.18.2017.08.28.00.52.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 00:52:31 -0700 (PDT) Date: Mon, 28 Aug 2017 09:52:22 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Matan Azrad Cc: dev@dpdk.org, stable@dpdk.org Message-ID: <20170828075222.GD8124@bidouze.vm.6wind.com> References: <20170821132533.GW8124@bidouze.vm.6wind.com> <1503818594-52694-1-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: <1503818594-52694-1-git-send-email-matan@mellanox.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v3] net/failsafe: fix parameters parsing 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: Mon, 28 Aug 2017 07:52:33 -0000 Hi Matan, thanks On Sun, Aug 27, 2017 at 10:23:14AM +0300, Matan Azrad wrote: > The corrupted code used wrongly snprintf return value as the > number of characters actually copied, in spite of the meanning > is the number of characters which would be generated for the > given input. > > It caused to remain zerod bytes between the failsafe command line > non sub device parameters indicates end of string. > > Hence, when rte_kvargs_parse tried to parse all parameters, it > got end of string after the first one and the others weren't parsed. > > So, if the mac parameters was the first in command line it was > taken while hotplug_poll was left default, and vice versa. > > The fix updates the buffer index by dedicated variable contains > the copy size, by the way validates the comma separation. > > Fixes: a46f8d584eb8 ("net/failsafe: add fail-safe PMD") > Cc: stable@dpdk.org > > Signed-off-by: Matan Azrad Acked-by: Gaetan Rivet > --- > drivers/net/failsafe/failsafe_args.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c > index 1f22416..ae857b0 100644 > --- a/drivers/net/failsafe/failsafe_args.c > +++ b/drivers/net/failsafe/failsafe_args.c > @@ -286,10 +286,17 @@ fs_remove_sub_devices_definition(char params[DEVARGS_MAXLEN]) > ERROR("Invalid parameter"); > return -EINVAL; > } > - if (params[b] == ',' || params[b] == '\0') > - i += snprintf(&buffer[i], b - a + 1, "%s", ¶ms[a]); > - if (params[b] == '(') { > + if (params[b] == ',' || params[b] == '\0') { > + size_t len = b - a; > + > + if (i > 0) > + len += 1; > + snprintf(&buffer[i], len + 1, "%s%s", > + i ? "," : "", ¶ms[a]); > + i += len; > + } else if (params[b] == '(') { > size_t start = b; > + > b += closing_paren(¶ms[b]); > if (b == start) > return -EINVAL; > @@ -393,6 +400,7 @@ failsafe_args_parse(struct rte_eth_dev *dev, const char *params) > &dev->data->mac_addrs[0]); > if (ret < 0) > goto free_kvlist; > + > mac_from_arg = 1; > } > } > -- > 2.7.4 > -- Gaëtan Rivet 6WIND