From 6be4da3dfac66de52b48d8fb56e24fa35b9a24ea Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 8 Apr 2017 08:47:59 -0400 Subject: [PATCH 1/6] 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 From 08c08a35c6552e90aafcdd857ad17e9beecac61f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 8 Apr 2017 08:55:40 -0400 Subject: [PATCH 2/6] lib: Fix debugs to be guarded. Signed-off-by: Donald Sharp --- lib/zclient.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/zclient.c b/lib/zclient.c index 71b95ae7db..d2a5186315 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1486,7 +1486,9 @@ lm_label_manager_connect (struct zclient *zclient) vrf_id_t vrf_id; u_int16_t cmd; - zlog_debug ("Connecting to Label Manager"); + if (zclient_debug) + zlog_debug ("Connecting to Label Manager"); + if (zclient->sock < 0) return -1; @@ -1518,7 +1520,8 @@ lm_label_manager_connect (struct zclient *zclient) zclient->sock = -1; return -1; } - zlog_debug ("%s: Label manager connect request (%d bytes) sent", __func__, ret); + if (zclient_debug) + zlog_debug ("%s: Label manager connect request (%d bytes) sent", __func__, ret); /* read response */ s = zclient->ibuf; @@ -1532,8 +1535,9 @@ lm_label_manager_connect (struct zclient *zclient) } /* result */ result = stream_getc(s); - zlog_debug ("%s: Label Manager connect response (%d bytes) received, result %u", - __func__, size, result); + if (zclient_debug) + zlog_debug ("%s: Label Manager connect response (%d bytes) received, result %u", + __func__, size, result); return (int)result; } @@ -1564,7 +1568,9 @@ lm_get_label_chunk (struct zclient *zclient, u_char keep, uint32_t chunk_size, u_int16_t cmd; u_char response_keep; - zlog_debug ("Getting Label Chunk"); + if (zclient_debug) + zlog_debug ("Getting Label Chunk"); + if (zclient->sock < 0) return -1; @@ -1594,7 +1600,8 @@ lm_get_label_chunk (struct zclient *zclient, u_char keep, uint32_t chunk_size, zclient->sock = -1; return -1; } - zlog_debug ("%s: Label chunk request (%d bytes) sent", __func__, ret); + if (zclient_debug) + zlog_debug ("%s: Label chunk request (%d bytes) sent", __func__, ret); /* read response */ s = zclient->ibuf; @@ -1606,7 +1613,9 @@ lm_get_label_chunk (struct zclient *zclient, u_char keep, uint32_t chunk_size, zlog_err ("%s: Invalid Get Label Chunk Message Reply Header", __func__); return -1; } - zlog_debug ("%s: Label chunk response (%d bytes) received", __func__, size); + if (zclient_debug) + zlog_debug ("%s: Label chunk response (%d bytes) received", __func__, size); + /* keep */ response_keep = stream_getc(s); /* start and end labels */ @@ -1627,8 +1636,9 @@ lm_get_label_chunk (struct zclient *zclient, u_char keep, uint32_t chunk_size, return -1; } - zlog_debug ("Label Chunk assign: %u - %u (%u) ", - *start, *end, response_keep); + if (zclient_debug) + zlog_debug ("Label Chunk assign: %u - %u (%u) ", + *start, *end, response_keep); return 0; } @@ -1647,7 +1657,9 @@ lm_release_label_chunk (struct zclient *zclient, uint32_t start, uint32_t end) int ret; struct stream *s; - zlog_debug ("Releasing Label Chunk"); + if (zclient_debug) + zlog_debug ("Releasing Label Chunk"); + if (zclient->sock < 0) return -1; From 2caafa8c6f815ae3018ce338c083fd75ff2a9102 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sat, 8 Apr 2017 17:52:57 -0300 Subject: [PATCH 3/6] ripd: fix argv index numbers in the redistribute command Fixes Issue#350 Signed-off-by: Renato Westphal --- ripd/rip_zebra.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 7fa3baea7e..578c513c78 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -339,7 +339,7 @@ DEFUN (rip_redistribute_type, for(i = 0; redist_type[i].str; i++) { - if (strncmp (redist_type[i].str, argv[2]->arg, + if (strncmp (redist_type[i].str, argv[1]->arg, redist_type[i].str_min_len) == 0) { zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, @@ -348,7 +348,7 @@ DEFUN (rip_redistribute_type, } } - vty_out(vty, "Invalid type %s%s", argv[2]->arg, + vty_out(vty, "Invalid type %s%s", argv[1]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -365,7 +365,7 @@ DEFUN (no_rip_redistribute_type, for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[3]->arg, + if (strncmp(redist_type[i].str, argv[2]->arg, redist_type[i].str_min_len) == 0) { rip_metric_unset (redist_type[i].type, DONT_CARE_METRIC_RIP); @@ -375,7 +375,7 @@ DEFUN (no_rip_redistribute_type, } } - vty_out(vty, "Invalid type %s%s", argv[3]->arg, + vty_out(vty, "Invalid type %s%s", argv[2]->arg, VTY_NEWLINE); return CMD_WARNING; From d536095fd34c8c14c7bd064dfb8f407256aad373 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 10 Apr 2017 12:28:45 -0300 Subject: [PATCH 4/6] bgpd: fixes for the "show bgp large-community" command * Fix a segfault when the "show bgp large-community" command is given without any optional large communities; * Fix parsing of optional large communities. Without this fix a "Large-community malformed" error is shown even for valid large communities. Signed-off-by: Renato Westphal --- bgpd/bgp_route.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 1fa3e8bc44..4e87ea1ece 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8171,7 +8171,7 @@ bgp_show_lcommunity (struct vty *vty, struct bgp *bgp, int argc, buffer_putc (b, ' '); else { - if (strmatch (argv[i]->text, "")) + if (strmatch (argv[i]->text, "AA:BB:CC")) { first = 1; buffer_putstr (b, argv[i]->arg); @@ -8187,7 +8187,7 @@ bgp_show_lcommunity (struct vty *vty, struct bgp *bgp, int argc, XFREE (MTYPE_TMP, str); if (! lcom) { - vty_out (vty, "%% Large-community malformed: %s", VTY_NEWLINE); + vty_out (vty, "%% Large-community malformed%s", VTY_NEWLINE); return CMD_WARNING; } @@ -8299,8 +8299,7 @@ DEFUN (show_ip_bgp_large_community, return CMD_WARNING; } - argv_find (argv, argc, "large-community", &idx); - if (strmatch(argv[idx+1]->text, "AA:BB:CC")) + if (argv_find (argv, argc, "AA:BB:CC", &idx)) return bgp_show_lcommunity (vty, bgp, argc, argv, afi, safi, uj); else return bgp_show (vty, bgp, afi, safi, bgp_show_type_lcommunity_all, NULL, uj); From b6ab29296fc7dc5b0a6ad0e5345aca3c2c701cba Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 14 Apr 2017 20:13:26 -0400 Subject: [PATCH 5/6] bgpd: Fix 'set as-path prepend last-as 10' 1) Fix missing newline in help string 2) Make the ability to have 10 be consistent with the stable/2.0 branch. Signed-off-by: Donald Sharp --- bgpd/bgp_routemap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index bafc81eaf8..9b5a7a5ebb 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1437,7 +1437,7 @@ route_set_aspath_prepend_compile (const char *arg) { unsigned int num; - if (sscanf(arg, "last-as %u", &num) == 1 && num > 0 && num < 10) + if (sscanf(arg, "last-as %u", &num) == 1 && num > 0 && num <= 10) return (void*)(uintptr_t)num; return route_aspath_compile(arg); @@ -3677,12 +3677,12 @@ DEFUN (set_aspath_prepend_asn, DEFUN (set_aspath_prepend_lastas, set_aspath_prepend_lastas_cmd, - "set as-path prepend last-as (1-9)", + "set as-path prepend last-as (1-10)", SET_STR "Transform BGP AS_PATH attribute\n" "Prepend to the as-path\n" "Use the peer's AS-number\n" - "Number of times to insert") + "Number of times to insert\n") { return set_aspath_prepend_asn (self, vty, argc, argv); } From 5260e25d2000dcd65b9e7f710f20482e1bb9f2df Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 14 Apr 2017 20:39:56 -0400 Subject: [PATCH 6/6] bgpd: 'show .... bgp regexp WORD' fixed The command was always just returning as part of the bgp_regexp_show function. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4e87ea1ece..32cf0bcb89 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8562,8 +8562,6 @@ static int bgp_show_regexp (struct vty *vty, const char *regstr, afi_t afi, safi_t safi, enum bgp_show_type type) { - return CMD_SUCCESS; - regex_t *regex; int rc;