Skip to contentSkip to conversation

ip: allow using a device "help" (or a prefix thereof)

PATCH Superseded Christoph Schulz 3 participants 3 messages Sep 18, 2015 – Sep 23, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip: allow using a device "help" (or a prefix thereof)

Device names that match "help" or a prefix thereof should be allowed anywhere a device name can be used. Note that a suitable keyword ("dev" or "name", the latter for "ip tunnel") has to be used in these cases to resolve ambiguities.

---
 ip/ip6tunnel.c | 2 +-
 ip/ipaddress.c | 2 +-
 ip/iplink.c    | 6 ++----
 ip/ipmaddr.c   | 2 +-
 4 files changed, 5 insertions(+), 7 deletions(-)
ip/ip6tunnel.c +1 -1
index 62a8240..9884efd 100644
@@ -287,7 +287,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip6_tnl_parm2 *p)
 			if (strcmp(*argv, "name") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (p->name[0])
 				duparg2("name", *argv);
ip/ipaddress.c +1 -1
index 2aa5fbf..4c97b4a 100644
@@ -1561,7 +1561,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 			if (strcmp(*argv, "dev") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (filter_dev)
 				duparg2("dev", *argv);
ip/iplink.c +2 -4
index 97f46cd..6f840cf 100644
@@ -649,8 +649,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 		} else {
 			if (strcmp(*argv, "dev") == 0)
 				NEXT_ARG();
-
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (*dev)
 				duparg2("dev", *argv);
@@ -1148,8 +1147,7 @@ static int do_set(int argc, char **argv)
 		} else {
 			if (strcmp(*argv, "dev") == 0)
 				NEXT_ARG();
-
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 
 			if (dev)
ip/ipmaddr.c +1 -1
index a77a18f..cbd6d11 100644
@@ -257,7 +257,7 @@ static int multiaddr_list(int argc, char **argv)
 			if (strcmp(*argv, "dev") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (filter.dev)
 				duparg2("dev", *argv);
Signature · 1 line
2.4.6
#1 lore raw
Quoted 3 lines · Christoph Schulz

Device names that match "help" or a prefix thereof should be allowed anywhere a device name can be used. Note that a suitable keyword ("dev" or "name", the latter for "ip tunnel") has to be used in these cases to resolve ambiguities.

Lol :D

#2 lore raw
In reply to Christoph Schulz
Quoted 7 lines · On Fri, 18 Sep 2015 10:23:45 +0200 Christoph Schulz <[email protected]> wrote:

Device names that match "help" or a prefix thereof should be allowed anywhere a device name can be used. Note that a suitable keyword ("dev" or "name", the latter for "ip tunnel") has to be used in these cases to resolve ambiguities.

This patch no longer applies cleanly after this patch that was just merged.

commit 940a96e6ca9a14cd52c97a719a1700b417adb2fb

Author: Phil Sutter <[email protected]>
Date:   Mon Sep 21 21:33:01 2015 +0200

ip-link: do not support 'ip link add dev help'

Commit 0532555 ('Support "ip link add help" for rtnl_link API') added a check for specified help parameter. Though due to the place where it has been added to, it is not possible anymore to force a given parameter to be interpreted as interface name by prefixing it with 'dev '. Fix this by forcing whatever follows 'dev' to be presumed as interface name.