Skip to contentSkip to conversation

iproute2: fix 'ip xfrm monitor all' command

PATCH In review Nathan Harold 2 participants 2 messages May 30, 2018 – Jun 1, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iproute2: fix 'ip xfrm monitor all' command

Currently, calling 'ip xfrm monitor all' will actually invoke the 'all-nsid' command because the soft-match for 'all-nsid' occurs before the precise match for 'all'. This patch rearranges the checks so that the 'all' command, itself an alias for invoking 'ip xfrm monitor' with no argument, can be called consistent with the syntax for other ip commands that accept an 'all'.

---
 ip/xfrm_monitor.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
ip/xfrm_monitor.c +3 -1
index 2eabece0..5d086768 100644
@@ -359,6 +359,8 @@ int do_xfrm_monitor(int argc, char **argv)
 		if (matches(*argv, "file") == 0) {
 			NEXT_ARG();
 			file = *argv;
+		} else if (strcmp(*argv, "all") == 0) {
+			/* fall out */
 		} else if (matches(*argv, "all-nsid") == 0) {
 			listen_all_nsid = 1;
 		} else if (matches(*argv, "acquire") == 0) {
@@ -381,7 +383,7 @@ int do_xfrm_monitor(int argc, char **argv)
 			groups = 0;
 		} else if (matches(*argv, "help") == 0) {
 			usage();
-		} else if (strcmp(*argv, "all")) {
+		} else {
 			fprintf(stderr, "Argument \"%s\" is unknown, try \"ip xfrm monitor help\".\n", *argv);
 			exit(-1);
 		}
Signature · 1 line
2.17.1.1185.g55be947832-goog
#1 lore raw
Quoted 10 lines · On Wed, 30 May 2018 12:11:32 -0700 Nathan Harold <[email protected]> wrote:

Currently, calling 'ip xfrm monitor all' will actually invoke the 'all-nsid' command because the soft-match for 'all-nsid' occurs before the precise match for 'all'. This patch rearranges the checks so that the 'all' command, itself an alias for invoking 'ip xfrm monitor' with no argument, can be called consistent with the syntax for other ip commands that accept an 'all'.

Looks good, applied. After review it shouldn't break any existing command lines.