diff options
author | Jakub Kicinski <kuba@kernel.org> | 2023-07-31 09:19:20 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2023-07-31 09:56:44 -0700 |
commit | 84ffffeb0a2ff69e36bd972d57699f9e3bb29a48 (patch) | |
tree | 1ad0f5758bc5934afb9915a83ce79a183882f38c | |
parent | 13a5d8fcb41bbc5875c0a6c150236208eadd3936 (diff) | |
download | iproute2-84ffffeb0a2ff69e36bd972d57699f9e3bb29a48.tar.gz |
ip: error out if iplink does not consume all options
dummy does not define .parse_opt, which make ip ignore all
trailing arguments, for example:
# ip link add type dummy a b c d e f name cheese
will work just fine (and won't call the device "cheese").
Error out in this case with a clear error message:
# ip link add type dummy a b c d e f name cheese
Garbage instead of arguments "a ...". Try "ip link help".
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
-rw-r--r-- | ip/iplink.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/ip/iplink.c b/ip/iplink.c index 6c5d13d53..9a548dd35 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -1112,13 +1112,12 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv) argc -= ret; argv += ret; - if (lu && argc) { + if (lu && lu->parse_opt && argc) { struct rtattr *data; data = addattr_nest(&req.n, sizeof(req), iflatype); - if (lu->parse_opt && - lu->parse_opt(lu, argc, argv, &req.n)) + if (lu->parse_opt(lu, argc, argv, &req.n)) return -1; addattr_nest_end(&req.n, data); |