[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191105211707.10300-2-jakub.kicinski@netronome.com>
Date: Tue, 5 Nov 2019 13:17:05 -0800
From: Jakub Kicinski <jakub.kicinski@...ronome.com>
To: dsahern@...il.com
Cc: stephen@...workplumber.org, netdev@...r.kernel.org,
oss-drivers@...ronome.com, jiri@...nulli.us,
Jakub Kicinski <jakub.kicinski@...ronome.com>
Subject: [PATCH iproute2-next 1/3] devlink: fix referencing namespace by PID
netns parameter for devlink reload is supposed to take PID
as well as string name. However, the PID parsing has two
bugs:
- the opts->netns member is unsigned so the < 0
condition is always false;
- the parameter list is not rewinded after parsing as
a name, so parsing as a pid uses the wrong argument.
Fixes: 08e8e1ca3e05 ("devlink: extend reload command to add support for network namespace change")
Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
---
devlink/devlink.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 9c96d05ea666..682f832a064c 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -345,6 +345,12 @@ static void dl_arg_inc(struct dl *dl)
dl->argv++;
}
+static void dl_arg_dec(struct dl *dl)
+{
+ dl->argc++;
+ dl->argv--;
+}
+
static char *dl_argv_next(struct dl *dl)
{
char *ret;
@@ -1460,7 +1466,8 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required,
if (err)
return err;
opts->netns = netns_get_fd(netns_str);
- if (opts->netns < 0) {
+ if ((int)opts->netns < 0) {
+ dl_arg_dec(dl);
err = dl_argv_uint32_t(dl, &opts->netns);
if (err)
return err;
--
2.23.0
Powered by blists - more mailing lists