]> 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)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 9 Jun 2021 16:27:14 +0000 (19:27 +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 3186eabea9cc9817b0510f7ace49551f3b0045f3..cb64187d723bc13b716c68faadb908d275c075d7 100644 (file)
@@ -4407,21 +4407,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,