]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospfd: Few modifications in "show ip ospf neighbor" o/p.
authorrgirada <rgirada@vmware.com>
Fri, 8 Oct 2021 06:18:14 +0000 (23:18 -0700)
committerrgirada <rgirada@vmware.com>
Tue, 26 Oct 2021 12:36:20 +0000 (05:36 -0700)
Description:
1. Adding uptime to the 'show ip ospf neighbor' o/p.
2. Adding uptime and deadtime in string format for json consumption.

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

index 64d3b7a02817afe6cbe9a26fb163c0cd579ef94a..96c28be1b9ab5d36d7f4afd42231afad6df26e72 100644 (file)
@@ -4335,9 +4335,9 @@ DEFUN (show_ip_ospf_interface_traffic,
 
 static void show_ip_ospf_neighbour_header(struct vty *vty)
 {
-       vty_out(vty, "\n%-15s %3s %-15s %9s %-15s %-32s %5s %5s %5s\n",
-               "Neighbor ID", "Pri", "State", "Dead Time", "Address",
-               "Interface", "RXmtL", "RqstL", "DBsmL");
+       vty_out(vty, "\n%-15s %-3s %-15s %-15s %-9s %-15s %-32s %5s %5s %5s\n",
+               "Neighbor ID", "Pri", "State", "Up Time", "Dead Time",
+               "Address", "Interface", "RXmtL", "RqstL", "DBsmL");
 }
 
 static void show_ip_ospf_neighbor_sub(struct vty *vty,
@@ -4350,6 +4350,9 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
        char buf[PREFIX_STRLEN];
        char timebuf[OSPF_TIME_DUMP_SIZE];
        json_object *json_neighbor = NULL, *json_neigh_array = NULL;
+       struct timeval res;
+       long time_val = 0;
+       char uptime[OSPF_TIME_DUMP_SIZE];
 
        for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
                if ((nbr = rn->info)) {
@@ -4359,6 +4362,13 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
                        /* Down state is not shown. */
                        if (nbr->state == NSM_Down)
                                continue;
+
+                       if (nbr->ts_last_progress.tv_sec
+                           || nbr->ts_last_progress.tv_usec)
+                               time_val = monotime_since(
+                                                  &nbr->ts_last_progress, &res)
+                                          / 1000LL;
+
                        if (use_json) {
                                char neigh_str[INET_ADDRSTRLEN];
 
@@ -4415,9 +4425,23 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
                                                                      ->u.sands,
                                                             NULL)
                                                     / 1000LL;
+                                       json_object_int_add(json_neighbor,
+                                                           "upTimeInMsec",
+                                                           time_val);
                                        json_object_int_add(json_neighbor,
                                                            "deadTimeMsecs",
                                                            time_store);
+                                       json_object_string_add(
+                                               json_neighbor, "upTime",
+                                               ospf_timeval_dump(
+                                                       &res, uptime,
+                                                       sizeof(uptime)));
+                                       json_object_string_add(
+                                               json_neighbor, "deadTime",
+                                               ospf_timer_dump(
+                                                       nbr->t_inactivity,
+                                                       timebuf,
+                                                       sizeof(timebuf)));
                                } else {
                                        json_object_string_add(json_neighbor,
                                                               "deadTimeMsecs",
@@ -4451,8 +4475,12 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
                                                nbr->priority, msgbuf);
                                else
                                        vty_out(vty, "%-15pI4 %3d %-15s ",
-                                               &nbr->router_id,
-                                               nbr->priority, msgbuf);
+                                               &nbr->router_id, nbr->priority,
+                                               msgbuf);
+
+                               vty_out(vty, "%-15s ",
+                                       ospf_timeval_dump(&res, uptime,
+                                                         sizeof(uptime)));
 
                                vty_out(vty, "%9s ",
                                        ospf_timer_dump(nbr->t_inactivity,