ip: error out if iplink does not consume all options
Subsystems (2)
Jakub Kicinski
maintainerPATCH 1/1 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 <[email protected]>
--- ip/iplink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ip/iplink.c +1 -1
@@ -1112,7 +1112,7 @@ 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);
Signature · 1 line
2.41.0
Quoted 5 lines · On Fri, 28 Jul 2023 11:33:29 -0700 Jakub Kicinski <[email protected]> wrote:
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
Quoted 7 lines
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 <[email protected]>
Looks good, but then the latter check for lu->parse_opt in the if clause is redundant. Coverity would flag that (assuming I get Coverity running again on iproute).