]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: fix loss of mixed form in "range" command 10543/head
authoranlan_cs <vic.lan@pica8.com>
Mon, 7 Feb 2022 13:25:28 +0000 (21:25 +0800)
committermergify-bot <noreply@mergify.com>
Wed, 9 Feb 2022 10:49:50 +0000 (10:49 +0000)
Currently "range" command can only accept `cost` or `substitute`
individually, and `show running` will mix them.

So need make it accept mixed form with both of them, otherwise
configuration file in mixed form will fail to start.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
(cherry picked from commit ec88a72a375bc3a228cf2752b03e5aa22d8ef206)

ospfd/ospf_vty.c

index da80b0ab59f87383a2a625eed73336ed7ae46de6..a5bb6ae46bac2a212540561f6b38c30a6bc686a4 100644 (file)
@@ -652,20 +652,22 @@ DEFUN (ospf_area_range,
 
 DEFUN (ospf_area_range_cost,
        ospf_area_range_cost_cmd,
-       "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
+       "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M {cost (0-16777215)|substitute A.B.C.D/M}",
        "OSPF area parameters\n"
        "OSPF area ID in IP address format\n"
        "OSPF area ID as a decimal value\n"
        "Summarize routes matching address/mask (border routers only)\n"
        "Area range prefix\n"
        "User specified metric for this range\n"
-       "Advertised metric for this range\n")
+       "Advertised metric for this range\n"
+       "Announce area range as another prefix\n"
+       "Network prefix to be announced instead of range\n")
 {
        VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
        int idx_ipv4_number = 1;
        int idx_ipv4_prefixlen = 3;
-       int idx_cost = 5;
-       struct prefix_ipv4 p;
+       int idx = 4;
+       struct prefix_ipv4 p, s;
        struct in_addr area_id;
        int format;
        uint32_t cost;
@@ -677,8 +679,16 @@ DEFUN (ospf_area_range_cost,
        ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id),
                                     format);
 
-       cost = strtoul(argv[idx_cost]->arg, NULL, 10);
-       ospf_area_range_cost_set(ospf, area_id, &p, cost);
+       if (argv_find(argv, argc, "cost", &idx)) {
+               cost = strtoul(argv[idx + 1]->arg, NULL, 10);
+               ospf_area_range_cost_set(ospf, area_id, &p, cost);
+       }
+
+       idx = 4;
+       if (argv_find(argv, argc, "substitute", &idx)) {
+               str2prefix_ipv4(argv[idx + 1]->arg, &s);
+               ospf_area_range_substitute_set(ospf, area_id, &p, &s);
+       }
 
        return CMD_SUCCESS;
 }
@@ -742,36 +752,6 @@ DEFUN (no_ospf_area_range,
        return CMD_SUCCESS;
 }
 
-DEFUN (ospf_area_range_substitute,
-       ospf_area_range_substitute_cmd,
-       "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
-       "OSPF area parameters\n"
-       "OSPF area ID in IP address format\n"
-       "OSPF area ID as a decimal value\n"
-       "Summarize routes matching address/mask (border routers only)\n"
-       "Area range prefix\n"
-       "Announce area range as another prefix\n"
-       "Network prefix to be announced instead of range\n")
-{
-       VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
-       int idx_ipv4_number = 1;
-       int idx_ipv4_prefixlen = 3;
-       int idx_ipv4_prefixlen_2 = 5;
-       struct prefix_ipv4 p, s;
-       struct in_addr area_id;
-       int format;
-
-       VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg);
-       str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p);
-       str2prefix_ipv4(argv[idx_ipv4_prefixlen_2]->arg, &s);
-
-       ospf_area_range_substitute_set(ospf, area_id, &p, &s);
-       ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id),
-                                    format);
-
-       return CMD_SUCCESS;
-}
-
 DEFUN (no_ospf_area_range_substitute,
        no_ospf_area_range_substitute_cmd,
        "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
@@ -12769,7 +12749,6 @@ void ospf_vty_init(void)
        install_element(OSPF_NODE, &ospf_area_range_cost_cmd);
        install_element(OSPF_NODE, &ospf_area_range_not_advertise_cmd);
        install_element(OSPF_NODE, &no_ospf_area_range_cmd);
-       install_element(OSPF_NODE, &ospf_area_range_substitute_cmd);
        install_element(OSPF_NODE, &no_ospf_area_range_substitute_cmd);
 
        /* "area virtual-link" commands. */