]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Fix MI-OSPF CLIs
authorChirag Shah <chirag@cumulusnetworks.com>
Thu, 3 Aug 2017 23:34:17 +0000 (16:34 -0700)
committerChirag Shah <chirag@cumulusnetworks.com>
Sat, 5 Aug 2017 01:03:45 +0000 (18:03 -0700)
Handle all instance base clis calling ospf_lookup_instance()
to return CMD_NOT_MY_INSTANCE in case of ospf is not found.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
ospfd/ospf_dump.c
ospfd/ospf_vty.c
vtysh/vtysh.c

index c0670012b8eadc9e5c7d1da4acd7490cea97e516..d3d1ffed5ec3f19b631d4ef0a03a2330e305b49e 100644 (file)
@@ -626,7 +626,7 @@ DEFUN (debug_ospf_packet,
        if (inst) // user passed instance ID
        {
                if (!ospf_lookup_instance(strtoul(argv[2]->arg, NULL, 10)))
-                       return CMD_SUCCESS;
+                       return CMD_NOT_MY_INSTANCE;
        }
 
        int type = 0;
@@ -702,7 +702,7 @@ DEFUN (no_debug_ospf_packet,
        if (inst) // user passed instance ID
        {
                if (!ospf_lookup_instance(strtoul(argv[3]->arg, NULL, 10)))
-                       return CMD_SUCCESS;
+                       return CMD_NOT_MY_INSTANCE;
        }
 
        int type = 0;
@@ -773,7 +773,7 @@ DEFUN (debug_ospf_ism,
        if (inst) // user passed instance ID
        {
                if (!ospf_lookup_instance(strtoul(argv[2]->arg, NULL, 10)))
-                       return CMD_SUCCESS;
+                       return CMD_NOT_MY_INSTANCE;
        }
 
        if (vty->node == CONFIG_NODE) {
@@ -824,7 +824,7 @@ DEFUN (no_debug_ospf_ism,
        if (inst) // user passed instance ID
        {
                if (!ospf_lookup_instance(strtoul(argv[3]->arg, NULL, 10)))
-                       return CMD_SUCCESS;
+                       return CMD_NOT_MY_INSTANCE;
        }
 
        if (vty->node == CONFIG_NODE) {
@@ -991,7 +991,7 @@ DEFUN (no_debug_ospf_instance_nsm,
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
        if (!ospf_lookup_instance(instance))
-               return CMD_SUCCESS;
+               return CMD_NOT_MY_INSTANCE;
 
        return no_debug_ospf_nsm_common(vty, 5, argc, argv);
 }
@@ -1065,7 +1065,7 @@ DEFUN (debug_ospf_instance_lsa,
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
        if (!ospf_lookup_instance(instance))
-               return CMD_SUCCESS;
+               return CMD_NOT_MY_INSTANCE;
 
        return debug_ospf_lsa_common(vty, 4, argc, argv);
 }
@@ -1141,7 +1141,7 @@ DEFUN (no_debug_ospf_instance_lsa,
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
        if (!ospf_lookup_instance(instance))
-               return CMD_SUCCESS;
+               return CMD_NOT_MY_INSTANCE;
 
        return no_debug_ospf_lsa_common(vty, 5, argc, argv);
 }
@@ -1203,7 +1203,7 @@ DEFUN (debug_ospf_instance_zebra,
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
        if (!ospf_lookup_instance(instance))
-               return CMD_SUCCESS;
+               return CMD_NOT_MY_INSTANCE;
 
        return debug_ospf_zebra_common(vty, 4, argc, argv);
 }
index 533b00382b701e0c0174083c12c6fa7856e927a0..f7a512951f868b2e13c5e84b35ce4ed79ab9ec6e 100644 (file)
@@ -175,8 +175,9 @@ DEFUN (no_router_ospf,
        if (argc > 3)
                instance = strtoul(argv[3]->arg, NULL, 10);
 
-       if ((ospf = ospf_lookup_instance(instance)) == NULL)
-               return CMD_SUCCESS;
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
 
        ospf_finish(ospf);
 
@@ -3218,8 +3219,11 @@ DEFUN (show_ip_ospf_instance,
        u_char uj = use_json(argc, argv);
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return (show_ip_ospf_common(vty, ospf, uj));
@@ -3654,8 +3658,11 @@ DEFUN (show_ip_ospf_instance_interface,
        u_char uj = use_json(argc, argv);
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        if (uj)
@@ -3861,8 +3868,11 @@ DEFUN (show_ip_ospf_instance_neighbor,
        u_char uj = use_json(argc, argv);
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return show_ip_ospf_neighbor_common(vty, ospf, uj);
@@ -3982,8 +3992,11 @@ DEFUN (show_ip_ospf_instance_neighbor_all,
        u_char uj = use_json(argc, argv);
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return show_ip_ospf_neighbor_all_common(vty, ospf, uj);
@@ -4075,8 +4088,11 @@ DEFUN (show_ip_ospf_instance_neighbor_int,
        u_char uj = use_json(argc, argv);
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj);
@@ -4462,8 +4478,11 @@ DEFUN (show_ip_ospf_instance_neighbor_id,
        u_char uj = use_json(argc, argv);
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj);
@@ -4551,8 +4570,11 @@ DEFUN (show_ip_ospf_instance_neighbor_detail,
        u_char uj = use_json(argc, argv);
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return show_ip_ospf_neighbor_detail_common(vty, ospf, uj);
@@ -4652,8 +4674,11 @@ DEFUN (show_ip_ospf_instance_neighbor_detail_all,
        u_char uj = use_json(argc, argv);
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj);
@@ -4757,8 +4782,11 @@ DEFUN (show_ip_ospf_instance_neighbor_int_detail,
        u_char uj = use_json(argc, argv);
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj);
@@ -5446,6 +5474,8 @@ DEFUN (show_ip_ospf_instance_database,
        if (argv_find(argv, argc, "(1-65535)", &idx)) {
                instance = strtoul(argv[idx]->arg, NULL, 10);
                ospf = ospf_lookup_instance(instance);
+               if (ospf == NULL)
+                       return CMD_NOT_MY_INSTANCE;
        } else {
                ospf = ospf_lookup();
        }
@@ -5474,8 +5504,11 @@ DEFUN (show_ip_ospf_instance_database_max,
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
 
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv));
@@ -5553,6 +5586,8 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router,
        if (argv_find(argv, argc, "(1-65535)", &idx)) {
                instance = strtoul(argv[idx]->arg, NULL, 10);
                ospf = ospf_lookup_instance(instance);
+               if (ospf == NULL)
+                       return CMD_NOT_MY_INSTANCE;
        } else
                ospf = ospf_lookup();
 
@@ -6922,7 +6957,7 @@ DEFUN (ip_ospf_area,
                        ospf = ospf_lookup();
                        ospf->if_ospf_cli_count--;
                }
-               return CMD_SUCCESS;
+               return CMD_NOT_MY_INSTANCE;
        }
 
        ret = str2area_id(areaid, &area_id, &format);
@@ -6995,8 +7030,9 @@ DEFUN (no_ip_ospf_area,
        if (argv_find(argv, argc, "(1-65535)", &idx))
                instance = strtol(argv[idx]->arg, NULL, 10);
 
-       if ((ospf = ospf_lookup_instance(instance)) == NULL)
-               return CMD_SUCCESS;
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
 
        argv_find(argv, argc, "area", &idx);
 
@@ -8034,8 +8070,11 @@ DEFUN (show_ip_ospf_instance_border_routers,
        u_short instance = 0;
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return show_ip_ospf_border_routers_common(vty, ospf);
@@ -8095,8 +8134,11 @@ DEFUN (show_ip_ospf_instance_route,
        u_short instance = 0;
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
-       if ((ospf = ospf_lookup_instance(instance)) == NULL
-           || !ospf->oi_running)
+       ospf = ospf_lookup_instance(instance);
+       if (ospf == NULL)
+               return CMD_NOT_MY_INSTANCE;
+
+       if (!ospf->oi_running)
                return CMD_SUCCESS;
 
        return show_ip_ospf_route_common(vty, ospf);
index 6ed24cd065ab3a113abeb56b255636cfd0bb30b3..82f44be3a8ffef67929a883072af45532507caca 100644 (file)
@@ -237,6 +237,7 @@ static int vtysh_client_run_all(struct vtysh_client *head_client,
                fprintf(fp,
                        "%% [%s]: command ignored as it targets an instance that is not running",
                        head_client->name);
+               rc_all = CMD_WARNING_CONFIG_FAILED;
        }
        return rc_all;
 }