diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2021-05-31 15:27:51 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2021-06-08 16:51:12 +0200 |
commit | b3d498f8b7d5367a49ff77d0fc8cd53ee7593bb8 (patch) | |
tree | 02c41e6f9c0dfd4796a5c1d54ac643fd1fb64c01 /ospfd | |
parent | lib, ospfd, ospf6d: fix logging of pointer addresses (diff) | |
download | frr-b3d498f8b7d5367a49ff77d0fc8cd53ee7593bb8.tar.xz frr-b3d498f8b7d5367a49ff77d0fc8cd53ee7593bb8.zip |
ospfd: fix crash when displaying neighbor data in JSON
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>
Diffstat (limited to 'ospfd')
-rw-r--r-- | ospfd/ospf_vty.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index fb2d79053..524bf8bae 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -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, |