]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: Adding apropriate ism state in ptop neighbors.
authorrgirada <rgirada@vmware.com>
Fri, 8 Oct 2021 07:15:48 +0000 (00:15 -0700)
committerrgirada <rgirada@vmware.com>
Tue, 26 Oct 2021 12:36:20 +0000 (05:36 -0700)
Description:
In PointToPoint networks, There wont be DR and BDR.
But by default, All neighbours ism state is shown as
DR_OTHER.

Changed the nbr state format to <nbrsate>/- (ex : FULL/-)
to P2pnetworks.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
ospfd/ospf_dump.c
ospfd/ospf_dump.h
ospfd/ospf_snmp.c
ospfd/ospf_vty.c

index b1aeefcd432d87e744f51aabcc917702eccd46b4..fab5b7d3cc43e3932173e1923d2b8b3c2de5dd98 100644 (file)
@@ -127,7 +127,9 @@ const char *ospf_area_desc_string(struct ospf_area *area)
        return buf;
 }
 
-#define OSPF_IF_STRING_MAXLEN  40
+#define OSPF_IF_STRING_MAXLEN 40
+
+/* Display both nbr and ism state of the ospf neighbor.*/
 const char *ospf_if_name_string(struct ospf_interface *oi)
 {
        static char buf[OSPF_IF_STRING_MAXLEN] = "";
@@ -146,6 +148,13 @@ const char *ospf_if_name_string(struct ospf_interface *oi)
        return buf;
 }
 
+/* Display only the nbr state.*/
+void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size)
+{
+       snprintf(buf, size, "%s",
+                lookup_msg(ospf_nsm_state_msg, nbr->state, NULL));
+}
+
 int ospf_nbr_ism_state(struct ospf_neighbor *nbr)
 {
        int state;
@@ -161,9 +170,23 @@ int ospf_nbr_ism_state(struct ospf_neighbor *nbr)
        return state;
 }
 
-void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size)
+void ospf_nbr_ism_state_message(struct ospf_neighbor *nbr, char *buf,
+                               size_t size)
 {
-       int state = ospf_nbr_ism_state(nbr);
+       int state;
+       struct ospf_interface *oi = nbr->oi;
+
+       if (!oi)
+               return;
+
+       /* network type is point-to-point */
+       if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
+               snprintf(buf, size, "%s/-",
+                        lookup_msg(ospf_nsm_state_msg, nbr->state, NULL));
+               return;
+       }
+
+       state = ospf_nbr_ism_state(nbr);
 
        snprintf(buf, size, "%s/%s",
                 lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
index 031ec2f4286657bef0cffe8bb3444c566d159d6d..58227d038e16e1b06253a5adde918f88b8d45f11 100644 (file)
@@ -151,7 +151,10 @@ 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 void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf,
+                                  size_t size);
+extern void ospf_nbr_ism_state_message(struct ospf_neighbor *nbr, char *buf,
+                                      size_t size);
 extern const char *ospf_timer_dump(struct thread *, char *, size_t);
 extern const char *ospf_timeval_dump(struct timeval *, char *, size_t);
 extern void ospf_packet_dump(struct stream *);
index 432f95f9ddfd5f049e1c7515e07099badbe999f7..a1ea4e45d7fb6d572222dc4c47210d7ddb207feb 100644 (file)
@@ -2432,7 +2432,7 @@ static void ospfTrapNbrStateChange(struct ospf_neighbor *on)
        oid index[sizeof(oid) * (IN_ADDR_SIZE + 1)];
        char msgbuf[16];
 
-       ospf_nbr_state_message(on, msgbuf, sizeof(msgbuf));
+       ospf_nbr_ism_state_message(on, msgbuf, sizeof(msgbuf));
        if (IS_DEBUG_OSPF_EVENT)
                zlog_info("%s: trap sent: %pI4 now %s", __func__,
                          &on->address.u.prefix4, msgbuf);
index 96c28be1b9ab5d36d7f4afd42231afad6df26e72..a3fb291bfc5e0e304fa15cb440bb1b14be5bd5cc 100644 (file)
@@ -4400,7 +4400,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
 
                                json_neighbor = json_object_new_object();
 
-                               ospf_nbr_state_message(nbr, msgbuf, 16);
+                               ospf_nbr_ism_state_message(nbr, msgbuf, 16);
 
                                json_object_int_add(json_neighbor, "priority",
                                                    nbr->priority);
@@ -4467,7 +4467,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
                                json_object_array_add(json_neigh_array,
                                                      json_neighbor);
                        } else {
-                               ospf_nbr_state_message(nbr, msgbuf, 16);
+                               ospf_nbr_ism_state_message(nbr, msgbuf, 16);
 
                                if (nbr->state == NSM_Attempt
                                    && nbr->router_id.s_addr == INADDR_ANY)