From ff0e8ee8a5602c4ac633df896444cfb23b095f82 Mon Sep 17 00:00:00 2001 From: Wesley Coakley Date: Mon, 14 Dec 2020 20:01:24 -0500 Subject: [PATCH 1/3] staticd: warn on attempted delete of non-existent route Signed-off-by: Wesley Coakley --- staticd/static_vty.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/staticd/static_vty.c b/staticd/static_vty.c index 1488cc1775..dd03f83778 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -294,8 +294,11 @@ static int static_route_leak(struct vty *vty, const char *svrf, buf_gate_str, ifname); dnode = yang_dnode_get(vty->candidate_config->dnode, ab_xpath); - if (!dnode) + if (!dnode) { + vty_out(vty, + "%% Refusing to remove a non-existent route\n"); return ret; + } dnode = yang_get_subtree_with_no_sibling(dnode); assert(dnode); From cd72ad0133aa908d5dbb5fecc5374598d55b2335 Mon Sep 17 00:00:00 2001 From: Wesley Coakley Date: Fri, 4 Dec 2020 11:37:22 -0800 Subject: [PATCH 2/3] pimd: show ip mroute column realign Signed-off-by: Wesley Coakley --- pimd/pim_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 714d6e8e1d..ae5b7940e9 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -6057,7 +6057,7 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, vty_out(vty, " R - SGRpt Pruned, F - Register flag, T - SPT-bit set\n"); vty_out(vty, - "\nSource Group Flags Proto Input Output TTL Uptime\n"); + "\nSource Group Flags Proto Input Output TTL Uptime\n"); } now = pim_time_monotonic_sec(); @@ -6247,7 +6247,7 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, } vty_out(vty, - "%-15s %-15s %-15s %-6s %-16s %-16s %-3d %8s\n", + "%-15s %-15s %-8s %-6s %-16s %-16s %-3d %8s\n", src_str, grp_str, state_str, proto, in_ifname, out_ifname, ttl, mroute_uptime); From 23f3a92e348207a22c58669971bb135f75aecaf7 Mon Sep 17 00:00:00 2001 From: Wesley Coakley Date: Mon, 30 Nov 2020 14:12:01 -0800 Subject: [PATCH 3/3] tests: address coverity / styling issues in topotests Signed-off-by: Wesley Coakley --- tests/topotests/lib/bgp.py | 46 +++++++++++++++++----------- tests/topotests/lib/common_config.py | 11 ++++--- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py index 22602cb460..55b11dab3c 100644 --- a/tests/topotests/lib/bgp.py +++ b/tests/topotests/lib/bgp.py @@ -2516,8 +2516,9 @@ def verify_best_path_as_per_admin_distance( @retry(attempts=5, wait=2, return_is_str=True, initial_wait=2) -def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None, -aspath=None, multi_nh=None): +def verify_bgp_rib( + tgen, addr_type, dut, input_dict, next_hop=None, aspath=None, multi_nh=None +): """ This API is to verify whether bgp rib has any matching route for a nexthop. @@ -2663,25 +2664,35 @@ aspath=None, multi_nh=None): if not isinstance(next_hop, list): next_hop = [next_hop] list1 = next_hop - found_hops = [rib_r["ip"] for rib_r in - rib_routes_json["routes"][ - st_rt][0]["nexthops"]] + found_hops = [ + rib_r["ip"] + for rib_r in rib_routes_json["routes"][st_rt][0][ + "nexthops" + ] + ] list2 = found_hops - missing_list_of_nexthops = \ - set(list2).difference(list1) - additional_nexthops_in_required_nhs = \ - set(list1).difference(list2) + missing_list_of_nexthops = set(list2).difference(list1) + additional_nexthops_in_required_nhs = set( + list1 + ).difference(list2) if list2: if additional_nexthops_in_required_nhs: - logger.info("Missing nexthop %s for route"\ - " %s in RIB of router %s\n", \ - additional_nexthops_in_required_nhs, \ - st_rt, dut) - errormsg=("Nexthop {} is Missing for "\ - "route {} in RIB of router {}\n".format( + logger.info( + "Missing nexthop %s for route" + " %s in RIB of router %s\n", additional_nexthops_in_required_nhs, - st_rt, dut)) + st_rt, + dut, + ) + errormsg = ( + "Nexthop {} is Missing for " + "route {} in RIB of router {}\n".format( + additional_nexthops_in_required_nhs, + st_rt, + dut, + ) + ) return errormsg else: nh_found = True @@ -3869,6 +3880,7 @@ def verify_attributes_for_evpn_routes( return errormsg if rt == "auto": + vni_dict = {} logger.info( "[DUT: %s]: Verifying auto-rt value for " "evpn route %s:", dut, @@ -3876,8 +3888,6 @@ def verify_attributes_for_evpn_routes( ) if rt_peer: - vni_dict = {} - rnode = tgen.routers()[rt_peer] show_bgp_json = run_frr_cmd( rnode, "show bgp vrf all summary json", isjson=True diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index ce35bdc0fe..fd480aba73 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -336,16 +336,15 @@ def start_router_daemons(tgen, router, daemons): router_list = tgen.routers() # Start daemons - result = router_list[router].startDaemons(daemons) - return result + res = router_list[router].startDaemons(daemons) except Exception as e: errormsg = traceback.format_exc() logger.error(errormsg) - return errormsg + res = errormsg logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name)) - return True + return res def kill_mininet_routers_process(tgen): @@ -1376,12 +1375,14 @@ def generate_ips(network, no_of_ips): return ipaddress_list start_ip = ipaddress.IPv4Address(unicode(start_ip)) step = 2 ** (32 - mask) - if addr_type == "ipv6": + elif addr_type == "ipv6": if start_ip == "0::0" and mask == 0 and no_of_ips == 1: ipaddress_list.append("{}/{}".format(start_ip, mask)) return ipaddress_list start_ip = ipaddress.IPv6Address(unicode(start_ip)) step = 2 ** (128 - mask) + else: + return [] next_ip = start_ip count = 0