diff options
author | Chirag Shah <chirag@cumulusnetworks.com> | 2017-08-04 01:34:17 +0200 |
---|---|---|
committer | Chirag Shah <chirag@cumulusnetworks.com> | 2017-08-05 03:03:45 +0200 |
commit | ac28e4ecaf5f8821d573ff1a3b8b7e95df5dd3ce (patch) | |
tree | 9c5dddb21ad63a8fb75dea33fe54e11c56e62453 /ospfd | |
parent | ospfd: Fix MI-OSPF configuraton clis (diff) | |
download | frr-ac28e4ecaf5f8821d573ff1a3b8b7e95df5dd3ce.tar.xz frr-ac28e4ecaf5f8821d573ff1a3b8b7e95df5dd3ce.zip |
ospfd: Fix MI-OSPF CLIs
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>
Diffstat (limited to 'ospfd')
-rw-r--r-- | ospfd/ospf_dump.c | 16 | ||||
-rw-r--r-- | ospfd/ospf_vty.c | 100 |
2 files changed, 79 insertions, 37 deletions
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index c0670012b..d3d1ffed5 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -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); } diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 533b00382..f7a512951 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -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); |