mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 08:32:45 +00:00
Merge pull request #12751 from Pdoijode/pdoijode/ospf-vrf-neighbor-detail-1
ospfd: Added missing fields and option to query specific neighbor in VRF
This commit is contained in:
commit
ba995a720b
@ -794,13 +794,13 @@ Showing Information
|
|||||||
|
|
||||||
.. clicmd:: show ip ospf neighbor [json]
|
.. clicmd:: show ip ospf neighbor [json]
|
||||||
|
|
||||||
.. clicmd:: show ip ospf neighbor INTERFACE [json]
|
.. clicmd:: show ip ospf [vrf <NAME|all>] neighbor INTERFACE [json]
|
||||||
|
|
||||||
.. clicmd:: show ip ospf neighbor detail [json]
|
.. clicmd:: show ip ospf neighbor detail [json]
|
||||||
|
|
||||||
.. clicmd:: show ip ospf neighbor A.B.C.D [detail] [json]
|
.. clicmd:: show ip ospf [vrf <NAME|all>] neighbor A.B.C.D [detail] [json]
|
||||||
|
|
||||||
.. clicmd:: show ip ospf neighbor INTERFACE detail [json]
|
.. clicmd:: show ip ospf [vrf <NAME|all>] neighbor INTERFACE detail [json]
|
||||||
|
|
||||||
Display lsa information of LSDB.
|
Display lsa information of LSDB.
|
||||||
Json o/p of this command covers base route information
|
Json o/p of this command covers base route information
|
||||||
|
@ -297,6 +297,13 @@ int vty_json_no_pretty(struct vty *vty, struct json_object *json)
|
|||||||
return vty_json_helper(vty, json, JSON_C_TO_STRING_NOSLASHESCAPE);
|
return vty_json_helper(vty, json, JSON_C_TO_STRING_NOSLASHESCAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vty_json_empty(struct vty *vty)
|
||||||
|
{
|
||||||
|
json_object *json = json_object_new_object();
|
||||||
|
|
||||||
|
vty_json(vty, json);
|
||||||
|
}
|
||||||
|
|
||||||
/* Output current time to the vty. */
|
/* Output current time to the vty. */
|
||||||
void vty_time_print(struct vty *vty, int cr)
|
void vty_time_print(struct vty *vty, int cr)
|
||||||
{
|
{
|
||||||
|
@ -344,7 +344,7 @@ extern bool vty_set_include(struct vty *vty, const char *regexp);
|
|||||||
*/
|
*/
|
||||||
extern int vty_json(struct vty *vty, struct json_object *json);
|
extern int vty_json(struct vty *vty, struct json_object *json);
|
||||||
extern int vty_json_no_pretty(struct vty *vty, struct json_object *json);
|
extern int vty_json_no_pretty(struct vty *vty, struct json_object *json);
|
||||||
|
extern void vty_json_empty(struct vty *vty);
|
||||||
/* post fd to be passed to the vtysh client
|
/* post fd to be passed to the vtysh client
|
||||||
* fd is owned by the VTY code after this and will be closed when done
|
* fd is owned by the VTY code after this and will be closed when done
|
||||||
*/
|
*/
|
||||||
|
338
ospfd/ospf_vty.c
338
ospfd/ospf_vty.c
@ -4900,9 +4900,8 @@ DEFUN (show_ip_ospf_instance_neighbor_all,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf,
|
static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf,
|
||||||
int arg_base,
|
const char *ifname, bool use_json,
|
||||||
struct cmd_token **argv,
|
uint8_t use_vrf)
|
||||||
bool use_json, uint8_t use_vrf)
|
|
||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
struct route_node *rn;
|
struct route_node *rn;
|
||||||
@ -4921,7 +4920,7 @@ static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf,
|
|||||||
|
|
||||||
ospf_show_vrf_name(ospf, vty, json, use_vrf);
|
ospf_show_vrf_name(ospf, vty, json, use_vrf);
|
||||||
|
|
||||||
ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id);
|
ifp = if_lookup_by_name(ifname, ospf->vrf_id);
|
||||||
if (!ifp) {
|
if (!ifp) {
|
||||||
if (use_json)
|
if (use_json)
|
||||||
json_object_boolean_true_add(json, "noSuchIface");
|
json_object_boolean_true_add(json, "noSuchIface");
|
||||||
@ -4947,58 +4946,9 @@ static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (show_ip_ospf_neighbor_int,
|
DEFPY(show_ip_ospf_instance_neighbor_int,
|
||||||
show_ip_ospf_neighbor_int_cmd,
|
|
||||||
"show ip ospf [vrf <NAME>] neighbor IFNAME [json]",
|
|
||||||
SHOW_STR
|
|
||||||
IP_STR
|
|
||||||
"OSPF information\n"
|
|
||||||
VRF_CMD_HELP_STR
|
|
||||||
"Neighbor list\n"
|
|
||||||
"Interface name\n"
|
|
||||||
JSON_STR)
|
|
||||||
{
|
|
||||||
struct ospf *ospf;
|
|
||||||
int idx_ifname = 0;
|
|
||||||
int idx_vrf = 0;
|
|
||||||
bool uj = use_json(argc, argv);
|
|
||||||
int ret = CMD_SUCCESS;
|
|
||||||
struct interface *ifp = NULL;
|
|
||||||
char *vrf_name = NULL;
|
|
||||||
vrf_id_t vrf_id = VRF_DEFAULT;
|
|
||||||
struct vrf *vrf = NULL;
|
|
||||||
|
|
||||||
if (argv_find(argv, argc, "vrf", &idx_vrf))
|
|
||||||
vrf_name = argv[idx_vrf + 1]->arg;
|
|
||||||
if (vrf_name && strmatch(vrf_name, VRF_DEFAULT_NAME))
|
|
||||||
vrf_name = NULL;
|
|
||||||
if (vrf_name) {
|
|
||||||
vrf = vrf_lookup_by_name(vrf_name);
|
|
||||||
if (vrf)
|
|
||||||
vrf_id = vrf->vrf_id;
|
|
||||||
}
|
|
||||||
ospf = ospf_lookup_by_vrf_id(vrf_id);
|
|
||||||
|
|
||||||
if (!ospf || !ospf->oi_running)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (!uj)
|
|
||||||
show_ip_ospf_neighbour_header(vty);
|
|
||||||
|
|
||||||
argv_find(argv, argc, "IFNAME", &idx_ifname);
|
|
||||||
|
|
||||||
ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
|
|
||||||
if (!ifp)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = show_ip_ospf_neighbor_int_common(vty, ospf, idx_ifname,
|
|
||||||
argv, uj, 0);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN (show_ip_ospf_instance_neighbor_int,
|
|
||||||
show_ip_ospf_instance_neighbor_int_cmd,
|
show_ip_ospf_instance_neighbor_int_cmd,
|
||||||
"show ip ospf (1-65535) neighbor IFNAME [json]",
|
"show ip ospf (1-65535)$instance neighbor IFNAME$ifname [json$json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
"OSPF information\n"
|
"OSPF information\n"
|
||||||
@ -5007,16 +4957,11 @@ DEFUN (show_ip_ospf_instance_neighbor_int,
|
|||||||
"Interface name\n"
|
"Interface name\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
int idx_number = 3;
|
|
||||||
int idx_ifname = 5;
|
|
||||||
struct ospf *ospf;
|
struct ospf *ospf;
|
||||||
unsigned short instance = 0;
|
|
||||||
bool uj = use_json(argc, argv);
|
|
||||||
|
|
||||||
if (!uj)
|
if (!json)
|
||||||
show_ip_ospf_neighbour_header(vty);
|
show_ip_ospf_neighbour_header(vty);
|
||||||
|
|
||||||
instance = strtoul(argv[idx_number]->arg, NULL, 10);
|
|
||||||
if (instance != ospf_instance)
|
if (instance != ospf_instance)
|
||||||
return CMD_NOT_MY_INSTANCE;
|
return CMD_NOT_MY_INSTANCE;
|
||||||
|
|
||||||
@ -5024,11 +4969,10 @@ DEFUN (show_ip_ospf_instance_neighbor_int,
|
|||||||
if (!ospf || !ospf->oi_running)
|
if (!ospf || !ospf->oi_running)
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
if (!uj)
|
if (!json)
|
||||||
show_ip_ospf_neighbour_header(vty);
|
show_ip_ospf_neighbour_header(vty);
|
||||||
|
|
||||||
return show_ip_ospf_neighbor_int_common(vty, ospf, idx_ifname, argv, uj,
|
return show_ip_ospf_neighbor_int_common(vty, ospf, ifname, !!json, 0);
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty,
|
static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty,
|
||||||
@ -5168,19 +5112,36 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,
|
|||||||
json_object_string_add(json_neigh, "areaId",
|
json_object_string_add(json_neigh, "areaId",
|
||||||
ospf_area_desc_string(oi->area));
|
ospf_area_desc_string(oi->area));
|
||||||
json_object_string_add(json_neigh, "ifaceName", oi->ifp->name);
|
json_object_string_add(json_neigh, "ifaceName", oi->ifp->name);
|
||||||
} else
|
if (oi->address)
|
||||||
vty_out(vty, " In the area %s via interface %s\n",
|
json_object_string_addf(json_neigh, "localIfaceAddress",
|
||||||
|
"%pI4",
|
||||||
|
&oi->address->u.prefix4);
|
||||||
|
} else {
|
||||||
|
vty_out(vty, " In the area %s via interface %s",
|
||||||
ospf_area_desc_string(oi->area), oi->ifp->name);
|
ospf_area_desc_string(oi->area), oi->ifp->name);
|
||||||
|
if (oi->address)
|
||||||
|
vty_out(vty, " local interface IP %pI4\n",
|
||||||
|
&oi->address->u.prefix4);
|
||||||
|
else
|
||||||
|
vty_out(vty, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* Show neighbor priority and state. */
|
/* Show neighbor priority and state. */
|
||||||
ospf_nbr_ism_state_message(nbr, neigh_state, sizeof(neigh_state));
|
ospf_nbr_ism_state_message(nbr, neigh_state, sizeof(neigh_state));
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_int_add(json_neigh, "nbrPriority", nbr->priority);
|
json_object_int_add(json_neigh, "nbrPriority", nbr->priority);
|
||||||
json_object_string_add(json_neigh, "nbrState", neigh_state);
|
json_object_string_add(json_neigh, "nbrState", neigh_state);
|
||||||
} else
|
json_object_string_add(json_neigh, "role",
|
||||||
vty_out(vty, " Neighbor priority is %d, State is %s,",
|
lookup_msg(ospf_ism_state_msg,
|
||||||
nbr->priority, neigh_state);
|
ospf_nbr_ism_state(nbr),
|
||||||
|
NULL));
|
||||||
|
} else {
|
||||||
|
vty_out(vty,
|
||||||
|
" Neighbor priority is %d, State is %s, Role is %s,",
|
||||||
|
nbr->priority, neigh_state,
|
||||||
|
lookup_msg(ospf_ism_state_msg, ospf_nbr_ism_state(nbr),
|
||||||
|
NULL));
|
||||||
|
}
|
||||||
/* Show state changes. */
|
/* Show state changes. */
|
||||||
if (use_json)
|
if (use_json)
|
||||||
json_object_int_add(json_neigh, "stateChangeCounter",
|
json_object_int_add(json_neigh, "stateChangeCounter",
|
||||||
@ -5414,7 +5375,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,
|
|||||||
static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,
|
static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,
|
||||||
struct in_addr *router_id,
|
struct in_addr *router_id,
|
||||||
bool use_json, uint8_t use_vrf,
|
bool use_json, uint8_t use_vrf,
|
||||||
bool is_detail)
|
bool is_detail,
|
||||||
|
json_object *json_vrf)
|
||||||
{
|
{
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct ospf_neighbor *nbr;
|
struct ospf_neighbor *nbr;
|
||||||
@ -5448,6 +5410,14 @@ static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,
|
|||||||
use_json);
|
use_json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (json_vrf && use_json) {
|
||||||
|
json_object_object_add(
|
||||||
|
json_vrf,
|
||||||
|
(ospf->vrf_id == VRF_DEFAULT) ? "default" : ospf->name,
|
||||||
|
json);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (use_json)
|
if (use_json)
|
||||||
vty_json(vty, json);
|
vty_json(vty, json);
|
||||||
else
|
else
|
||||||
@ -5456,23 +5426,50 @@ static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFPY(show_ip_ospf_neighbor_id, show_ip_ospf_neighbor_id_cmd,
|
DEFPY(show_ip_ospf_neighbor_id,
|
||||||
"show ip ospf neighbor A.B.C.D$router_id [detail$detail] [json$json]",
|
show_ip_ospf_neighbor_id_cmd,
|
||||||
SHOW_STR IP_STR
|
"show ip ospf [vrf NAME$vrf_name] neighbor A.B.C.D$router_id [detail$detail] [json$json]",
|
||||||
|
SHOW_STR
|
||||||
|
IP_STR
|
||||||
"OSPF information\n"
|
"OSPF information\n"
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
"Neighbor list\n"
|
"Neighbor list\n"
|
||||||
"Neighbor ID\n"
|
"Neighbor ID\n"
|
||||||
"Detailed output\n" JSON_STR)
|
"Detailed output\n"
|
||||||
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct ospf *ospf;
|
struct ospf *ospf;
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
int ret = CMD_SUCCESS;
|
int ret = CMD_SUCCESS;
|
||||||
|
int inst = 0;
|
||||||
|
|
||||||
|
if (vrf_name && !strmatch(vrf_name, "all")) {
|
||||||
|
ospf = ospf_lookup_by_inst_name(inst, vrf_name);
|
||||||
|
if (ospf == NULL || !ospf->oi_running) {
|
||||||
|
if (!json)
|
||||||
|
vty_out(vty,
|
||||||
|
"%% OSPF is not enabled in vrf %s\n",
|
||||||
|
vrf_name);
|
||||||
|
else
|
||||||
|
vty_json_empty(vty);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
ret = show_ip_ospf_neighbor_id_common(
|
||||||
|
vty, ospf, &router_id, !!json, 0, !!detail, NULL);
|
||||||
|
} else {
|
||||||
|
json_object *json_vrf = NULL;
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
json_vrf = json_object_new_object();
|
||||||
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
||||||
if (!ospf->oi_running)
|
if (!ospf->oi_running)
|
||||||
continue;
|
continue;
|
||||||
ret = show_ip_ospf_neighbor_id_common(vty, ospf, &router_id,
|
ret = show_ip_ospf_neighbor_id_common(
|
||||||
!!json, 0, !!detail);
|
vty, ospf, &router_id, !!json, 0, !!detail,
|
||||||
|
json_vrf);
|
||||||
|
}
|
||||||
|
if (json)
|
||||||
|
vty_json(vty, json_vrf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -5497,7 +5494,7 @@ DEFPY(show_ip_ospf_instance_neighbor_id, show_ip_ospf_instance_neighbor_id_cmd,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
return show_ip_ospf_neighbor_id_common(vty, ospf, &router_id, !!json, 0,
|
return show_ip_ospf_neighbor_id_common(vty, ospf, &router_id, !!json, 0,
|
||||||
!!detail);
|
!!detail, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_ip_ospf_neighbor_detail_common(struct vty *vty,
|
static int show_ip_ospf_neighbor_detail_common(struct vty *vty,
|
||||||
@ -5562,9 +5559,9 @@ static int show_ip_ospf_neighbor_detail_common(struct vty *vty,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (show_ip_ospf_neighbor_detail,
|
DEFPY(show_ip_ospf_neighbor_detail,
|
||||||
show_ip_ospf_neighbor_detail_cmd,
|
show_ip_ospf_neighbor_detail_cmd,
|
||||||
"show ip ospf [vrf <NAME|all>] neighbor detail [json]",
|
"show ip ospf [vrf <NAME|all>$vrf_name] neighbor detail [json$json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
"OSPF information\n"
|
"OSPF information\n"
|
||||||
@ -5575,64 +5572,58 @@ DEFUN (show_ip_ospf_neighbor_detail,
|
|||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct ospf *ospf;
|
struct ospf *ospf;
|
||||||
bool uj = use_json(argc, argv);
|
|
||||||
struct listnode *node = NULL;
|
struct listnode *node = NULL;
|
||||||
char *vrf_name = NULL;
|
|
||||||
bool all_vrf = false;
|
|
||||||
int ret = CMD_SUCCESS;
|
int ret = CMD_SUCCESS;
|
||||||
int inst = 0;
|
int inst = 0;
|
||||||
int idx_vrf = 0;
|
|
||||||
uint8_t use_vrf = 0;
|
uint8_t use_vrf = 0;
|
||||||
json_object *json = NULL;
|
json_object *json_vrf = NULL;
|
||||||
|
|
||||||
OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
|
if (json)
|
||||||
|
json_vrf = json_object_new_object();
|
||||||
if (uj)
|
|
||||||
json = json_object_new_object();
|
|
||||||
|
|
||||||
/* vrf input is provided could be all or specific vrf*/
|
/* vrf input is provided could be all or specific vrf*/
|
||||||
if (vrf_name) {
|
if (vrf_name) {
|
||||||
use_vrf = 1;
|
use_vrf = 1;
|
||||||
if (all_vrf) {
|
if (strmatch(vrf_name, "all")) {
|
||||||
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
||||||
if (!ospf->oi_running)
|
if (!ospf->oi_running)
|
||||||
continue;
|
continue;
|
||||||
ret = show_ip_ospf_neighbor_detail_common(
|
ret = show_ip_ospf_neighbor_detail_common(
|
||||||
vty, ospf, json, uj, use_vrf);
|
vty, ospf, json_vrf, !!json, use_vrf);
|
||||||
}
|
}
|
||||||
if (uj)
|
if (json)
|
||||||
vty_json(vty, json);
|
vty_json(vty, json_vrf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ospf = ospf_lookup_by_inst_name(inst, vrf_name);
|
ospf = ospf_lookup_by_inst_name(inst, vrf_name);
|
||||||
if (ospf == NULL || !ospf->oi_running) {
|
if (ospf == NULL || !ospf->oi_running) {
|
||||||
if (uj)
|
if (json)
|
||||||
json_object_free(json);
|
vty_json(vty, json_vrf);
|
||||||
|
else
|
||||||
|
vty_out(vty,
|
||||||
|
"%% OSPF is not enabled in vrf %s\n",
|
||||||
|
vrf_name);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Display default ospf (instance 0) info */
|
/* Display default ospf (instance 0) info */
|
||||||
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
||||||
if (ospf == NULL || !ospf->oi_running) {
|
if (ospf == NULL || !ospf->oi_running) {
|
||||||
if (uj)
|
if (json)
|
||||||
json_object_free(json);
|
vty_json(vty, json_vrf);
|
||||||
|
else
|
||||||
|
vty_out(vty, "%% OSPF is not enabled\n");
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ospf) {
|
if (ospf)
|
||||||
ret = show_ip_ospf_neighbor_detail_common(vty, ospf, json, uj,
|
ret = show_ip_ospf_neighbor_detail_common(vty, ospf, json_vrf,
|
||||||
use_vrf);
|
!!json, use_vrf);
|
||||||
if (uj) {
|
|
||||||
vty_out(vty, "%s\n",
|
|
||||||
json_object_to_json_string_ext(
|
|
||||||
json, JSON_C_TO_STRING_PRETTY));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uj)
|
if (json)
|
||||||
json_object_free(json);
|
vty_json(vty, json_vrf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -5861,9 +5852,9 @@ DEFUN (show_ip_ospf_instance_neighbor_detail_all,
|
|||||||
|
|
||||||
static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
|
static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
|
||||||
struct ospf *ospf,
|
struct ospf *ospf,
|
||||||
int arg_base,
|
const char *ifname,
|
||||||
struct cmd_token **argv,
|
bool use_json,
|
||||||
bool use_json)
|
json_object *json_vrf)
|
||||||
{
|
{
|
||||||
struct ospf_interface *oi;
|
struct ospf_interface *oi;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
@ -5871,8 +5862,15 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
|
|||||||
struct ospf_neighbor *nbr;
|
struct ospf_neighbor *nbr;
|
||||||
json_object *json = NULL;
|
json_object *json = NULL;
|
||||||
|
|
||||||
if (use_json)
|
if (use_json) {
|
||||||
json = json_object_new_object();
|
json = json_object_new_object();
|
||||||
|
if (json_vrf)
|
||||||
|
json_object_object_add(json_vrf,
|
||||||
|
(ospf->vrf_id == VRF_DEFAULT)
|
||||||
|
? "default"
|
||||||
|
: ospf->name,
|
||||||
|
json);
|
||||||
|
}
|
||||||
|
|
||||||
if (ospf->instance) {
|
if (ospf->instance) {
|
||||||
if (use_json)
|
if (use_json)
|
||||||
@ -5882,13 +5880,13 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
|
|||||||
vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance);
|
vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id);
|
ifp = if_lookup_by_name(ifname, ospf->vrf_id);
|
||||||
if (!ifp) {
|
if (!ifp) {
|
||||||
if (!use_json)
|
if (!use_json) {
|
||||||
vty_out(vty, "No such interface.\n");
|
vty_out(vty, "No such interface.\n");
|
||||||
else {
|
} else {
|
||||||
vty_out(vty, "{}\n");
|
if (!json_vrf)
|
||||||
json_object_free(json);
|
vty_json(vty, json);
|
||||||
}
|
}
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
@ -5916,37 +5914,114 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_json)
|
if (use_json) {
|
||||||
|
if (!json_vrf)
|
||||||
vty_json(vty, json);
|
vty_json(vty, json);
|
||||||
else
|
} else {
|
||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (show_ip_ospf_neighbor_int_detail,
|
DEFPY(show_ip_ospf_neighbor_int,
|
||||||
show_ip_ospf_neighbor_int_detail_cmd,
|
show_ip_ospf_neighbor_int_cmd,
|
||||||
"show ip ospf neighbor IFNAME detail [json]",
|
"show ip ospf [vrf NAME$vrf_name] neighbor IFNAME$ifname [json$json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
"OSPF information\n"
|
"OSPF information\n"
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
|
"Neighbor list\n"
|
||||||
|
"Interface name\n"
|
||||||
|
JSON_STR)
|
||||||
|
{
|
||||||
|
struct ospf *ospf;
|
||||||
|
int ret = CMD_SUCCESS;
|
||||||
|
struct interface *ifp = NULL;
|
||||||
|
vrf_id_t vrf_id = VRF_DEFAULT;
|
||||||
|
struct vrf *vrf = NULL;
|
||||||
|
|
||||||
|
if (vrf_name && strmatch(vrf_name, VRF_DEFAULT_NAME))
|
||||||
|
vrf_name = NULL;
|
||||||
|
if (vrf_name) {
|
||||||
|
vrf = vrf_lookup_by_name(vrf_name);
|
||||||
|
if (vrf)
|
||||||
|
vrf_id = vrf->vrf_id;
|
||||||
|
}
|
||||||
|
ospf = ospf_lookup_by_vrf_id(vrf_id);
|
||||||
|
|
||||||
|
if (!ospf || !ospf->oi_running) {
|
||||||
|
if (json)
|
||||||
|
vty_json_empty(vty);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!json)
|
||||||
|
show_ip_ospf_neighbour_header(vty);
|
||||||
|
|
||||||
|
ifp = if_lookup_by_name(ifname, vrf_id);
|
||||||
|
if (!ifp) {
|
||||||
|
if (json)
|
||||||
|
vty_json_empty(vty);
|
||||||
|
else
|
||||||
|
vty_out(vty, "No such interface.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = show_ip_ospf_neighbor_int_common(vty, ospf, ifname, !!json, 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFPY(show_ip_ospf_neighbor_int_detail,
|
||||||
|
show_ip_ospf_neighbor_int_detail_cmd,
|
||||||
|
"show ip ospf [vrf NAME$vrf_name] neighbor IFNAME$ifname detail [json$json]",
|
||||||
|
SHOW_STR
|
||||||
|
IP_STR
|
||||||
|
"OSPF information\n"
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
"Neighbor list\n"
|
"Neighbor list\n"
|
||||||
"Interface name\n"
|
"Interface name\n"
|
||||||
"detail of all neighbors\n"
|
"detail of all neighbors\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct ospf *ospf;
|
struct ospf *ospf;
|
||||||
bool uj = use_json(argc, argv);
|
|
||||||
struct listnode *node = NULL;
|
struct listnode *node = NULL;
|
||||||
int ret = CMD_SUCCESS;
|
int ret = CMD_SUCCESS;
|
||||||
bool ospf_output = false;
|
bool ospf_output = false;
|
||||||
|
|
||||||
|
if (vrf_name && !strmatch(vrf_name, "all")) {
|
||||||
|
int inst = 0;
|
||||||
|
|
||||||
|
ospf = ospf_lookup_by_inst_name(inst, vrf_name);
|
||||||
|
if (ospf == NULL || !ospf->oi_running) {
|
||||||
|
if (!json)
|
||||||
|
vty_out(vty,
|
||||||
|
"%% OSPF is not enabled in vrf %s\n",
|
||||||
|
vrf_name);
|
||||||
|
else
|
||||||
|
vty_json_empty(vty);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
return show_ip_ospf_neighbor_int_detail_common(
|
||||||
|
vty, ospf, ifname, !!json, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
json_object *json_vrf = NULL;
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
json_vrf = json_object_new_object();
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
||||||
if (!ospf->oi_running)
|
if (!ospf->oi_running)
|
||||||
continue;
|
continue;
|
||||||
ospf_output = true;
|
ospf_output = true;
|
||||||
ret = show_ip_ospf_neighbor_int_detail_common(vty, ospf, 4,
|
ret = show_ip_ospf_neighbor_int_detail_common(vty, ospf, ifname,
|
||||||
argv, uj);
|
!!json, json_vrf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json) {
|
||||||
|
vty_json(vty, json_vrf);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ospf_output)
|
if (!ospf_output)
|
||||||
@ -5955,9 +6030,9 @@ DEFUN (show_ip_ospf_neighbor_int_detail,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (show_ip_ospf_instance_neighbor_int_detail,
|
DEFPY(show_ip_ospf_instance_neighbor_int_detail,
|
||||||
show_ip_ospf_instance_neighbor_int_detail_cmd,
|
show_ip_ospf_instance_neighbor_int_detail_cmd,
|
||||||
"show ip ospf (1-65535) neighbor IFNAME detail [json]",
|
"show ip ospf (1-65535)$instance neighbor IFNAME$ifname detail [json$json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
"OSPF information\n"
|
"OSPF information\n"
|
||||||
@ -5967,13 +6042,8 @@ DEFUN (show_ip_ospf_instance_neighbor_int_detail,
|
|||||||
"detail of all neighbors\n"
|
"detail of all neighbors\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
int idx_number = 3;
|
|
||||||
int idx_ifname = 5;
|
|
||||||
struct ospf *ospf;
|
struct ospf *ospf;
|
||||||
unsigned short instance = 0;
|
|
||||||
bool uj = use_json(argc, argv);
|
|
||||||
|
|
||||||
instance = strtoul(argv[idx_number]->arg, NULL, 10);
|
|
||||||
if (instance != ospf_instance)
|
if (instance != ospf_instance)
|
||||||
return CMD_NOT_MY_INSTANCE;
|
return CMD_NOT_MY_INSTANCE;
|
||||||
|
|
||||||
@ -5981,8 +6051,8 @@ DEFUN (show_ip_ospf_instance_neighbor_int_detail,
|
|||||||
if (!ospf || !ospf->oi_running)
|
if (!ospf || !ospf->oi_running)
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
return show_ip_ospf_neighbor_int_detail_common(vty, ospf, idx_ifname,
|
return show_ip_ospf_neighbor_int_detail_common(vty, ospf, ifname,
|
||||||
argv, uj);
|
!!json, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show functions */
|
/* Show functions */
|
||||||
|
Loading…
Reference in New Issue
Block a user