From a663a38ef8e4bcbb726b089a014c826745851d3e Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 19:00:39 +0000 Subject: [PATCH 1/2] ospfd: fix virtual-link timers commands Use {} semantics, correct docstrings, switchup parsing. Signed-off-by: Quentin Young --- ospfd/ospf_vty.c | 67 ++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index bb908ead2f..0b3984c0af 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -988,15 +988,15 @@ ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) "Use null authentication\n" \ "Use message-digest authentication\n" -#define VLINK_HELPSTR_TIME_PARAM_NOSECS \ - "Time between HELLO packets\n" \ - "Time between retransmitting lost link state advertisements\n" \ - "Link state transmit delay\n" \ - "Interval time after which a neighbor is declared down\n" - #define VLINK_HELPSTR_TIME_PARAM \ - VLINK_HELPSTR_TIME_PARAM_NOSECS \ - "Seconds\n" + "Time between HELLO packets\n" \ + "Seconds\n" \ + "Time between retransmitting lost link state advertisements\n" \ + "Seconds\n" \ + "Link state transmit delay\n" \ + "Seconds\n" \ + "Interval time after which a neighbor is declared down\n" \ + "Seconds\n" \ #define VLINK_HELPSTR_AUTH_SIMPLE \ "Authentication password (key)\n" \ @@ -1131,16 +1131,8 @@ DEFUN (ospf_area_vlink, DEFUN (ospf_area_vlink_intervals, ospf_area_vlink_intervals_cmd, - "area virtual-link A.B.C.D" - " (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "]]]", + "area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM VLINK_HELPSTR_TIME_PARAM) { VTY_DECLVAR_CONTEXT(ospf, ospf); @@ -1165,17 +1157,17 @@ DEFUN (ospf_area_vlink_intervals, vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); return CMD_WARNING; } - for (unsigned int i = 0; i < 4; i++) + + for (int idx = 4; idx < argc; idx++) { - int idx = 0; - if (argv_find (argv, argc, "hello-interval", &idx)) - vl_config.hello_interval = strtol(argv[idx+1]->arg, NULL, 10); - else if (argv_find (argv, argc, "retransmit-interval", &idx)) - vl_config.retransmit_interval = strtol(argv[idx+1]->arg, NULL, 10); - else if (argv_find (argv, argc, "transmit-delay", &idx)) - vl_config.transmit_delay = strtol(argv[idx+1]->arg, NULL, 10); - else if (argv_find (argv, argc, "dead-interval", &idx)) - vl_config.dead_interval = strtol(argv[idx+1]->arg, NULL, 10); + if (strmatch (argv[idx]->text, "hello-interval")) + vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "retransmit-interval")) + vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "transmit-delay")) + vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "dead-interval")) + vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); } /* Action configuration */ @@ -1294,17 +1286,9 @@ DEFUN (no_ospf_area_vlink, DEFUN (no_ospf_area_vlink_intervals, no_ospf_area_vlink_intervals_cmd, - "no area virtual-link A.B.C.D" - " (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "]]]", + "no area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", NO_STR VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM VLINK_HELPSTR_TIME_PARAM) { VTY_DECLVAR_CONTEXT(ospf, ospf); @@ -1330,16 +1314,15 @@ DEFUN (no_ospf_area_vlink_intervals, return CMD_WARNING; } - for (unsigned int i = 0; i < 4; i++) + for (int idx = 5; idx < argc; idx++) { - int idx = 0; - if (argv_find (argv, argc, "hello-interval", &idx)) + if (strmatch (argv[idx]->text, "hello-interval")) vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; - else if (argv_find (argv, argc, "retransmit-interval", &idx)) + else if (strmatch (argv[idx]->text, "retransmit-interval")) vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; - else if (argv_find (argv, argc, "transmit-delay", &idx)) + else if (strmatch (argv[idx]->text, "transmit-delay")) vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; - else if (argv_find (argv, argc, "dead-interval", &idx)) + else if (strmatch (argv[idx]->text, "dead-interval")) vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; } From b1c02cec70dfe53af19c44c71339bf721e701973 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 19:04:53 +0000 Subject: [PATCH 2/2] ospfd: shufflin move virtual-link command down to be next to its no form Signed-off-by: Quentin Young --- ospfd/ospf_vty.c | 90 ++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 0b3984c0af..cded08d323 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -1129,51 +1129,6 @@ DEFUN (ospf_area_vlink, } -DEFUN (ospf_area_vlink_intervals, - ospf_area_vlink_intervals_cmd, - "area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM) -{ - VTY_DECLVAR_CONTEXT(ospf, ospf); - struct ospf_vl_config_data vl_config; - int ret = 0; - - ospf_vl_config_data_init(&vl_config, vty); - - char *area_id = argv[1]->arg; - char *router_id = argv[3]->arg; - - ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); - if (ret < 0) - { - vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); - return CMD_WARNING; - } - - ret = inet_aton (router_id, &vl_config.vl_peer); - if (! ret) - { - vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); - return CMD_WARNING; - } - - for (int idx = 4; idx < argc; idx++) - { - if (strmatch (argv[idx]->text, "hello-interval")) - vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); - else if (strmatch (argv[idx]->text, "retransmit-interval")) - vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); - else if (strmatch (argv[idx]->text, "transmit-delay")) - vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); - else if (strmatch (argv[idx]->text, "dead-interval")) - vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); - } - - /* Action configuration */ - return ospf_vl_set (ospf, &vl_config); -} - DEFUN (no_ospf_area_vlink, no_ospf_area_vlink_cmd, "no area virtual-link A.B.C.D [authentication] [] []", @@ -1284,6 +1239,51 @@ DEFUN (no_ospf_area_vlink, return ospf_vl_set (ospf, &vl_config); } +DEFUN (ospf_area_vlink_intervals, + ospf_area_vlink_intervals_cmd, + "area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", + VLINK_HELPSTR_IPADDR + VLINK_HELPSTR_TIME_PARAM) +{ + VTY_DECLVAR_CONTEXT(ospf, ospf); + struct ospf_vl_config_data vl_config; + int ret = 0; + + ospf_vl_config_data_init(&vl_config, vty); + + char *area_id = argv[1]->arg; + char *router_id = argv[3]->arg; + + ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); + if (ret < 0) + { + vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + ret = inet_aton (router_id, &vl_config.vl_peer); + if (! ret) + { + vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); + return CMD_WARNING; + } + + for (int idx = 4; idx < argc; idx++) + { + if (strmatch (argv[idx]->text, "hello-interval")) + vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "retransmit-interval")) + vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "transmit-delay")) + vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "dead-interval")) + vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); + } + + /* Action configuration */ + return ospf_vl_set (ospf, &vl_config); +} + DEFUN (no_ospf_area_vlink_intervals, no_ospf_area_vlink_intervals_cmd, "no area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",