summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-09-09 18:41:35 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-09-09 20:53:24 +0200
commitb8dfa5447828b06df05eadfa11174fe7d272a0d2 (patch)
treee7b955c8b7da5511b2387955ed9a8fda4284aee2
parentvrf: add a runtime check before playing with netns (diff)
downloadfrr-b8dfa5447828b06df05eadfa11174fe7d272a0d2.tar.xz
frr-b8dfa5447828b06df05eadfa11174fe7d272a0d2.zip
ospfd: Fix crash with usage of incorrect command
Entering 'show ip ospf interface json' causes ospf to crash. Entering 'show ip ospf interface <intf> json' causes ospf to crash if intf has no neighbors on the otherside Modify the code to not crash in these cases. Ticket: CM-12776 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
-rw-r--r--ospfd/ospf_vty.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 264249b4c..1b26c6786 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -3871,7 +3871,13 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface
{
struct timeval result;
unsigned long time_store = 0;
- result = tv_sub (oi->t_hello->u.sands, recent_relative_time());
+ if (oi->t_hello)
+ result = tv_sub (oi->t_hello->u.sands, recent_relative_time());
+ else
+ {
+ result.tv_sec = 0;
+ result.tv_usec = 0;
+ }
time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000);
json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store);
}
@@ -3933,20 +3939,29 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
if (ospf_oi_count(ifp))
{
show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
+ if (use_json)
+ json_object_object_add (json, ifp->name, json_interface_sub);
}
}
}
else if (argv[iface_argv] && strcmp(argv[iface_argv], "json") == 0)
{
+ if (!use_json)
+ {
+ json = json_object_new_object();
+ json_interface_sub = json_object_new_object ();
+ use_json = 1;
+ }
/* Show All Interfaces. */
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
{
if (ospf_oi_count(ifp))
{
show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
- json_object_object_add(json, ifp->name, json_interface_sub);
- }
- }
+ if (use_json)
+ json_object_object_add(json, ifp->name, json_interface_sub);
+ }
+ }
}
else
{