From: Donald Sharp Date: Wed, 13 Oct 2021 16:40:35 +0000 (-0400) Subject: ospfd: Add `converged` and `role` json output for neighbor command X-Git-Tag: base_8.2~334^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=3766c36a209de3e33df05f71642664921d9cc6c5;p=mirror%2Ffrr.git ospfd: Add `converged` and `role` json output for neighbor command The `show ip ospf neighbor json` command was displaying state:`Full\/DR` Where state was both the role and whether or not the neigbhor was converged. While from a OSPF perspective this is the state. This state is a combination of two things. This creates a problem in testing because we have no guarantee that a particular ospf router will actually have a particular role given how loaded our topotest systems are. So add a bit of json output to display both the converged status as well as the role this router is playing on this neighbor/interface. The above becomes: state:`Full\/DR` converged:`Full` role:`DR` Tests can now be modified to look for `Full` and allow it to continue. Most of the tests do not actually care if this router is the DR or Backup. Signed-off-by: Donald Sharp --- diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index f11c84b092..b1aeefcd43 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -146,8 +146,7 @@ const char *ospf_if_name_string(struct ospf_interface *oi) return buf; } - -void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size) +int ospf_nbr_ism_state(struct ospf_neighbor *nbr) { int state; struct ospf_interface *oi = nbr->oi; @@ -159,6 +158,13 @@ void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size) else state = ISM_DROther; + return state; +} + +void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size) +{ + int state = ospf_nbr_ism_state(nbr); + snprintf(buf, size, "%s/%s", lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), lookup_msg(ospf_ism_state_msg, state, NULL)); diff --git a/ospfd/ospf_dump.h b/ospfd/ospf_dump.h index a1f55dd0af..031ec2f428 100644 --- a/ospfd/ospf_dump.h +++ b/ospfd/ospf_dump.h @@ -150,6 +150,7 @@ extern char *ospf_lsa_type_str[]; extern const char *ospf_area_name_string(struct ospf_area *); extern const char *ospf_area_desc_string(struct ospf_area *); extern const char *ospf_if_name_string(struct ospf_interface *); +extern int ospf_nbr_ism_state(struct ospf_neighbor *nbr); extern void ospf_nbr_state_message(struct ospf_neighbor *, char *, size_t); extern const char *ospf_timer_dump(struct thread *, char *, size_t); extern const char *ospf_timeval_dump(struct timeval *, char *, size_t); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 4109ada64a..4d42734ce5 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -4419,6 +4419,16 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, json_object_string_add(json_neighbor, "state", msgbuf); + json_object_string_add( + json_neighbor, "converged", + lookup_msg(ospf_nsm_state_msg, + nbr->state, NULL)); + json_object_string_add( + json_neighbor, "role", + lookup_msg(ospf_ism_state_msg, + ospf_nbr_ism_state(nbr), + NULL)); + if (nbr->t_inactivity) { long time_store;