]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: fix crash when displaying neighbor data in JSON
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 31 May 2021 13:27:51 +0000 (10:27 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 8 Jun 2021 14:51:12 +0000 (11:51 -0300)
Add a null check to protect against the case where the neighbor
inactive timer is disabled. That can happen when the router is
acting as a helper for another router that is attempting to restart
gracefully.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ospfd/ospf_vty.c

index fb2d790532ba5fc35b60221c8989e1ba6ca849b7..524bf8baee3784a0803ece31eee6ca781267276a 100644 (file)
@@ -4435,21 +4435,27 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
 
                                ospf_nbr_state_message(nbr, msgbuf, 16);
 
-                               long time_store;
-
-                               time_store =
-                                       monotime_until(
-                                               &nbr->t_inactivity->u.sands,
-                                               NULL)
-                                       / 1000LL;
-
                                json_object_int_add(json_neighbor, "priority",
                                                    nbr->priority);
                                json_object_string_add(json_neighbor, "state",
                                                       msgbuf);
-                               json_object_int_add(json_neighbor,
-                                                   "deadTimeMsecs",
-                                                   time_store);
+
+                               if (nbr->t_inactivity) {
+                                       long time_store;
+
+                                       time_store = monotime_until(
+                                                            &nbr->t_inactivity
+                                                                     ->u.sands,
+                                                            NULL)
+                                                    / 1000LL;
+                                       json_object_int_add(json_neighbor,
+                                                           "deadTimeMsecs",
+                                                           time_store);
+                               } else {
+                                       json_object_string_add(json_neighbor,
+                                                              "deadTimeMsecs",
+                                                              "inactive");
+                               }
                                json_object_string_add(
                                        json_neighbor, "address",
                                        inet_ntop(AF_INET, &nbr->src,