DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/failsafe: fix blank line parsing
@ 2017-08-03 14:52 Gaetan Rivet
  2017-08-03 15:08 ` [dpdk-dev] [PATCH v2] " Gaetan Rivet
  0 siblings, 1 reply; 3+ messages in thread
From: Gaetan Rivet @ 2017-08-03 14:52 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

When the output of an exec() slave definition is only a single newline
character, the fail-safe currently fails to parse the device with the
value returned by the rte_devargs library.

This behavior is incorrect, because the fail-safe should make a
difference between the absence of a device, and an erroneous device
declaration.

Fix the output sanitization in the case where no newline was at its end
and detect the special case of an absent device. The correct error code
is then returned.

Fixes: a0194d828100 ("net/failsafe: add flexible device definition")

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---

This patch depends on:

net/failsafe: fix for missing pclose after popen
http://dpdk.org/ml/archives/dev/2017-August/072429.html

 drivers/net/failsafe/failsafe_args.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c
index 3f92a77..185e2c0 100644
--- a/drivers/net/failsafe/failsafe_args.c
+++ b/drivers/net/failsafe/failsafe_args.c
@@ -101,10 +101,11 @@ fs_parse_device(struct sub_device *sdev, char *args)
 static void
 fs_sanitize_cmdline(char *args)
 {
-	size_t len;
+	char *nl;
 
-	len = strnlen(args, DEVARGS_MAXLEN);
-	args[len - 1] = '\0';
+	nl = strrchr(args, '\n');
+	if (nl)
+		nl[0] = '\0';
 }
 
 static int
@@ -149,6 +150,10 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline)
 		goto ret_pclose;
 	}
 	fs_sanitize_cmdline(output);
+	if (strnlen(output, 1) == 0) {
+		ret = -ENODEV;
+		goto ret_pclose;
+	}
 	ret = fs_parse_device(sdev, output);
 	if (ret) {
 		ERROR("Parsing device '%s' failed", output);
-- 
2.1.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-dev] [PATCH v2] net/failsafe: fix blank line parsing
  2017-08-03 14:52 [dpdk-dev] [PATCH] net/failsafe: fix blank line parsing Gaetan Rivet
@ 2017-08-03 15:08 ` Gaetan Rivet
  2017-08-03 20:34   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Gaetan Rivet @ 2017-08-03 15:08 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

When the output of an exec() slave definition is only a single newline
character, the fail-safe currently fails to parse the device with the
value returned by the rte_devargs library.

This behavior is incorrect, because the fail-safe should make a
difference between the absence of a device, and an erroneous device
declaration.

Fix the output sanitization in the case where no newline was at its end
and detect the special case of an absent device. The correct error code
is then returned.

Fixes: a0194d828100 ("net/failsafe: add flexible device definition")

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---

This patch depends on:

net/failsafe: fix for missing pclose after popen
http://dpdk.org/ml/archives/dev/2017-August/072429.html

v2:

  - Remove useless, unposix use of strnlen

 drivers/net/failsafe/failsafe_args.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c
index 3f92a77..1f22416 100644
--- a/drivers/net/failsafe/failsafe_args.c
+++ b/drivers/net/failsafe/failsafe_args.c
@@ -101,10 +101,11 @@ fs_parse_device(struct sub_device *sdev, char *args)
 static void
 fs_sanitize_cmdline(char *args)
 {
-	size_t len;
+	char *nl;
 
-	len = strnlen(args, DEVARGS_MAXLEN);
-	args[len - 1] = '\0';
+	nl = strrchr(args, '\n');
+	if (nl)
+		nl[0] = '\0';
 }
 
 static int
@@ -149,6 +150,10 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline)
 		goto ret_pclose;
 	}
 	fs_sanitize_cmdline(output);
+	if (output[0] == '\0') {
+		ret = -ENODEV;
+		goto ret_pclose;
+	}
 	ret = fs_parse_device(sdev, output);
 	if (ret) {
 		ERROR("Parsing device '%s' failed", output);
-- 
2.1.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/failsafe: fix blank line parsing
  2017-08-03 15:08 ` [dpdk-dev] [PATCH v2] " Gaetan Rivet
@ 2017-08-03 20:34   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2017-08-03 20:34 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev

03/08/2017 17:08, Gaetan Rivet:
> When the output of an exec() slave definition is only a single newline
> character, the fail-safe currently fails to parse the device with the
> value returned by the rte_devargs library.
> 
> This behavior is incorrect, because the fail-safe should make a
> difference between the absence of a device, and an erroneous device
> declaration.
> 
> Fix the output sanitization in the case where no newline was at its end
> and detect the special case of an absent device. The correct error code
> is then returned.
> 
> Fixes: a0194d828100 ("net/failsafe: add flexible device definition")
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-03 20:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-03 14:52 [dpdk-dev] [PATCH] net/failsafe: fix blank line parsing Gaetan Rivet
2017-08-03 15:08 ` [dpdk-dev] [PATCH v2] " Gaetan Rivet
2017-08-03 20:34   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).