From 6be4da3dfac66de52b48d8fb56e24fa35b9a24ea Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 8 Apr 2017 08:47:59 -0400 Subject: [PATCH] ospfd: Fix the 'show ip ospf int ...' command Fixed output: robot.cumulusnetworks.com# show ip ospf int enp0s3 is up ifindex 2, MTU 1500 bytes, BW 0 Mbit Internet Address 10.0.2.15/24, Broadcast 10.0.2.255, Area 0.0.0.0 MTU mismatch detection:enabled Router ID 192.168.0.1, Network Type BROADCAST, Cost: 10 Transmit Delay is 1 sec, State Waiting, Priority 1 No backup designated router on this network Multicast group memberships: OSPFAllRouters Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5 Hello due in 9.611s Neighbor Count is 0, Adjacent neighbor count is 0 enp0s10 is up ifindex 7, MTU 1500 bytes, BW 0 Mbit Internet Address 192.168.201.146/24, Broadcast 192.168.201.255, Area 0.0.0.0 MTU mismatch detection:enabled Router ID 192.168.0.1, Network Type BROADCAST, Cost: 10 Transmit Delay is 1 sec, State Waiting, Priority 1 No backup designated router on this network Multicast group memberships: OSPFAllRouters Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5 Hello due in 7.241s Neighbor Count is 0, Adjacent neighbor count is 0 robot.cumulusnetworks.com# show ip ospf int enp0s3 enp0s3 is up ifindex 2, MTU 1500 bytes, BW 0 Mbit Internet Address 10.0.2.15/24, Broadcast 10.0.2.255, Area 0.0.0.0 MTU mismatch detection:enabled Router ID 192.168.0.1, Network Type BROADCAST, Cost: 10 Transmit Delay is 1 sec, State Waiting, Priority 1 No backup designated router on this network Multicast group memberships: OSPFAllRouters Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5 Hello due in 2.915s Neighbor Count is 0, Adjacent neighbor count is 0 robot.cumulusnetworks.com# show ip ospf int enp0s10 json { "enp0s10":{ "ifUp":true, "ifIndex":7, "mtuBytes":1500, "bandwidthMbit":0, "ifFlags":"", "ospfEnabled":true, "ipAddress":"192.168.201.146", "ipAddressPrefixlen":24, "ospfIfType":"Broadcast", "localIfUsed":"192.168.201.255", "area":"0.0.0.0", "routerId":"192.168.0.1", "networkType":"BROADCAST", "cost":10, "transmitDelayMsecs":1000, "state":"Waiting", "priority":1, "mcastMemberOspfAllRouters":true, "timerMsecs":100, "timerDeadMsecs":25, "timerWaitMsecs":25, "timerRetransmit":200, "timerHelloInMsecs":2106, "nbrCount":0, "nbrAdjacentCount":0 } } robot.cumulusnetworks.com# Signed-off-by: Donald Sharp --- ospfd/ospf_vty.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 49474df826..b4c456e0aa 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3557,7 +3557,7 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, VTY_NEWLINE, VTY_NEWLINE); } - if (argc == (iface_argv + 1)) + if (argc == iface_argv) { /* Show All Interfaces.*/ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) @@ -3570,25 +3570,6 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, } } } - else if (argv[iface_argv] && strcmp(argv[iface_argv]->arg, "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); - if (use_json) - json_object_object_add(json, ifp->name, json_interface_sub); - } - } - } else { /* Interface name is specified. */ @@ -3634,7 +3615,10 @@ DEFUN (show_ip_ospf_interface, if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) return CMD_SUCCESS; - return show_ip_ospf_interface_common(vty, ospf, argc, argv, 0, uj); + if (uj) + argc--; + + return show_ip_ospf_interface_common(vty, ospf, argc, argv, 4, uj); } DEFUN (show_ip_ospf_instance_interface, @@ -3657,7 +3641,10 @@ DEFUN (show_ip_ospf_instance_interface, if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; - return show_ip_ospf_interface_common(vty, ospf, argc, argv, 1, uj); + if (uj) + argc--; + + return show_ip_ospf_interface_common(vty, ospf, argc, argv, 5, uj); } static void -- 2.39.5