]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: Add `converged` and `role` json output for neighbor command
authorDonald Sharp <sharpd@nvidia.com>
Wed, 13 Oct 2021 16:40:35 +0000 (12:40 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 13 Oct 2021 16:40:35 +0000 (12:40 -0400)
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 <sharpd@nvidia.com>
ospfd/ospf_dump.c
ospfd/ospf_dump.h
ospfd/ospf_vty.c

index f11c84b092f94cd7892af1812de25e66c3bcbf81..b1aeefcd432d87e744f51aabcc917702eccd46b4 100644 (file)
@@ -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));
index a1f55dd0af7c95e95bb5aea5112c88615aa9c172..031ec2f4286657bef0cffe8bb3444c566d159d6d 100644 (file)
@@ -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);
index 4109ada64a198b1a28f81e1ed8613a8a30ce6ffe..4d42734ce5b313788efe5e4f58f4bad46a879f64 100644 (file)
@@ -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;