diff options
77 files changed, 2427 insertions, 2005 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 995917b6bd..ddc5c61ee7 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -197,8 +197,6 @@ static __attribute__((__noreturn__)) void bgp_exit(int status) frr_early_fini(); - bfd_gbl_exit(); - bgp_close(); bgp_default = bgp_get_default(); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 7cd36ef538..36aa3e1a3e 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -132,10 +132,6 @@ DEFINE_HOOK(bgp_inst_config_write, (bgp, vty)); DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); -#define GR_NO_OPER \ - "The Graceful Restart No Operation was executed as cmd same as previous one." -#define GR_INVALID \ - "The Graceful Restart command used is not valid at this moment." static struct peer_group *listen_range_exists(struct bgp *bgp, struct prefix *range, int exact); @@ -750,9 +746,6 @@ int bgp_nb_errmsg_return(char *errmsg, size_t errmsg_len, int ret) case BGP_ERR_GR_OPERATION_FAILED: str = "The Graceful Restart Operation failed due to an err."; break; - case BGP_GR_NO_OPERATION: - str = GR_NO_OPER; - break; case BGP_ERR_PEER_GROUP_MEMBER: str = "Peer-group member cannot override remote-as of peer-group"; break; diff --git a/isisd/isis_adjacency.h b/isisd/isis_adjacency.h index 754345c008..b7fab7ae1e 100644 --- a/isisd/isis_adjacency.h +++ b/isisd/isis_adjacency.h @@ -105,7 +105,7 @@ struct isis_adjacency { struct isis_circuit *circuit; /* back pointer */ uint16_t *mt_set; /* Topologies this adjacency is valid for */ unsigned int mt_count; /* Number of entries in mt_set */ - struct bfd_session *bfd_session; + struct bfd_session_params *bfd_session; struct list *adj_sids; /* Segment Routing Adj-SIDs. */ uint32_t snmp_idx; struct listnode *snmp_list_node; diff --git a/isisd/isis_bfd.c b/isisd/isis_bfd.c index 89f1ed0ba3..ed4d2c6539 100644 --- a/isisd/isis_bfd.c +++ b/isisd/isis_bfd.c @@ -34,319 +34,32 @@ DEFINE_MTYPE_STATIC(ISISD, BFD_SESSION, "ISIS BFD Session"); -struct bfd_session { - int family; - union g_addr dst_ip; - union g_addr src_ip; - int status; -}; - -static struct bfd_session *bfd_session_new(int family, union g_addr *dst_ip, - union g_addr *src_ip) -{ - struct bfd_session *rv; - - rv = XCALLOC(MTYPE_BFD_SESSION, sizeof(*rv)); - rv->family = family; - rv->dst_ip = *dst_ip; - rv->src_ip = *src_ip; - return rv; -} - -static void bfd_session_free(struct bfd_session **session) -{ - if (!*session) - return; - - XFREE(MTYPE_BFD_SESSION, *session); -} - -static bool bfd_session_same(const struct bfd_session *session, int family, - const union g_addr *src, const union g_addr *dst) -{ - if (session->family != family) - return false; - - switch (session->family) { - case AF_INET: - if (!IPV4_ADDR_SAME(&session->dst_ip.ipv4, &dst->ipv4)) - return false; - if (!IPV4_ADDR_SAME(&session->src_ip.ipv4, &src->ipv4)) - return false; - break; - case AF_INET6: - if (!IPV6_ADDR_SAME(&session->dst_ip.ipv6, &dst->ipv6)) - return false; - if (!IPV6_ADDR_SAME(&session->src_ip.ipv6, &src->ipv6)) - return false; - break; - default: - flog_err(EC_LIB_DEVELOPMENT, "%s: unknown address-family: %u", - __func__, session->family); - exit(1); - } - - return true; -} - -static void bfd_adj_event(struct isis_adjacency *adj, struct prefix *dst, - int new_status) -{ - if (!adj->bfd_session) { - if (IS_DEBUG_BFD) - zlog_debug( - "ISIS-BFD: Ignoring update for adjacency with %s, could not find bfd session on the adjacency", - isis_adj_name(adj)); - return; - } - - if (adj->bfd_session->family != dst->family) { - if (IS_DEBUG_BFD) - zlog_debug( - "ISIS-BFD: Ignoring update for adjacency with %s, address family does not match the family on the adjacency", - isis_adj_name(adj)); - return; - } - - switch (adj->bfd_session->family) { - case AF_INET: - if (!IPV4_ADDR_SAME(&adj->bfd_session->dst_ip.ipv4, - &dst->u.prefix4)) { - if (IS_DEBUG_BFD) - zlog_debug( - "ISIS-BFD: Ignoring update for adjacency with %s, IPv4 address does not match", - isis_adj_name(adj)); - return; - } - break; - case AF_INET6: - if (!IPV6_ADDR_SAME(&adj->bfd_session->dst_ip.ipv6, - &dst->u.prefix6)) { - if (IS_DEBUG_BFD) - zlog_debug( - "ISIS-BFD: Ignoring update for adjacency with %s, IPv6 address does not match", - isis_adj_name(adj)); - return; - } - break; - default: - flog_err(EC_LIB_DEVELOPMENT, "%s: unknown address-family: %u", - __func__, adj->bfd_session->family); - exit(1); - } - - int old_status = adj->bfd_session->status; - - BFD_SET_CLIENT_STATUS(adj->bfd_session->status, new_status); - - if (old_status == new_status) { - if (IS_DEBUG_BFD) - zlog_debug( - "ISIS-BFD: Ignoring update for adjacency with %s, new status matches current known status", - isis_adj_name(adj)); - return; - } - - if (IS_DEBUG_BFD) { - char dst_str[INET6_ADDRSTRLEN]; - - inet_ntop(adj->bfd_session->family, &adj->bfd_session->dst_ip, - dst_str, sizeof(dst_str)); - zlog_debug("ISIS-BFD: Peer %s on %s changed from %s to %s", - dst_str, adj->circuit->interface->name, - bfd_get_status_str(old_status), - bfd_get_status_str(new_status)); - } - - if (old_status != BFD_STATUS_UP - || new_status != BFD_STATUS_DOWN) { - return; - } - - adj->circuit->area->bfd_signalled_down = true; - - isis_adj_state_change(&adj, ISIS_ADJ_DOWN, "bfd session went down"); -} - -static int isis_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS) -{ - struct interface *ifp; - struct prefix dst_ip, src_ip; - int status; - - ifp = bfd_get_peer_info(zclient->ibuf, &dst_ip, &src_ip, &status, NULL, - vrf_id); - if (!ifp || (dst_ip.family != AF_INET && dst_ip.family != AF_INET6)) - return 0; - - if (IS_DEBUG_BFD) { - char dst_buf[INET6_ADDRSTRLEN]; - - inet_ntop(dst_ip.family, &dst_ip.u.prefix, dst_buf, - sizeof(dst_buf)); - - zlog_debug("ISIS-BFD: Received update for %s on %s: Changed state to %s", - dst_buf, ifp->name, bfd_get_status_str(status)); - } - - struct isis_circuit *circuit = circuit_scan_by_ifp(ifp); - - if (!circuit) { - if (IS_DEBUG_BFD) - zlog_debug( - "ISIS-BFD: Ignoring update, could not find circuit"); - return 0; - } - - if (circuit->circ_type == CIRCUIT_T_BROADCAST) { - for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) { - struct list *adjdb = circuit->u.bc.adjdb[level - 1]; - - struct listnode *node, *nnode; - struct isis_adjacency *adj; - - for (ALL_LIST_ELEMENTS(adjdb, node, nnode, adj)) - bfd_adj_event(adj, &dst_ip, status); - } - } else if (circuit->circ_type == CIRCUIT_T_P2P) { - if (circuit->u.p2p.neighbor) { - bfd_adj_event(circuit->u.p2p.neighbor, - &dst_ip, status); - } - } - - return 0; -} - -static int isis_bfd_nbr_replay(ZAPI_CALLBACK_ARGS) +static void adj_bfd_cb(struct bfd_session_params *bsp, + const struct bfd_session_status *bss, void *arg) { - bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, vrf_id); - - struct listnode *anode; - struct isis_area *area; - struct isis *isis = NULL; - - isis = isis_lookup_by_vrfid(vrf_id); - - if (isis == NULL) { - zlog_warn(" %s : ISIS routing instance not found", __func__); - return -1; - } - - if (IS_DEBUG_BFD) - zlog_debug("ISIS-BFD: Got neighbor replay request, resending neighbors."); - - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { - struct listnode *cnode; - struct isis_circuit *circuit; - - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) - isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_UPDATE); - } + struct isis_adjacency *adj = arg; if (IS_DEBUG_BFD) - zlog_debug("ISIS-BFD: Done with replay."); - - return 0; -} - -static void (*orig_zebra_connected)(struct zclient *); -static void isis_bfd_zebra_connected(struct zclient *zclient) -{ - if (orig_zebra_connected) - orig_zebra_connected(zclient); - - bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, VRF_DEFAULT); -} - -static void bfd_debug(int family, union g_addr *dst, union g_addr *src, - const char *interface, int command) -{ - if (!(IS_DEBUG_BFD)) - return; - - char dst_str[INET6_ADDRSTRLEN]; - char src_str[INET6_ADDRSTRLEN]; - - inet_ntop(family, dst, dst_str, sizeof(dst_str)); - inet_ntop(family, src, src_str, sizeof(src_str)); - - const char *command_str; - - switch (command) { - case ZEBRA_BFD_DEST_REGISTER: - command_str = "Register"; - break; - case ZEBRA_BFD_DEST_DEREGISTER: - command_str = "Deregister"; - break; - case ZEBRA_BFD_DEST_UPDATE: - command_str = "Update"; - break; - default: - command_str = "Unknown-Cmd"; - break; - } - - zlog_debug("ISIS-BFD: %s peer %s on %s (src %s)", - command_str, dst_str, interface, src_str); -} - -static void bfd_command(int command, struct bfd_info *bfd_info, int family, - const void *dst_ip, const void *src_ip, - const char *if_name) -{ - struct bfd_session_arg args = {}; - size_t addrlen; - - args.cbit = 1; - args.family = family; - args.vrf_id = VRF_DEFAULT; - args.command = command; - args.bfd_info = bfd_info; - if (args.bfd_info) { - args.min_rx = bfd_info->required_min_rx; - args.min_tx = bfd_info->desired_min_tx; - args.detection_multiplier = bfd_info->detect_mult; - if (bfd_info->profile[0]) { - args.profilelen = strlen(bfd_info->profile); - strlcpy(args.profile, bfd_info->profile, - sizeof(args.profile)); - } - } - - addrlen = family == AF_INET ? sizeof(struct in_addr) - : sizeof(struct in6_addr); - memcpy(&args.dst, dst_ip, addrlen); - if (src_ip) - memcpy(&args.src, src_ip, addrlen); + zlog_debug( + "ISIS-BFD: BFD changed status for adjacency %s old %s new %s", + isis_adj_name(adj), + bfd_get_status_str(bss->previous_state), + bfd_get_status_str(bss->state)); - if (if_name) { - strlcpy(args.ifname, if_name, sizeof(args.ifname)); - args.ifnamelen = strlen(args.ifname); + if (bss->state == BFD_STATUS_DOWN + && bss->previous_state == BFD_STATUS_UP) { + adj->circuit->area->bfd_signalled_down = true; + isis_adj_state_change(&adj, ISIS_ADJ_DOWN, + "bfd session went down"); } - - zclient_bfd_command(zclient, &args); } static void bfd_handle_adj_down(struct isis_adjacency *adj) { - if (!adj->bfd_session) - return; - - bfd_debug(adj->bfd_session->family, &adj->bfd_session->dst_ip, - &adj->bfd_session->src_ip, adj->circuit->interface->name, - ZEBRA_BFD_DEST_DEREGISTER); - - bfd_command(ZEBRA_BFD_DEST_DEREGISTER, NULL, adj->bfd_session->family, - &adj->bfd_session->dst_ip, &adj->bfd_session->src_ip, - (adj->circuit->interface) ? adj->circuit->interface->name - : NULL); - - bfd_session_free(&adj->bfd_session); + bfd_sess_free(&adj->bfd_session); } -static void bfd_handle_adj_up(struct isis_adjacency *adj, int command) +static void bfd_handle_adj_up(struct isis_adjacency *adj) { struct isis_circuit *circuit = adj->circuit; int family; @@ -355,10 +68,10 @@ static void bfd_handle_adj_up(struct isis_adjacency *adj, int command) struct list *local_ips; struct prefix *local_ip; - if (!circuit->bfd_info) { + if (!circuit->bfd_config.enabled) { if (IS_DEBUG_BFD) zlog_debug( - "ISIS-BFD: skipping BFD initialization on adjacency with %s because there is no bfd_info in the circuit", + "ISIS-BFD: skipping BFD initialization on adjacency with %s because BFD is not enabled for the circuit", isis_adj_name(adj)); goto out; } @@ -407,28 +120,20 @@ static void bfd_handle_adj_up(struct isis_adjacency *adj, int command) } else goto out; - if (adj->bfd_session) { - if (bfd_session_same(adj->bfd_session, family, &src_ip, - &dst_ip)) - bfd_handle_adj_down(adj); - } - - if (!adj->bfd_session) { - if (IS_DEBUG_BFD) - zlog_debug( - "ISIS-BFD: creating BFD session for adjacency with %s", - isis_adj_name(adj)); - adj->bfd_session = bfd_session_new(family, &dst_ip, &src_ip); - } - - bfd_debug(adj->bfd_session->family, &adj->bfd_session->dst_ip, - &adj->bfd_session->src_ip, circuit->interface->name, command); - - bfd_command(command, circuit->bfd_info, family, - &adj->bfd_session->dst_ip, &adj->bfd_session->src_ip, - (adj->circuit->interface) ? adj->circuit->interface->name - : NULL); + if (adj->bfd_session == NULL) + adj->bfd_session = bfd_sess_new(adj_bfd_cb, adj); + bfd_sess_set_timers(adj->bfd_session, BFD_DEF_DETECT_MULT, + BFD_DEF_MIN_RX, BFD_DEF_MIN_TX); + if (family == AF_INET) + bfd_sess_set_ipv4_addrs(adj->bfd_session, &src_ip.ipv4, + &dst_ip.ipv4); + else + bfd_sess_set_ipv6_addrs(adj->bfd_session, &src_ip.ipv6, + &dst_ip.ipv6); + bfd_sess_set_interface(adj->bfd_session, adj->circuit->interface->name); + bfd_sess_set_profile(adj->bfd_session, circuit->bfd_config.profile); + bfd_sess_install(adj->bfd_session); return; out: bfd_handle_adj_down(adj); @@ -437,23 +142,21 @@ out: static int bfd_handle_adj_state_change(struct isis_adjacency *adj) { if (adj->adj_state == ISIS_ADJ_UP) - bfd_handle_adj_up(adj, ZEBRA_BFD_DEST_REGISTER); + bfd_handle_adj_up(adj); else bfd_handle_adj_down(adj); return 0; } -static void bfd_adj_cmd(struct isis_adjacency *adj, int command) +static void bfd_adj_cmd(struct isis_adjacency *adj) { - if (adj->adj_state == ISIS_ADJ_UP - && command != ZEBRA_BFD_DEST_DEREGISTER) { - bfd_handle_adj_up(adj, command); - } else { + if (adj->adj_state == ISIS_ADJ_UP && adj->circuit->bfd_config.enabled) + bfd_handle_adj_up(adj); + else bfd_handle_adj_down(adj); - } } -void isis_bfd_circuit_cmd(struct isis_circuit *circuit, int command) +void isis_bfd_circuit_cmd(struct isis_circuit *circuit) { switch (circuit->circ_type) { case CIRCUIT_T_BROADCAST: @@ -464,45 +167,18 @@ void isis_bfd_circuit_cmd(struct isis_circuit *circuit, int command) struct isis_adjacency *adj; for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) - bfd_adj_cmd(adj, command); + bfd_adj_cmd(adj); } break; case CIRCUIT_T_P2P: if (circuit->u.p2p.neighbor) - bfd_adj_cmd(circuit->u.p2p.neighbor, command); + bfd_adj_cmd(circuit->u.p2p.neighbor); break; default: break; } } -void isis_bfd_circuit_param_set(struct isis_circuit *circuit, uint32_t min_rx, - uint32_t min_tx, uint32_t detect_mult, - const char *profile, int defaults) -{ - int command = 0; - - bfd_set_param(&circuit->bfd_info, min_rx, min_tx, detect_mult, profile, - defaults, &command); - - if (command) - isis_bfd_circuit_cmd(circuit, command); -} - -#ifdef FABRICD -static int bfd_circuit_write_settings(struct isis_circuit *circuit, - struct vty *vty) -{ - struct bfd_info *bfd_info = circuit->bfd_info; - - if (!bfd_info) - return 0; - - vty_out(vty, " %s bfd\n", PROTO_NAME); - return 1; -} -#endif - static int bfd_handle_adj_ip_enabled(struct isis_adjacency *adj, int family) { @@ -515,7 +191,7 @@ static int bfd_handle_adj_ip_enabled(struct isis_adjacency *adj, int family) if (adj->adj_state != ISIS_ADJ_UP) return 0; - bfd_handle_adj_up(adj, ZEBRA_BFD_DEST_REGISTER); + bfd_handle_adj_up(adj); return 0; } @@ -535,26 +211,17 @@ static int bfd_handle_circuit_add_addr(struct isis_circuit *circuit) if (adj->adj_state != ISIS_ADJ_UP) continue; - bfd_handle_adj_up(adj, ZEBRA_BFD_DEST_REGISTER); + bfd_handle_adj_up(adj); } return 0; } -void isis_bfd_init(void) +void isis_bfd_init(struct thread_master *tm) { - bfd_gbl_init(); - - orig_zebra_connected = zclient->zebra_connected; - zclient->zebra_connected = isis_bfd_zebra_connected; - zclient->interface_bfd_dest_update = isis_bfd_interface_dest_update; - zclient->bfd_dest_replay = isis_bfd_nbr_replay; - hook_register(isis_adj_state_change_hook, - bfd_handle_adj_state_change); -#ifdef FABRICD - hook_register(isis_circuit_config_write, - bfd_circuit_write_settings); -#endif + bfd_protocol_integration_init(zclient, tm); + + hook_register(isis_adj_state_change_hook, bfd_handle_adj_state_change); hook_register(isis_adj_ip_enabled_hook, bfd_handle_adj_ip_enabled); hook_register(isis_circuit_add_addr_hook, bfd_handle_circuit_add_addr); } diff --git a/isisd/isis_bfd.h b/isisd/isis_bfd.h index 6ce630688c..1dec7ae20f 100644 --- a/isisd/isis_bfd.h +++ b/isisd/isis_bfd.h @@ -20,12 +20,10 @@ #define ISIS_BFD_H struct isis_circuit; +struct thread_master; -void isis_bfd_circuit_cmd(struct isis_circuit *circuit, int command); -void isis_bfd_circuit_param_set(struct isis_circuit *circuit, uint32_t min_rx, - uint32_t min_tx, uint32_t detect_mult, - const char *profile, int defaults); -void isis_bfd_init(void); +void isis_bfd_circuit_cmd(struct isis_circuit *circuit); +void isis_bfd_init(struct thread_master *tm); #endif diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 7fd9c07ed2..2c51f21d77 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -205,6 +205,7 @@ void isis_circuit_del(struct isis_circuit *circuit) isis_lfa_excluded_ifaces_clear(circuit, ISIS_LEVEL1); isis_lfa_excluded_ifaces_clear(circuit, ISIS_LEVEL2); + XFREE(MTYPE_TMP, circuit->bfd_config.profile); XFREE(MTYPE_ISIS_CIRCUIT, circuit->tag); /* and lastly the circuit itself */ @@ -1282,6 +1283,10 @@ static int isis_interface_config_write(struct vty *vty) circuit->passwd.passwd); write++; } + if (circuit->bfd_config.enabled) { + vty_out(vty, " " PROTO_NAME " bfd\n"); + write++; + } write += hook_call(isis_circuit_config_write, circuit, vty); } diff --git a/isisd/isis_circuit.h b/isisd/isis_circuit.h index 84c3ca3ff2..e7b7a2434d 100644 --- a/isisd/isis_circuit.h +++ b/isisd/isis_circuit.h @@ -70,8 +70,6 @@ struct isis_p2p_info { struct thread *t_send_p2p_hello; /* send P2P IIHs in this thread */ }; -struct bfd_info; - struct isis_circuit_arg { int level; struct isis_circuit *circuit; @@ -144,7 +142,10 @@ struct isis_circuit { #define ISIS_CIRCUIT_FLAPPED_AFTER_SPF 0x01 uint8_t flags; bool disable_threeway_adj; - struct bfd_info *bfd_info; + struct { + bool enabled; + char *profile; + } bfd_config; struct ldp_sync_info *ldp_sync_info; bool lfa_protection[ISIS_LEVELS]; bool rlfa_protection[ISIS_LEVELS]; diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index f316e0279c..14fa414c52 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -363,7 +363,7 @@ DEFPY_YANG(isis_bfd, */ DEFPY_YANG(isis_bfd_profile, isis_bfd_profile_cmd, - "[no] isis bfd profile WORD", + "[no] isis bfd profile BFDPROF$profile", NO_STR PROTO_HELP "Enable BFD support\n" "Use a pre-configured profile\n" @@ -378,8 +378,14 @@ DEFPY_YANG(isis_bfd_profile, return CMD_SUCCESS; } - nb_cli_enqueue_change(vty, "./frr-isisd:isis/bfd-monitoring/profile", - NB_OP_MODIFY, no ? NULL : profile); + if (no) + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/bfd-monitoring/profile", + NB_OP_DESTROY, NULL); + else + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/bfd-monitoring/profile", + NB_OP_MODIFY, profile); return nb_cli_apply_changes(vty, NULL); } @@ -387,18 +393,16 @@ DEFPY_YANG(isis_bfd_profile, void cli_show_ip_isis_bfd_monitoring(struct vty *vty, struct lyd_node *dnode, bool show_defaults) { - const char *profile; - - if (!yang_dnode_get_bool(dnode, "./enabled")) - vty_out(vty, " no"); - - vty_out(vty, " isis bfd\n"); - - if (yang_dnode_exists(dnode, "./profile")) { - profile = yang_dnode_get_string(dnode, "./profile"); - if (profile[0] != '\0') - vty_out(vty, " isis bfd profile %s\n", profile); + if (!yang_dnode_get_bool(dnode, "./enabled")) { + if (show_defaults) + vty_out(vty, " no isis bfd\n"); + } else { + vty_out(vty, " isis bfd\n"); } + + if (yang_dnode_exists(dnode, "./profile")) + vty_out(vty, " isis bfd profile %s\n", + yang_dnode_get_string(dnode, "./profile")); } /* diff --git a/isisd/isis_main.c b/isisd/isis_main.c index c03cedb187..c93bbb83af 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -269,7 +269,7 @@ int main(int argc, char **argv, char **envp) isis_global_instance_create(VRF_DEFAULT_NAME); isis_zebra_init(master, instance); - isis_bfd_init(); + isis_bfd_init(master); isis_ldp_sync_init(); fabricd_init(); diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c index 5ca2329dd3..87cd732e0b 100644 --- a/isisd/isis_nb_config.c +++ b/isisd/isis_nb_config.c @@ -2626,23 +2626,9 @@ void lib_interface_isis_bfd_monitoring_apply_finish( struct nb_cb_apply_finish_args *args) { struct isis_circuit *circuit; - bool enabled; - const char *profile = NULL; circuit = nb_running_get_entry(args->dnode, NULL, true); - enabled = yang_dnode_get_bool(args->dnode, "./enabled"); - - if (yang_dnode_exists(args->dnode, "./profile")) - profile = yang_dnode_get_string(args->dnode, "./profile"); - - if (enabled) { - isis_bfd_circuit_param_set(circuit, BFD_DEF_MIN_RX, - BFD_DEF_MIN_TX, BFD_DEF_DETECT_MULT, - profile, true); - } else { - isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_DEREGISTER); - bfd_info_free(&circuit->bfd_info); - } + isis_bfd_circuit_cmd(circuit); } /* @@ -2651,7 +2637,14 @@ void lib_interface_isis_bfd_monitoring_apply_finish( int lib_interface_isis_bfd_monitoring_enabled_modify( struct nb_cb_modify_args *args) { - /* Everything done in apply_finish */ + struct isis_circuit *circuit; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(args->dnode, NULL, true); + circuit->bfd_config.enabled = yang_dnode_get_bool(args->dnode, NULL); + return NB_OK; } @@ -2661,14 +2654,30 @@ int lib_interface_isis_bfd_monitoring_enabled_modify( int lib_interface_isis_bfd_monitoring_profile_modify( struct nb_cb_modify_args *args) { - /* Everything done in apply_finish */ + struct isis_circuit *circuit; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(args->dnode, NULL, true); + XFREE(MTYPE_TMP, circuit->bfd_config.profile); + circuit->bfd_config.profile = + XSTRDUP(MTYPE_TMP, yang_dnode_get_string(args->dnode, NULL)); + return NB_OK; } int lib_interface_isis_bfd_monitoring_profile_destroy( struct nb_cb_destroy_args *args) { - /* Everything done in apply_finish */ + struct isis_circuit *circuit; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(args->dnode, NULL, true); + XFREE(MTYPE_TMP, circuit->bfd_config.profile); + return NB_OK; } diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c index 7020b6efeb..a19fcc240f 100644 --- a/isisd/isis_vty_fabricd.c +++ b/isisd/isis_vty_fabricd.c @@ -319,13 +319,11 @@ DEFUN (isis_bfd, if (!circuit) return CMD_ERR_NO_MATCH; - if (circuit->bfd_info - && CHECK_FLAG(circuit->bfd_info->flags, BFD_FLAG_PARAM_CFG)) { + if (circuit->bfd_config.enabled) return CMD_SUCCESS; - } - isis_bfd_circuit_param_set(circuit, BFD_DEF_MIN_RX, BFD_DEF_MIN_TX, - BFD_DEF_DETECT_MULT, NULL, true); + circuit->bfd_config.enabled = true; + isis_bfd_circuit_cmd(circuit); return CMD_SUCCESS; } @@ -343,11 +341,12 @@ DEFUN (no_isis_bfd, if (!circuit) return CMD_ERR_NO_MATCH; - if (!circuit->bfd_info) + if (!circuit->bfd_config.enabled) return CMD_SUCCESS; - isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_DEREGISTER); - bfd_info_free(&circuit->bfd_info); + circuit->bfd_config.enabled = false; + isis_bfd_circuit_cmd(circuit); + return CMD_SUCCESS; } diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index 90959eb98c..4bd42ead86 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -37,6 +37,7 @@ #include "nexthop.h" #include "vrf.h" #include "libfrr.h" +#include "bfd.h" #include "isisd/isis_constants.h" #include "isisd/isis_common.h" @@ -730,6 +731,7 @@ static void isis_zebra_connected(struct zclient *zclient) zclient_register_opaque(zclient, LDP_RLFA_LABELS); zclient_register_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE); zclient_register_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE); + bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, VRF_DEFAULT); } /* diff --git a/isisd/isisd.c b/isisd/isisd.c index 37416fc1a4..cb3734bd41 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -41,6 +41,7 @@ #include "vrf.h" #include "spf_backoff.h" #include "lib/northbound_cli.h" +#include "bfd.h" #include "isisd/isis_constants.h" #include "isisd/isis_common.h" @@ -664,6 +665,8 @@ void isis_terminate() struct isis *isis; struct listnode *node, *nnode; + bfd_protocol_integration_set_shutdown(true); + if (listcount(im->isis) == 0) return; @@ -35,190 +35,88 @@ DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info"); -static int bfd_debug = 0; -static struct bfd_gbl bfd_gbl; - -/* - * bfd_gbl_init - Initialize the BFD global structure - */ -void bfd_gbl_init(void) -{ - memset(&bfd_gbl, 0, sizeof(struct bfd_gbl)); -} - -/* - * bfd_gbl_exit - Called when daemon exits - */ -void bfd_gbl_exit(void) -{ - SET_FLAG(bfd_gbl.flags, BFD_GBL_FLAG_IN_SHUTDOWN); -} - -/* - * bfd_info_create - Allocate the BFD information - */ -struct bfd_info *bfd_info_create(void) -{ - struct bfd_info *bfd_info; - - bfd_info = XCALLOC(MTYPE_BFD_INFO, sizeof(struct bfd_info)); - assert(bfd_info); - - bfd_info->status = BFD_STATUS_UNKNOWN; - bfd_info->type = BFD_TYPE_NOT_CONFIGURED; - bfd_info->last_update = 0; - return bfd_info; -} - -/* - * bfd_info_free - Free the BFD information. +/** + * BFD protocol integration configuration. */ -void bfd_info_free(struct bfd_info **bfd_info) -{ - XFREE(MTYPE_BFD_INFO, *bfd_info); -} -/* - * bfd_validate_param - Validate the BFD paramter information. - */ -int bfd_validate_param(struct vty *vty, const char *dm_str, const char *rx_str, - const char *tx_str, uint8_t *dm_val, uint32_t *rx_val, - uint32_t *tx_val) -{ - *dm_val = strtoul(dm_str, NULL, 10); - *rx_val = strtoul(rx_str, NULL, 10); - *tx_val = strtoul(tx_str, NULL, 10); - return CMD_SUCCESS; -} +/** Events definitions. */ +enum bfd_session_event { + /** Remove the BFD session configuration. */ + BSE_UNINSTALL, + /** Install the BFD session configuration. */ + BSE_INSTALL, +}; -/* - * bfd_set_param - Set the configured BFD paramter values +/** + * Data structure to do the necessary tricks to hide the BFD protocol + * integration internals. */ -void bfd_set_param(struct bfd_info **bfd_info, uint32_t min_rx, uint32_t min_tx, - uint8_t detect_mult, const char *profile, int defaults, - int *command) -{ - if (!*bfd_info) { - *bfd_info = bfd_info_create(); - *command = ZEBRA_BFD_DEST_REGISTER; - } else { - if (((*bfd_info)->required_min_rx != min_rx) - || ((*bfd_info)->desired_min_tx != min_tx) - || ((*bfd_info)->detect_mult != detect_mult) - || ((*bfd_info)->profile[0] == 0 && profile) - || ((*bfd_info)->profile[0] && profile == NULL) - || (profile && (*bfd_info)->profile[0] - && strcmp((*bfd_info)->profile, profile))) - *command = ZEBRA_BFD_DEST_UPDATE; - } - - if (*command) { - (*bfd_info)->required_min_rx = min_rx; - (*bfd_info)->desired_min_tx = min_tx; - (*bfd_info)->detect_mult = detect_mult; - if (profile) - strlcpy((*bfd_info)->profile, profile, - BFD_PROFILE_NAME_LEN); - else - (*bfd_info)->profile[0] = '\0'; - } - - if (!defaults) - SET_FLAG((*bfd_info)->flags, BFD_FLAG_PARAM_CFG); - else - UNSET_FLAG((*bfd_info)->flags, BFD_FLAG_PARAM_CFG); -} +struct bfd_session_params { + /** Contains the session parameters and more. */ + struct bfd_session_arg args; + /** Contains the session state. */ + struct bfd_session_status bss; + /** Protocol implementation status update callback. */ + bsp_status_update updatecb; + /** Protocol implementation custom data pointer. */ + void *arg; -/* - * bfd_peer_sendmsg - Format and send a peer register/Unregister - * command to Zebra to be forwarded to BFD - * - * DEPRECATED: use zclient_bfd_command instead - */ -void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info, - int family, void *dst_ip, void *src_ip, char *if_name, - int ttl, int multihop, int cbit, int command, - int set_flag, vrf_id_t vrf_id) -{ - struct bfd_session_arg args = {}; - size_t addrlen; + /** + * Next event. + * + * This variable controls what action to execute when the command batch + * finishes. Normally we'd use `thread_add_event` value, however since + * that function is going to be called multiple times and the value + * might be different we'll use this variable to keep track of it. + */ + enum bfd_session_event lastev; + /** + * BFD session configuration event. + * + * Multiple actions might be asked during a command batch (either via + * configuration load or northbound batch), so we'll use this to + * install/uninstall the BFD session parameters only once. + */ + struct thread *installev; - /* Individual reg/dereg messages are suppressed during shutdown. */ - if (CHECK_FLAG(bfd_gbl.flags, BFD_GBL_FLAG_IN_SHUTDOWN)) { - if (bfd_debug) - zlog_debug( - "%s: Suppressing BFD peer reg/dereg messages", - __func__); - return; - } + /** BFD session installation state. */ + bool installed; - /* Check socket. */ - if (!zclient || zclient->sock < 0) { - if (bfd_debug) - zlog_debug( - "%s: Can't send BFD peer register, Zebra client not established", - __func__); - return; - } + /** Global BFD paramaters list. */ + TAILQ_ENTRY(bfd_session_params) entry; +}; - /* Fill in all arguments. */ - args.ttl = ttl; - args.cbit = cbit; - args.family = family; - args.mhop = multihop; - args.vrf_id = vrf_id; - args.command = command; - args.set_flag = set_flag; - args.bfd_info = bfd_info; - if (args.bfd_info) { - args.min_rx = bfd_info->required_min_rx; - args.min_tx = bfd_info->desired_min_tx; - args.detection_multiplier = bfd_info->detect_mult; - if (bfd_info->profile[0]) { - args.profilelen = strlen(bfd_info->profile); - strlcpy(args.profile, bfd_info->profile, - sizeof(args.profile)); - } - } +struct bfd_sessions_global { + /** + * Global BFD session parameters list for (re)installation and update + * without code duplication among daemons. + */ + TAILQ_HEAD(bsplist, bfd_session_params) bsplist; - addrlen = family == AF_INET ? sizeof(struct in_addr) - : sizeof(struct in6_addr); - memcpy(&args.dst, dst_ip, addrlen); - if (src_ip) - memcpy(&args.src, src_ip, addrlen); + /** Pointer to FRR's event manager. */ + struct thread_master *tm; + /** Pointer to zebra client data structure. */ + struct zclient *zc; - if (if_name) - args.ifnamelen = - strlcpy(args.ifname, if_name, sizeof(args.ifname)); + /** Debugging state. */ + bool debugging; + /** Is shutting down? */ + bool shutting_down; +}; - zclient_bfd_command(zclient, &args); -} +/** Global configuration variable. */ +static struct bfd_sessions_global bsglobal; -/* - * bfd_get_command_dbg_str - Convert command to a debug string. - */ -const char *bfd_get_command_dbg_str(int command) -{ - switch (command) { - case ZEBRA_BFD_DEST_REGISTER: - return "Register"; - case ZEBRA_BFD_DEST_DEREGISTER: - return "Deregister"; - case ZEBRA_BFD_DEST_UPDATE: - return "Update"; - default: - return "Unknown"; - } -} +/** Global empty address for IPv4/IPv6. */ +static const struct in6_addr i6a_zero; /* * bfd_get_peer_info - Extract the Peer information for which the BFD session * went down from the message sent from Zebra to clients. */ -struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp, - struct prefix *sp, int *status, - int *remote_cbit, - vrf_id_t vrf_id) +static struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp, + struct prefix *sp, int *status, + int *remote_cbit, vrf_id_t vrf_id) { unsigned int ifindex; struct interface *ifp = NULL; @@ -243,7 +141,7 @@ struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp, if (ifindex != 0) { ifp = if_lookup_by_index(ifindex, vrf_id); if (ifp == NULL) { - if (bfd_debug) + if (bsglobal.debugging) zlog_debug( "zebra_interface_bfd_read: Can't find interface by ifindex: %d ", ifindex); @@ -322,96 +220,6 @@ static void bfd_last_update(time_t last_update, char *buf, size_t len) } /* - * bfd_show_param - Show the BFD parameter information. - */ -void bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, int bfd_tag, - int extra_space, bool use_json, json_object *json_obj) -{ - json_object *json_bfd = NULL; - - if (!bfd_info) - return; - - if (use_json) { - if (bfd_tag) - json_bfd = json_object_new_object(); - else - json_bfd = json_obj; - - json_object_int_add(json_bfd, "detectMultiplier", - bfd_info->detect_mult); - json_object_int_add(json_bfd, "rxMinInterval", - bfd_info->required_min_rx); - json_object_int_add(json_bfd, "txMinInterval", - bfd_info->desired_min_tx); - if (bfd_tag) - json_object_object_add(json_obj, "peerBfdInfo", - json_bfd); - } else { - vty_out(vty, - " %s%sDetect Multiplier: %d, Min Rx interval: %d, Min Tx interval: %d\n", - (extra_space) ? " " : "", (bfd_tag) ? "BFD: " : " ", - bfd_info->detect_mult, bfd_info->required_min_rx, - bfd_info->desired_min_tx); - } -} - -/* - * bfd_show_status - Show the BFD status information. - */ -static void bfd_show_status(struct vty *vty, struct bfd_info *bfd_info, - int bfd_tag, int extra_space, bool use_json, - json_object *json_bfd) -{ - char time_buf[32]; - - if (!bfd_info) - return; - - bfd_last_update(bfd_info->last_update, time_buf, 32); - if (use_json) { - json_object_string_add(json_bfd, "status", - bfd_get_status_str(bfd_info->status)); - json_object_string_add(json_bfd, "lastUpdate", time_buf); - } else { - vty_out(vty, " %s%sStatus: %s, Last update: %s\n", - (extra_space) ? " " : "", (bfd_tag) ? "BFD: " : " ", - bfd_get_status_str(bfd_info->status), time_buf); - } -} - -/* - * bfd_show_info - Show the BFD information. - */ -void bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, int multihop, - int extra_space, bool use_json, json_object *json_obj) -{ - json_object *json_bfd = NULL; - - if (!bfd_info) - return; - - if (use_json) { - json_bfd = json_object_new_object(); - if (multihop) - json_object_string_add(json_bfd, "type", "multi hop"); - else - json_object_string_add(json_bfd, "type", "single hop"); - } else { - vty_out(vty, " %sBFD: Type: %s\n", (extra_space) ? " " : "", - (multihop) ? "multi hop" : "single hop"); - } - - bfd_show_param(vty, bfd_info, 0, extra_space, use_json, json_bfd); - bfd_show_status(vty, bfd_info, 0, extra_space, use_json, json_bfd); - - if (use_json) - json_object_object_add(json_obj, "peerBfdInfo", json_bfd); - else - vty_out(vty, "\n"); -} - -/* * bfd_client_sendmsg - Format and send a client register * command to Zebra to be forwarded to BFD */ @@ -423,7 +231,7 @@ void bfd_client_sendmsg(struct zclient *zclient, int command, /* Check socket. */ if (!zclient || zclient->sock < 0) { - if (bfd_debug) + if (bsglobal.debugging) zlog_debug( "%s: Can't send BFD client register, Zebra client not established", __func__); @@ -441,7 +249,7 @@ void bfd_client_sendmsg(struct zclient *zclient, int command, ret = zclient_send_message(zclient); if (ret == ZCLIENT_SEND_FAILURE) { - if (bfd_debug) + if (bsglobal.debugging) zlog_debug( "bfd_client_sendmsg %ld: zclient_send_message() failed", (long)getpid()); @@ -457,8 +265,8 @@ int zclient_bfd_command(struct zclient *zc, struct bfd_session_arg *args) size_t addrlen; /* Individual reg/dereg messages are suppressed during shutdown. */ - if (CHECK_FLAG(bfd_gbl.flags, BFD_GBL_FLAG_IN_SHUTDOWN)) { - if (bfd_debug) + if (bsglobal.shutting_down) { + if (bsglobal.debugging) zlog_debug( "%s: Suppressing BFD peer reg/dereg messages", __func__); @@ -467,7 +275,7 @@ int zclient_bfd_command(struct zclient *zc, struct bfd_session_arg *args) /* Check socket. */ if (!zc || zc->sock < 0) { - if (bfd_debug) + if (bsglobal.debugging) zlog_debug("%s: zclient unavailable", __func__); return -1; } @@ -557,97 +365,14 @@ int zclient_bfd_command(struct zclient *zc, struct bfd_session_arg *args) /* Send message to zebra. */ if (zclient_send_message(zc) == ZCLIENT_SEND_FAILURE) { - if (bfd_debug) + if (bsglobal.debugging) zlog_debug("%s: zclient_send_message failed", __func__); return -1; } - /* Write registration indicator into data structure. */ - if (args->bfd_info && args->set_flag) { - if (args->command == ZEBRA_BFD_DEST_REGISTER) - SET_FLAG(args->bfd_info->flags, BFD_FLAG_BFD_REG); - else if (args->command == ZEBRA_BFD_DEST_DEREGISTER) - UNSET_FLAG(args->bfd_info->flags, BFD_FLAG_BFD_REG); - } - return 0; } -/** - * BFD protocol integration configuration. - */ - -/** Events definitions. */ -enum bfd_session_event { - /** Remove the BFD session configuration. */ - BSE_UNINSTALL, - /** Install the BFD session configuration. */ - BSE_INSTALL, -}; - -/** - * Data structure to do the necessary tricks to hide the BFD protocol - * integration internals. - */ -struct bfd_session_params { - /** Contains the session parameters and more. */ - struct bfd_session_arg args; - /** Contains the session state. */ - struct bfd_session_status bss; - /** Protocol implementation status update callback. */ - bsp_status_update updatecb; - /** Protocol implementation custom data pointer. */ - void *arg; - - /** - * Next event. - * - * This variable controls what action to execute when the command batch - * finishes. Normally we'd use `thread_add_event` value, however since - * that function is going to be called multiple times and the value - * might be different we'll use this variable to keep track of it. - */ - enum bfd_session_event lastev; - /** - * BFD session configuration event. - * - * Multiple actions might be asked during a command batch (either via - * configuration load or northbound batch), so we'll use this to - * install/uninstall the BFD session parameters only once. - */ - struct thread *installev; - - /** BFD session installation state. */ - bool installed; - - /** Global BFD paramaters list. */ - TAILQ_ENTRY(bfd_session_params) entry; -}; - -struct bfd_sessions_global { - /** - * Global BFD session parameters list for (re)installation and update - * without code duplication among daemons. - */ - TAILQ_HEAD(bsplist, bfd_session_params) bsplist; - - /** Pointer to FRR's event manager. */ - struct thread_master *tm; - /** Pointer to zebra client data structure. */ - struct zclient *zc; - - /** Debugging state. */ - bool debugging; - /** Is shutting down? */ - bool shutting_down; -}; - -/** Global configuration variable. */ -static struct bfd_sessions_global bsglobal; - -/** Global empty address for IPv4/IPv6. */ -static const struct in6_addr i6a_zero; - struct bfd_session_params *bfd_sess_new(bsp_status_update updatecb, void *arg) { struct bfd_session_params *bsp; @@ -40,17 +40,6 @@ extern "C" { #define BFD_MIN_DETECT_MULT 2 #define BFD_MAX_DETECT_MULT 255 -#define BFD_GBL_FLAG_IN_SHUTDOWN (1 << 0) /* The daemon in shutdown */ -struct bfd_gbl { - uint16_t flags; -}; - -#define BFD_FLAG_PARAM_CFG (1 << 0) /* parameters have been configured */ -#define BFD_FLAG_BFD_REG (1 << 1) /* Peer registered with BFD */ -#define BFD_FLAG_BFD_TYPE_MULTIHOP (1 << 2) /* Peer registered with BFD as multihop */ -#define BFD_FLAG_BFD_CBIT_ON (1 << 3) /* Peer registered with CBIT set to on */ -#define BFD_FLAG_BFD_CHECK_CONTROLPLANE (1 << 4) /* BFD and controlplane daemon are linked */ - #define BFD_STATUS_UNKNOWN (1 << 0) /* BFD session status never received */ #define BFD_STATUS_DOWN (1 << 1) /* BFD session status is down */ #define BFD_STATUS_UP (1 << 2) /* BFD session status is up */ @@ -58,72 +47,11 @@ struct bfd_gbl { #define BFD_PROFILE_NAME_LEN 64 -#define BFD_SET_CLIENT_STATUS(current_status, new_status) \ - do { \ - (current_status) = \ - (((new_status) == BFD_STATUS_ADMIN_DOWN) ? \ - BFD_STATUS_DOWN : (new_status));\ - } while (0) - -enum bfd_sess_type { - BFD_TYPE_NOT_CONFIGURED, - BFD_TYPE_SINGLEHOP, - BFD_TYPE_MULTIHOP -}; - -struct bfd_info { - uint16_t flags; - uint8_t detect_mult; - uint32_t desired_min_tx; - uint32_t required_min_rx; - time_t last_update; - uint8_t status; - enum bfd_sess_type type; - char profile[BFD_PROFILE_NAME_LEN]; -}; - -extern struct bfd_info *bfd_info_create(void); - -extern void bfd_info_free(struct bfd_info **bfd_info); - -extern int bfd_validate_param(struct vty *vty, const char *dm_str, - const char *rx_str, const char *tx_str, - uint8_t *dm_val, uint32_t *rx_val, - uint32_t *tx_val); - -extern void bfd_set_param(struct bfd_info **bfd_info, uint32_t min_rx, - uint32_t min_tx, uint8_t detect_mult, - const char *profile, int defaults, int *command); -extern void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info, - int family, void *dst_ip, void *src_ip, - char *if_name, int ttl, int multihop, int cbit, - int command, int set_flag, vrf_id_t vrf_id); - -extern const char *bfd_get_command_dbg_str(int command); - -extern struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp, - struct prefix *sp, int *status, - int *remote_cbit, - vrf_id_t vrf_id); - const char *bfd_get_status_str(int status); -extern void bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, - int bfd_tag, int extra_space, bool use_json, - json_object *json_obj); - -extern void bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, - int multihop, int extra_space, bool use_json, - json_object *json_obj); - extern void bfd_client_sendmsg(struct zclient *zclient, int command, vrf_id_t vrf_id); -extern void bfd_gbl_init(void); - -extern void bfd_gbl_exit(void); - - /* * BFD new API. */ @@ -519,12 +447,6 @@ struct bfd_session_arg { uint32_t min_tx; /** Detection multiplier. */ uint32_t detection_multiplier; - - /** BFD client information output. */ - struct bfd_info *bfd_info; - - /** Write registration indicator. */ - uint8_t set_flag; }; /** diff --git a/lib/filter_cli.c b/lib/filter_cli.c index e147ed5639..f030ce1b33 100644 --- a/lib/filter_cli.c +++ b/lib/filter_cli.c @@ -1360,14 +1360,31 @@ DEFPY_YANG( nb_cli_enqueue_change(vty, "./ipv4-prefix", NB_OP_MODIFY, prefix_str); - if (ge_str) + if (ge_str) { nb_cli_enqueue_change( vty, "./ipv4-prefix-length-greater-or-equal", NB_OP_MODIFY, ge_str); - if (le_str) + } else { + /* + * Remove old ge if not being modified + */ + nb_cli_enqueue_change( + vty, "./ipv4-prefix-length-greater-or-equal", + NB_OP_DESTROY, NULL); + } + + if (le_str) { nb_cli_enqueue_change( vty, "./ipv4-prefix-length-lesser-or-equal", NB_OP_MODIFY, le_str); + } else { + /* + * Remove old le if not being modified + */ + nb_cli_enqueue_change( + vty, "./ipv4-prefix-length-lesser-or-equal", + NB_OP_DESTROY, NULL); + } } else { nb_cli_enqueue_change(vty, "./any", NB_OP_CREATE, NULL); } @@ -1561,14 +1578,31 @@ DEFPY_YANG( nb_cli_enqueue_change(vty, "./ipv6-prefix", NB_OP_MODIFY, prefix_str); - if (ge_str) + if (ge_str) { nb_cli_enqueue_change( vty, "./ipv6-prefix-length-greater-or-equal", NB_OP_MODIFY, ge_str); - if (le_str) + } else { + /* + * Remove old ge if not being modified + */ + nb_cli_enqueue_change( + vty, "./ipv6-prefix-length-greater-or-equal", + NB_OP_DESTROY, NULL); + } + + if (le_str) { nb_cli_enqueue_change( vty, "./ipv6-prefix-length-lesser-or-equal", NB_OP_MODIFY, le_str); + } else { + /* + * Remove old le if not being modified + */ + nb_cli_enqueue_change( + vty, "./ipv6-prefix-length-lesser-or-equal", + NB_OP_DESTROY, NULL); + } } else { nb_cli_enqueue_change(vty, "./any", NB_OP_CREATE, NULL); } diff --git a/lib/nexthop.c b/lib/nexthop.c index 8439398149..0ac6c0ae1b 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -62,7 +62,8 @@ static int _nexthop_labels_cmp(const struct nexthop *nh1, if (nhl1->num_labels < nhl2->num_labels) return -1; - return memcmp(nhl1->label, nhl2->label, nhl1->num_labels); + return memcmp(nhl1->label, nhl2->label, + (nhl1->num_labels * sizeof(mpls_label_t))); } int nexthop_g_addr_cmp(enum nexthop_types_t type, const union g_addr *addr1, @@ -203,6 +204,105 @@ int nexthop_cmp(const struct nexthop *next1, const struct nexthop *next2) } /* + * More-limited comparison function used to detect duplicate + * nexthops. This is used in places where we don't need the full + * comparison of 'nexthop_cmp()'. + */ +int nexthop_cmp_basic(const struct nexthop *nh1, + const struct nexthop *nh2) +{ + int ret = 0; + const struct mpls_label_stack *nhl1 = NULL; + const struct mpls_label_stack *nhl2 = NULL; + + if (nh1 == NULL && nh2 == NULL) + return 0; + + if (nh1 && !nh2) + return 1; + + if (!nh1 && nh2) + return -1; + + if (nh1->vrf_id < nh2->vrf_id) + return -1; + + if (nh1->vrf_id > nh2->vrf_id) + return 1; + + if (nh1->type < nh2->type) + return -1; + + if (nh1->type > nh2->type) + return 1; + + if (nh1->weight < nh2->weight) + return -1; + + if (nh1->weight > nh2->weight) + return 1; + + switch (nh1->type) { + case NEXTHOP_TYPE_IPV4: + case NEXTHOP_TYPE_IPV6: + ret = nexthop_g_addr_cmp(nh1->type, &nh1->gate, &nh2->gate); + if (ret != 0) + return ret; + break; + case NEXTHOP_TYPE_IPV4_IFINDEX: + case NEXTHOP_TYPE_IPV6_IFINDEX: + ret = nexthop_g_addr_cmp(nh1->type, &nh1->gate, &nh2->gate); + if (ret != 0) + return ret; + /* Intentional Fall-Through */ + case NEXTHOP_TYPE_IFINDEX: + if (nh1->ifindex < nh2->ifindex) + return -1; + + if (nh1->ifindex > nh2->ifindex) + return 1; + break; + case NEXTHOP_TYPE_BLACKHOLE: + if (nh1->bh_type < nh2->bh_type) + return -1; + + if (nh1->bh_type > nh2->bh_type) + return 1; + break; + } + + /* Compare source addr */ + ret = nexthop_g_addr_cmp(nh1->type, &nh1->src, &nh2->src); + if (ret != 0) + goto done; + + nhl1 = nh1->nh_label; + nhl2 = nh2->nh_label; + + /* No labels is a match */ + if (!nhl1 && !nhl2) + return 0; + + if (nhl1 && !nhl2) + return 1; + + if (nhl2 && !nhl1) + return -1; + + if (nhl1->num_labels > nhl2->num_labels) + return 1; + + if (nhl1->num_labels < nhl2->num_labels) + return -1; + + ret = memcmp(nhl1->label, nhl2->label, + (nhl1->num_labels * sizeof(mpls_label_t))); + +done: + return ret; +} + +/* * nexthop_type_to_str */ const char *nexthop_type_to_str(enum nexthop_types_t nh_type) diff --git a/lib/nexthop.h b/lib/nexthop.h index f1ad195cf4..d6ea83cf06 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -207,6 +207,11 @@ extern int nexthop_g_addr_cmp(enum nexthop_types_t type, const union g_addr *addr1, const union g_addr *addr2); +/* More-limited comparison function used to detect duplicate nexthops. + * Returns -1, 0, 1 + */ +int nexthop_cmp_basic(const struct nexthop *nh1, const struct nexthop *nh2); + extern const char *nexthop_type_to_str(enum nexthop_types_t nh_type); extern bool nexthop_labels_match(const struct nexthop *nh1, const struct nexthop *nh2); diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 27d4f0755e..286e642781 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -389,6 +389,8 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route, zlog_debug( "prefix %pFX was denied by export list", &route->prefix); + ospf6_abr_delete_route(route, summary, + summary_table, old); return 0; } } @@ -401,6 +403,9 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route, zlog_debug( "prefix %pFX was denied by filter-list out", &route->prefix); + ospf6_abr_delete_route(route, summary, summary_table, + old); + return 0; } @@ -1075,7 +1080,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa) == FILTER_DENY) { if (is_debug) zlog_debug( - "Prefix was denied by import-list"); + "Prefix %pFX was denied by import-list", + &prefix); if (old) ospf6_route_remove(old, table); return; @@ -1087,7 +1093,9 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa) if (prefix_list_apply(PREFIX_LIST_IN(oa), &prefix) != PREFIX_PERMIT) { if (is_debug) - zlog_debug("Prefix was denied by prefix-list"); + zlog_debug( + "Prefix %pFX was denied by prefix-list in", + &prefix); if (old) ospf6_route_remove(old, table); return; @@ -1287,6 +1295,21 @@ void ospf6_abr_reimport(struct ospf6_area *oa) ospf6_abr_examin_summary(lsa, oa); } +/* export filter removed so determine if we should reoriginate summary LSAs */ +void ospf6_abr_reexport(struct ospf6_area *oa) +{ + struct ospf6_route *route; + + /* if not a ABR return success */ + if (!ospf6_is_router_abr(oa->ospf6)) + return; + + /* Redo summaries if required */ + for (route = ospf6_route_head(oa->ospf6->route_table); route; + route = ospf6_route_next(route)) + ospf6_abr_originate_summary_to_area(route, oa); +} + void ospf6_abr_prefix_resummarize(struct ospf6 *o) { struct ospf6_route *route; diff --git a/ospf6d/ospf6_abr.h b/ospf6d/ospf6_abr.h index 25a73f9203..6a912ac630 100644 --- a/ospf6d/ospf6_abr.h +++ b/ospf6d/ospf6_abr.h @@ -73,6 +73,7 @@ extern void ospf6_abr_examin_brouter(uint32_t router_id, struct ospf6_route *route, struct ospf6 *ospf6); extern void ospf6_abr_reimport(struct ospf6_area *oa); +extern void ospf6_abr_reexport(struct ospf6_area *oa); extern void ospf6_abr_range_reset_cost(struct ospf6 *ospf6); extern void ospf6_abr_prefix_resummarize(struct ospf6 *ospf6); @@ -86,5 +87,6 @@ extern void ospf6_abr_old_path_update(struct ospf6_route *old_route, struct ospf6_route *route, struct ospf6_route_table *table); extern void ospf6_abr_init(void); +extern void ospf6_abr_reexport(struct ospf6_area *oa); #endif /*OSPF6_ABR_H*/ diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index c38ce09a27..d65e40279d 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -661,7 +661,9 @@ DEFUN (area_filter_list, XFREE(MTYPE_OSPF6_PLISTNAME, PREFIX_NAME_OUT(area)); PREFIX_NAME_OUT(area) = XSTRDUP(MTYPE_OSPF6_PLISTNAME, plistname); - ospf6_abr_enable_area(area); + + /* Redo summaries if required */ + ospf6_abr_reexport(area); } return CMD_SUCCESS; @@ -703,12 +705,32 @@ DEFUN (no_area_filter_list, return CMD_SUCCESS; XFREE(MTYPE_OSPF6_PLISTNAME, PREFIX_NAME_OUT(area)); - ospf6_abr_enable_area(area); + PREFIX_LIST_OUT(area) = NULL; + ospf6_abr_reexport(area); } return CMD_SUCCESS; } +void ospf6_filter_update(struct access_list *access) +{ + struct ospf6_area *oa; + struct listnode *n, *node, *nnode; + struct ospf6 *ospf6; + + for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) { + for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, n, oa)) { + if (IMPORT_NAME(oa) + && strcmp(IMPORT_NAME(oa), access->name) == 0) + ospf6_abr_reimport(oa); + + if (EXPORT_NAME(oa) + && strcmp(EXPORT_NAME(oa), access->name) == 0) + ospf6_abr_reexport(oa); + } + } +} + void ospf6_area_plist_update(struct prefix_list *plist, int add) { struct listnode *node, *nnode; @@ -724,11 +746,15 @@ void ospf6_area_plist_update(struct prefix_list *plist, int add) for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) { for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, n, oa)) { if (PREFIX_NAME_IN(oa) - && !strcmp(PREFIX_NAME_IN(oa), name)) + && !strcmp(PREFIX_NAME_IN(oa), name)) { PREFIX_LIST_IN(oa) = add ? plist : NULL; + ospf6_abr_reexport(oa); + } if (PREFIX_NAME_OUT(oa) - && !strcmp(PREFIX_NAME_OUT(oa), name)) + && !strcmp(PREFIX_NAME_OUT(oa), name)) { PREFIX_LIST_OUT(oa) = add ? plist : NULL; + ospf6_abr_reexport(oa); + } } } } @@ -818,7 +844,9 @@ DEFUN (area_export_list, free(EXPORT_NAME(area)); EXPORT_NAME(area) = strdup(argv[idx_name]->arg); - ospf6_abr_enable_area(area); + + /* Redo summaries if required */ + ospf6_abr_reexport(area); return CMD_SUCCESS; } @@ -846,7 +874,7 @@ DEFUN (no_area_export_list, free(EXPORT_NAME(area)); EXPORT_NAME(area) = NULL; - ospf6_abr_enable_area(area); + ospf6_abr_reexport(area); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_area.h b/ospf6d/ospf6_area.h index 8a58b2a50e..761fe75f73 100644 --- a/ospf6d/ospf6_area.h +++ b/ospf6d/ospf6_area.h @@ -148,6 +148,7 @@ extern void ospf6_area_show(struct vty *, struct ospf6_area *, json_object *json_areas, bool use_json); extern void ospf6_area_plist_update(struct prefix_list *plist, int add); +extern void ospf6_filter_update(struct access_list *access); extern void ospf6_area_config_write(struct vty *vty, struct ospf6 *ospf6); extern void ospf6_area_init(void); struct ospf6_interface; diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c index 5f4815fec1..0fa6f8c779 100644 --- a/ospf6d/ospf6_flood.c +++ b/ospf6d/ospf6_flood.c @@ -381,7 +381,8 @@ void ospf6_flood_interface(struct ospf6_neighbor *from, struct ospf6_lsa *lsa, } else { /* (d) add retrans-list, schedule retransmission */ if (is_debug) - zlog_debug("Add retrans-list of this neighbor"); + zlog_debug("Add retrans-list of neighbor %s ", + on->name); ospf6_increment_retrans_count(lsa); ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list); thread_add_timer(master, ospf6_lsupdate_send_neighbor, @@ -395,7 +396,8 @@ void ospf6_flood_interface(struct ospf6_neighbor *from, struct ospf6_lsa *lsa, if (retrans_added == 0) { if (is_debug) zlog_debug( - "No retransmission scheduled, next interface"); + "No retransmission scheduled, next interface %s", + oi->interface->name); return; } diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index adff76ec41..61a438b04a 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -1672,7 +1672,7 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa, if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) zlog_debug( - "%s: route %pFX %p with final effective paths %u nh%u", + "%s: route %pFX %p with final effective paths %u nh %u", __func__, &route->prefix, (void *)old_route, old_route->paths diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 5ffcf8c2fa..e233611690 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -87,6 +87,8 @@ static void __attribute__((noreturn)) ospf6_exit(int status) frr_early_fini(); + bfd_protocol_integration_set_shutdown(true); + for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) { vrf = vrf_lookup_by_id(ospf6->vrf_id); ospf6_delete(ospf6); @@ -96,9 +98,6 @@ static void __attribute__((noreturn)) ospf6_exit(int status) ospf6_interface_delete(ifp->info); } - bfd_gbl_exit(); - - ospf6_message_terminate(); ospf6_asbr_terminate(); ospf6_lsa_terminate(); diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index a2f27ec3b2..da8c695f65 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -25,6 +25,7 @@ #include "vty.h" #include "command.h" #include "plist.h" +#include "filter.h" #include "ospf6_proto.h" #include "ospf6_top.h" @@ -1398,8 +1399,11 @@ void ospf6_init(struct thread_master *master) ospf6_asbr_init(); ospf6_abr_init(); + /* initialize hooks for modifying filter rules */ prefix_list_add_hook(ospf6_plist_add); prefix_list_delete_hook(ospf6_plist_del); + access_list_add_hook(ospf6_filter_update); + access_list_delete_hook(ospf6_filter_update); ospf6_bfd_init(); install_node(&debug_node); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 57ef6029ad..50943c4ccf 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -9111,14 +9111,13 @@ DEFUN (ospf_redistribute_source, int metric = -1; struct ospf_redist *red; int idx = 0; + bool update = false; /* Get distribute source. */ source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); if (source < 0) return CMD_WARNING_CONFIG_FAILED; - red = ospf_redist_add(ospf, source, 0); - /* Get metric value. */ if (argv_find(argv, argc, "(0-16777214)", &idx)) { if (!str2metric(argv[idx]->arg, &metric)) @@ -9131,13 +9130,25 @@ DEFUN (ospf_redistribute_source, return CMD_WARNING_CONFIG_FAILED; } idx = 1; + + red = ospf_redist_lookup(ospf, source, 0); + if (!red) + red = ospf_redist_add(ospf, source, 0); + else + update = true; + /* Get route-map */ if (argv_find(argv, argc, "WORD", &idx)) { ospf_routemap_set(red, argv[idx]->arg); } else ospf_routemap_unset(red); - return ospf_redistribute_set(ospf, source, 0, type, metric); + if (update) + return ospf_redistribute_update(ospf, red, source, 0, type, + metric); + else + return ospf_redistribute_set(ospf, red, source, 0, type, + metric); } DEFUN (no_ospf_redistribute_source, @@ -9195,6 +9206,7 @@ DEFUN (ospf_redistribute_instance_source, int metric = -1; unsigned short instance; struct ospf_redist *red; + bool update = false; source = proto_redistnum(AFI_IP, argv[idx_ospf_table]->text); @@ -9227,7 +9239,11 @@ DEFUN (ospf_redistribute_instance_source, if (!str2metric_type(argv[idx + 1]->arg, &type)) return CMD_WARNING_CONFIG_FAILED; - red = ospf_redist_add(ospf, source, instance); + red = ospf_redist_lookup(ospf, source, instance); + if (!red) + red = ospf_redist_add(ospf, source, instance); + else + update = true; idx = 3; if (argv_find(argv, argc, "route-map", &idx)) @@ -9235,7 +9251,12 @@ DEFUN (ospf_redistribute_instance_source, else ospf_routemap_unset(red); - return ospf_redistribute_set(ospf, source, instance, type, metric); + if (update) + return ospf_redistribute_update(ospf, red, source, instance, + type, metric); + else + return ospf_redistribute_set(ospf, red, source, instance, type, + metric); } DEFUN (no_ospf_redistribute_instance_source, diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index f198995dfa..5853b506f8 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -774,45 +774,36 @@ int ospf_is_type_redistributed(struct ospf *ospf, int type, ospf->vrf_id)))); } -int ospf_redistribute_set(struct ospf *ospf, int type, unsigned short instance, - int mtype, int mvalue) +int ospf_redistribute_update(struct ospf *ospf, struct ospf_redist *red, + int type, unsigned short instance, int mtype, + int mvalue) { int force = 0; - struct ospf_redist *red; - - red = ospf_redist_lookup(ospf, type, instance); - if (red == NULL) { - zlog_err( - "Redistribute[%s][%d]: Lookup failed Type[%d] , Metric[%d]", - ospf_redist_string(type), instance, - metric_type(ospf, type, instance), - metric_value(ospf, type, instance)); - return CMD_WARNING_CONFIG_FAILED; + if (mtype != red->dmetric.type) { + red->dmetric.type = mtype; + force = LSA_REFRESH_FORCE; + } + if (mvalue != red->dmetric.value) { + red->dmetric.value = mvalue; + force = LSA_REFRESH_FORCE; } - if (ospf_is_type_redistributed(ospf, type, instance)) { - if (mtype != red->dmetric.type) { - red->dmetric.type = mtype; - force = LSA_REFRESH_FORCE; - } - if (mvalue != red->dmetric.value) { - red->dmetric.value = mvalue; - force = LSA_REFRESH_FORCE; - } - - ospf_external_lsa_refresh_type(ospf, type, instance, force); + ospf_external_lsa_refresh_type(ospf, type, instance, force); - if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) - zlog_debug( - "Redistribute[%s][%d]: Refresh Type[%d], Metric[%d]", - ospf_redist_string(type), instance, - metric_type(ospf, type, instance), - metric_value(ospf, type, instance)); + if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) + zlog_debug( + "Redistribute[%s][%d]: Refresh Type[%d], Metric[%d]", + ospf_redist_string(type), instance, + metric_type(ospf, type, instance), + metric_value(ospf, type, instance)); - return CMD_SUCCESS; - } + return CMD_SUCCESS; +} +int ospf_redistribute_set(struct ospf *ospf, struct ospf_redist *red, int type, + unsigned short instance, int mtype, int mvalue) +{ red->dmetric.type = mtype; red->dmetric.value = mvalue; @@ -839,9 +830,6 @@ int ospf_redistribute_unset(struct ospf *ospf, int type, if (type == zclient->redist_default && instance == zclient->instance) return CMD_SUCCESS; - if (!ospf_is_type_redistributed(ospf, type, instance)) - return CMD_SUCCESS; - zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, instance, ospf->vrf_id); diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h index bdc8af0402..3f4edfa29c 100644 --- a/ospfd/ospf_zebra.h +++ b/ospfd/ospf_zebra.h @@ -78,10 +78,12 @@ extern struct ospf_redist *ospf_redist_add(struct ospf *, uint8_t, unsigned short); extern void ospf_redist_del(struct ospf *, uint8_t, unsigned short); -extern int ospf_redistribute_set(struct ospf *, int, unsigned short, int, int); +extern int ospf_redistribute_update(struct ospf *, struct ospf_redist *, int, + unsigned short, int, int); +extern int ospf_redistribute_set(struct ospf *, struct ospf_redist *, int, + unsigned short, int, int); extern int ospf_redistribute_unset(struct ospf *, int, unsigned short); extern int ospf_redistribute_default_set(struct ospf *, int, int, int); -extern int ospf_redistribute_default_unset(struct ospf *); extern int ospf_distribute_list_out_set(struct ospf *, int, const char *); extern int ospf_distribute_list_out_unset(struct ospf *, int, const char *); extern void ospf_routemap_set(struct ospf_redist *, const char *); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index faec868b2a..cc1404e5e9 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -648,7 +648,6 @@ void ospf_terminate(void) if (listcount(om->ospf) == 0) goto done; - bfd_gbl_exit(); for (ALL_LIST_ELEMENTS(om->ospf, node, nnode, ospf)) ospf_finish(ospf); @@ -697,6 +696,7 @@ static void ospf_finish_final(struct ospf *ospf) struct ospf_area *area; struct ospf_vl_data *vl_data; struct listnode *node, *nnode; + struct ospf_redist *red; int i; QOBJ_UNREG(ospf); @@ -710,7 +710,6 @@ static void ospf_finish_final(struct ospf *ospf) /* Unregister redistribution */ for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { struct list *red_list; - struct ospf_redist *red; red_list = ospf->redist[i]; if (!red_list) @@ -721,7 +720,12 @@ static void ospf_finish_final(struct ospf *ospf) ospf_redist_del(ospf, i, red->instance); } } - ospf_redistribute_default_set(ospf, DEFAULT_ORIGINATE_NONE, 0, 0); + red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); + if (red) { + ospf_routemap_unset(red); + ospf_redist_del(ospf, DEFAULT_ROUTE, 0); + ospf_redistribute_default_set(ospf, DEFAULT_ORIGINATE_NONE, 0, 0); + } for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) ospf_remove_vls_through_area(ospf, area); @@ -2158,7 +2162,7 @@ static int ospf_vrf_delete(struct vrf *vrf) return 0; } -static void ospf_set_redist_vrf_bitmaps(struct ospf *ospf) +static void ospf_set_redist_vrf_bitmaps(struct ospf *ospf, bool set) { int type; struct list *red_list; @@ -2171,7 +2175,12 @@ static void ospf_set_redist_vrf_bitmaps(struct ospf *ospf) zlog_debug( "%s: setting redist vrf %d bitmap for type %d", __func__, ospf->vrf_id, type); - vrf_bitmap_set(zclient->redist[AFI_IP][type], ospf->vrf_id); + if (set) + vrf_bitmap_set(zclient->redist[AFI_IP][type], + ospf->vrf_id); + else + vrf_bitmap_unset(zclient->redist[AFI_IP][type], + ospf->vrf_id); } } @@ -2201,18 +2210,12 @@ static int ospf_vrf_enable(struct vrf *vrf) __func__, vrf->name, ospf->vrf_id, old_vrf_id); if (old_vrf_id != ospf->vrf_id) { - frr_with_privs(&ospfd_privs) { - /* stop zebra redist to us for old vrf */ - zclient_send_dereg_requests(zclient, - old_vrf_id); - - ospf_set_redist_vrf_bitmaps(ospf); + ospf_set_redist_vrf_bitmaps(ospf, true); - /* start zebra redist to us for new vrf */ - ospf_zebra_vrf_register(ospf); + /* start zebra redist to us for new vrf */ + ospf_zebra_vrf_register(ospf); - ret = ospf_sock_init(ospf); - } + ret = ospf_sock_init(ospf); if (ret < 0 || ospf->fd <= 0) return 0; thread_add_read(master, ospf_read, ospf, ospf->fd, @@ -2242,6 +2245,10 @@ static int ospf_vrf_disable(struct vrf *vrf) if (ospf) { old_vrf_id = ospf->vrf_id; + ospf_zebra_vrf_deregister(ospf); + + ospf_set_redist_vrf_bitmaps(ospf, false); + /* We have instance configured, unlink * from VRF and make it "down". */ diff --git a/pceplib/test/pcep_msg_messages_test.c b/pceplib/test/pcep_msg_messages_test.c index 61fa94047b..6ae449acd1 100644 --- a/pceplib/test/pcep_msg_messages_test.c +++ b/pceplib/test/pcep_msg_messages_test.c @@ -26,6 +26,7 @@ #endif #include <stdlib.h> +#include <assert.h> #include <CUnit/CUnit.h> @@ -79,13 +80,16 @@ void test_pcep_msg_create_open() pcep_msg_create_open(keepalive, deadtimer, sid); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 1); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH + pcep_object_get_length(PCEP_OBJ_CLASS_OPEN, PCEP_OBJ_TYPE_OPEN)); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_OPEN); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -122,6 +126,7 @@ void test_pcep_msg_create_request() CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); CU_ASSERT_EQUAL(message->obj_list->num_entries, 2); @@ -130,6 +135,7 @@ void test_pcep_msg_create_request() MESSAGE_HEADER_LENGTH + pcep_object_get_length_by_hdr(&rp_obj->header) + pcep_object_get_length_by_hdr(&ipv4_obj->header)); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_PCREQ); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -144,14 +150,17 @@ void test_pcep_msg_create_request() CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 2); CU_ASSERT_EQUAL( message->encoded_message_length, MESSAGE_HEADER_LENGTH + pcep_object_get_length_by_hdr(&rp_obj->header) + pcep_object_get_length_by_hdr(&ipv6_obj->header)); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_PCREQ); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -169,8 +178,10 @@ void test_pcep_msg_create_request() CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 3); CU_ASSERT_EQUAL( message->encoded_message_length, @@ -179,6 +190,7 @@ void test_pcep_msg_create_request() + pcep_object_get_length_by_hdr(&ipv4_obj->header) + pcep_object_get_length_by_hdr( &bandwidth_obj->header)); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_PCREQ); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -203,13 +215,16 @@ void test_pcep_msg_create_reply_nopath() struct pcep_message *message = pcep_msg_create_reply(rp_obj, obj_list); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 2); CU_ASSERT_EQUAL(message->encoded_message_length, (MESSAGE_HEADER_LENGTH + pcep_object_get_length_by_hdr(&rp_obj->header) + pcep_object_get_length_by_hdr(&nopath_obj->header))); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_PCREP); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -224,10 +239,12 @@ void test_pcep_msg_create_reply() CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); CU_ASSERT_EQUAL(message->obj_list->num_entries, 0); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_PCREP); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -249,6 +266,7 @@ void test_pcep_msg_create_reply() pcep_encode_message(message, versioning); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 2); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH @@ -270,13 +288,16 @@ void test_pcep_msg_create_close() struct pcep_message *message = pcep_msg_create_close(reason); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 1); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH + pcep_object_get_length(PCEP_OBJ_CLASS_CLOSE, PCEP_OBJ_TYPE_CLOSE)); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_CLOSE); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -285,6 +306,7 @@ void test_pcep_msg_create_close() * are verified in pcep-objects-test.c */ struct pcep_object_close *close_obj = (struct pcep_object_close *)message->obj_list->head->data; + assert(close_obj != NULL); CU_ASSERT_EQUAL(close_obj->header.object_class, PCEP_OBJ_CLASS_CLOSE); CU_ASSERT_EQUAL(close_obj->header.object_type, PCEP_OBJ_TYPE_CLOSE); CU_ASSERT_EQUAL(close_obj->reason, reason); @@ -301,13 +323,16 @@ void test_pcep_msg_create_error() pcep_msg_create_error(error_type, error_value); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 1); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH + pcep_object_get_length(PCEP_OBJ_CLASS_ERROR, PCEP_OBJ_TYPE_ERROR)); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_ERROR); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -330,10 +355,13 @@ void test_pcep_msg_create_keepalive() struct pcep_message *message = pcep_msg_create_keepalive(); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 0); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_KEEPALIVE); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -355,12 +383,15 @@ void test_pcep_msg_create_report() message = pcep_msg_create_report(obj_list); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 1); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH + lsp->header.encoded_object_length); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_REPORT); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -405,14 +436,17 @@ void test_pcep_msg_create_update() message = pcep_msg_create_update(obj_list); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 3); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH + srp->header.encoded_object_length + lsp->header.encoded_object_length + ero->header.encoded_object_length); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_UPDATE); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -454,14 +488,17 @@ void test_pcep_msg_create_initiate() message = pcep_msg_create_initiate(obj_list); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->msg_header); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 3); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH + srp->header.encoded_object_length + lsp->header.encoded_object_length + ero->header.encoded_object_length); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_INITIATE); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -482,11 +519,14 @@ void test_pcep_msg_create_notify(void) message = pcep_msg_create_notify(notify_obj, NULL); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 1); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH + notify_obj->header.encoded_object_length); + assert(message->msg_header != NULL); CU_ASSERT_EQUAL(message->msg_header->type, PCEP_TYPE_PCNOTF); CU_ASSERT_EQUAL(message->msg_header->pcep_version, PCEP_MESSAGE_HEADER_VERSION); @@ -504,7 +544,9 @@ void test_pcep_msg_create_notify(void) message = pcep_msg_create_notify(notify_obj, obj_list); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); + assert(message != NULL); CU_ASSERT_PTR_NOT_NULL(message->obj_list); + assert(message->obj_list != NULL); CU_ASSERT_EQUAL(message->obj_list->num_entries, 2); CU_ASSERT_EQUAL(message->encoded_message_length, MESSAGE_HEADER_LENGTH diff --git a/pceplib/test/pcep_msg_objects_test.c b/pceplib/test/pcep_msg_objects_test.c index e0814de543..a92bbe4896 100644 --- a/pceplib/test/pcep_msg_objects_test.c +++ b/pceplib/test/pcep_msg_objects_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <stdlib.h> #include <CUnit/CUnit.h> @@ -128,6 +129,7 @@ static void verify_pcep_obj_header2(uint8_t obj_class, uint8_t obj_type, static void verify_pcep_obj_header(uint8_t obj_class, uint8_t obj_type, struct pcep_object_header *obj_hdr) { + assert(obj_hdr != NULL); verify_pcep_obj_header2(obj_class, obj_type, pcep_object_get_length_by_hdr(obj_hdr), obj_hdr->encoded_object); @@ -172,12 +174,14 @@ void test_pcep_obj_create_open_with_tlvs() pcep_obj_create_open(keepalive, deadtimer, sid, tlv_list); CU_ASSERT_PTR_NOT_NULL(open); + assert(open != NULL); pcep_encode_object(&open->header, versioning, object_buf); verify_pcep_obj_header2(PCEP_OBJ_CLASS_OPEN, PCEP_OBJ_TYPE_OPEN, pcep_object_get_length_by_hdr(&open->header) + sizeof(uint32_t) * 2, open->header.encoded_object); CU_ASSERT_PTR_NOT_NULL(open->header.tlv_list); + assert(open->header.tlv_list != NULL); CU_ASSERT_EQUAL(open->header.tlv_list->num_entries, 1); CU_ASSERT_EQUAL(open->header.encoded_object[4], @@ -240,6 +244,8 @@ void test_pcep_obj_create_nopath() CU_ASSERT_EQUAL(nopath->header.encoded_object[7], 0); /* Verify the TLV */ + assert(nopath != NULL); + assert(nopath->header.tlv_list != NULL); CU_ASSERT_PTR_NOT_NULL(nopath->header.tlv_list); struct pcep_object_tlv_nopath_vector *tlv = (struct pcep_object_tlv_nopath_vector *) @@ -269,6 +275,7 @@ void test_pcep_obj_create_association_ipv4() false, PCEP_ASSOCIATION_TYPE_SR_POLICY_ASSOCIATION_TYPE, all_assoc_groups, src); CU_ASSERT_PTR_NOT_NULL(assoc); + assert(assoc != NULL); CU_ASSERT_EQUAL(assoc->association_type, PCEP_ASSOCIATION_TYPE_SR_POLICY_ASSOCIATION_TYPE); CU_ASSERT_EQUAL(assoc->association_id, all_assoc_groups); @@ -291,6 +298,7 @@ void test_pcep_obj_create_association_ipv6() false, PCEP_ASSOCIATION_TYPE_SR_POLICY_ASSOCIATION_TYPE, all_assoc_groups, src); CU_ASSERT_PTR_NOT_NULL(assoc); + assert(assoc != NULL); CU_ASSERT_EQUAL(assoc->association_type, PCEP_ASSOCIATION_TYPE_SR_POLICY_ASSOCIATION_TYPE); CU_ASSERT_EQUAL(assoc->association_id, all_assoc_groups); @@ -466,6 +474,7 @@ void test_pcep_obj_create_svec() svec = pcep_obj_create_svec(true, true, true, id_list); CU_ASSERT_PTR_NOT_NULL(svec); + assert(svec != NULL); pcep_encode_object(&svec->header, versioning, object_buf); verify_pcep_obj_header2(PCEP_OBJ_CLASS_SVEC, PCEP_OBJ_TYPE_SVEC, (OBJECT_HEADER_LENGTH + sizeof(uint32_t) * 2), @@ -614,6 +623,7 @@ static void test_pcep_obj_create_object_common(ro_func func_to_test, struct pcep_object_ro *ero = func_to_test(NULL); CU_ASSERT_PTR_NOT_NULL(ero); + assert(ero != NULL); pcep_encode_object(&ero->header, versioning, object_buf); verify_pcep_obj_header2(object_class, object_type, OBJECT_HEADER_LENGTH, ero->header.encoded_object); @@ -622,6 +632,7 @@ static void test_pcep_obj_create_object_common(ro_func func_to_test, reset_objects_buffer(); ero = func_to_test(ero_list); CU_ASSERT_PTR_NOT_NULL(ero); + assert(ero != NULL); pcep_encode_object(&ero->header, versioning, object_buf); verify_pcep_obj_header2(object_class, object_type, OBJECT_HEADER_LENGTH, ero->header.encoded_object); @@ -634,6 +645,7 @@ static void test_pcep_obj_create_object_common(ro_func func_to_test, dll_append(ero_list, ro_subobj); ero = func_to_test(ero_list); CU_ASSERT_PTR_NOT_NULL(ero); + assert(ero != NULL); pcep_encode_object(&ero->header, versioning, object_buf); /* 4 bytes for obj header + * 2 bytes for ro_subobj header + @@ -917,6 +929,7 @@ void test_pcep_obj_create_ro_subobj_sr_ipv4_node() sr = pcep_obj_create_ro_subobj_sr_ipv4_node(true, true, false, false, sid, &ipv4_node_id); CU_ASSERT_PTR_NOT_NULL(sr); + assert(sr != NULL); struct pcep_object_ro *ro = encode_ro_subobj(&sr->ro_subobj); verify_pcep_obj_ro_sr_header(ro, &sr->ro_subobj, PCEP_SR_SUBOBJ_NAI_IPV4_NODE, true, @@ -936,10 +949,12 @@ void test_pcep_obj_create_ro_subobj_sr_ipv4_node() sr = pcep_obj_create_ro_subobj_sr_ipv4_node(false, false, true, true, sid, &ipv4_node_id); CU_ASSERT_PTR_NOT_NULL(sr); + assert(sr != NULL); ro = encode_ro_subobj(&sr->ro_subobj); verify_pcep_obj_ro_sr_header(ro, &sr->ro_subobj, PCEP_SR_SUBOBJ_NAI_IPV4_NODE, false, sizeof(uint32_t) * 4); + assert(ro != NULL); CU_ASSERT_TRUE(ro->header.encoded_object[7] & OBJECT_SUBOBJ_SR_FLAG_C); CU_ASSERT_TRUE(ro->header.encoded_object[7] & OBJECT_SUBOBJ_SR_FLAG_M); CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_S); @@ -1040,6 +1055,7 @@ void test_pcep_obj_create_ro_subobj_sr_ipv4_adj() CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_F); CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_C); CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_M); + assert(sr != NULL); CU_ASSERT_EQUAL(sr->sid, 0); uint32_t *uint32_ptr = (uint32_t *)(ro->header.encoded_object + 8); CU_ASSERT_EQUAL(uint32_ptr[0], local_ipv4.s_addr); @@ -1094,6 +1110,7 @@ void test_pcep_obj_create_ro_subobj_sr_ipv6_adj() sr = pcep_obj_create_ro_subobj_sr_ipv6_adj(true, true, true, true, sid, &local_ipv6, &remote_ipv6); CU_ASSERT_PTR_NOT_NULL(sr); + assert(sr != NULL); struct pcep_object_ro *ro = encode_ro_subobj(&sr->ro_subobj); verify_pcep_obj_ro_sr_header(ro, &sr->ro_subobj, PCEP_SR_SUBOBJ_NAI_IPV6_ADJACENCY, true, @@ -1168,6 +1185,7 @@ void test_pcep_obj_create_ro_subobj_sr_unnumbered_ipv4_adj() CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_F); CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_C); CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_M); + assert(sr != NULL); CU_ASSERT_EQUAL(sr->sid, 0); uint32_t *uint32_ptr = (uint32_t *)(ro->header.encoded_object + 8); CU_ASSERT_EQUAL(uint32_ptr[0], local_node_id); @@ -1244,6 +1262,7 @@ void test_pcep_obj_create_ro_subobj_sr_linklocal_ipv6_adj() CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_F); CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_C); CU_ASSERT_TRUE(ro->header.encoded_object[7] & ~OBJECT_SUBOBJ_SR_FLAG_M); + assert(sr != NULL); CU_ASSERT_EQUAL(sr->sid, 0); uint32_t *uint32_ptr = (uint32_t *)(ro->header.encoded_object + 8); CU_ASSERT_EQUAL(uint32_ptr[0], local_ipv6.__in6_u.__u6_addr32[0]); diff --git a/pceplib/test/pcep_msg_tlvs_test.c b/pceplib/test/pcep_msg_tlvs_test.c index 57e1d16e91..888925fdbf 100644 --- a/pceplib/test/pcep_msg_tlvs_test.c +++ b/pceplib/test/pcep_msg_tlvs_test.c @@ -30,6 +30,7 @@ #else #include <endian.h> #endif /* __FreeBSD__ */ +#include <assert.h> #include <stdlib.h> #include <CUnit/CUnit.h> @@ -88,6 +89,7 @@ void test_pcep_tlv_create_stateful_pce_capability() pcep_tlv_create_stateful_pce_capability(true, true, true, true, true, true); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, @@ -126,11 +128,13 @@ void test_pcep_tlv_create_speaker_entity_id() dll_append(list, speaker_entity); tlv = pcep_tlv_create_speaker_entity_id(list); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_SPEAKER_ENTITY_ID); CU_ASSERT_EQUAL(tlv->header.encoded_tlv_length, sizeof(uint32_t)); CU_ASSERT_PTR_NOT_NULL(tlv->speaker_entity_id_list); + assert(tlv->speaker_entity_id_list != NULL); CU_ASSERT_EQUAL(tlv->speaker_entity_id_list->num_entries, 1); uint32_t *uint32_ptr = (uint32_t *)tlv->header.encoded_tlv; CU_ASSERT_EQUAL(uint32_ptr[1], htonl(*speaker_entity)); @@ -144,6 +148,7 @@ void test_pcep_tlv_create_lsp_db_version() struct pcep_object_tlv_lsp_db_version *tlv = pcep_tlv_create_lsp_db_version(lsp_db_version); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_LSP_DB_VERSION); @@ -162,6 +167,7 @@ void test_pcep_tlv_create_path_setup_type() struct pcep_object_tlv_path_setup_type *tlv = pcep_tlv_create_path_setup_type(pst); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_PATH_SETUP_TYPE); CU_ASSERT_EQUAL(tlv->header.encoded_tlv_length, sizeof(uint32_t)); @@ -231,6 +237,7 @@ void test_pcep_tlv_create_path_setup_type_capability() PCEP_OBJ_TLV_TYPE_PATH_SETUP_TYPE_CAPABILITY); CU_ASSERT_EQUAL(tlv->header.encoded_tlv_length, sizeof(uint32_t) * 2); CU_ASSERT_PTR_NOT_NULL(tlv->pst_list); + assert(tlv != NULL); CU_ASSERT_EQUAL(tlv->pst_list->num_entries, 3); uint32_t *uint32_ptr = (uint32_t *)tlv->header.encoded_tlv; CU_ASSERT_EQUAL(uint32_ptr[1], htonl(0x00000003)); @@ -251,6 +258,7 @@ void test_pcep_tlv_create_path_setup_type_capability() tlv = pcep_tlv_create_path_setup_type_capability(pst_list, sub_tlv_list); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, @@ -283,6 +291,7 @@ void test_pcep_tlv_create_sr_pce_capability() struct pcep_object_tlv_sr_pce_capability *tlv = pcep_tlv_create_sr_pce_capability(true, true, 8); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_SR_PCE_CAPABILITY); @@ -305,6 +314,7 @@ void test_pcep_tlv_create_symbolic_path_name() struct pcep_object_tlv_symbolic_path_name *tlv = pcep_tlv_create_symbolic_path_name(path_name, path_name_length); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_SYMBOLIC_PATH_NAME); @@ -325,6 +335,8 @@ void test_pcep_tlv_create_symbolic_path_name() reset_tlv_buffer(); tlv = pcep_tlv_create_symbolic_path_name(path_name, 3); CU_ASSERT_PTR_NOT_NULL(tlv); + printf("El tlv es %p", tlv); + assert(tlv != NULL); // crash si FALSE pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_SYMBOLIC_PATH_NAME); CU_ASSERT_EQUAL(tlv->header.encoded_tlv_length, 3); @@ -359,6 +371,7 @@ void test_pcep_tlv_create_ipv4_lsp_identifiers() tlv = pcep_tlv_create_ipv4_lsp_identifiers( NULL, NULL, lsp_id, tunnel_id, &extended_tunnel_id); CU_ASSERT_PTR_NULL(tlv); + assert(tlv == NULL); tlv = pcep_tlv_create_ipv4_lsp_identifiers(&sender_ip, &endpoint_ip, lsp_id, tunnel_id, @@ -381,6 +394,7 @@ void test_pcep_tlv_create_ipv4_lsp_identifiers() tlv = pcep_tlv_create_ipv4_lsp_identifiers(&sender_ip, &endpoint_ip, lsp_id, tunnel_id, NULL); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, @@ -424,11 +438,13 @@ void test_pcep_tlv_create_ipv6_lsp_identifiers() NULL, NULL, lsp_id, tunnel_id, (struct in6_addr *)&extended_tunnel_id); CU_ASSERT_PTR_NULL(tlv); + assert(tlv == NULL); tlv = pcep_tlv_create_ipv6_lsp_identifiers( &sender_ip, &endpoint_ip, lsp_id, tunnel_id, (struct in6_addr *)&extended_tunnel_id); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, @@ -449,6 +465,7 @@ void test_pcep_tlv_create_srpag_pol_id_ipv4() struct pcep_object_tlv_srpag_pol_id *tlv = pcep_tlv_create_srpag_pol_id_ipv4(color, (void *)&src); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, (PCEP_OBJ_TLV_TYPE_SRPOLICY_POL_ID)); @@ -506,6 +523,7 @@ void test_pcep_tlv_create_srpag_pol_name() struct pcep_object_tlv_srpag_pol_name *tlv = pcep_tlv_create_srpag_pol_name(pol_name, strlen(pol_name)); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, @@ -559,6 +577,7 @@ void test_pcep_tlv_create_srpag_cp_pref() struct pcep_object_tlv_srpag_cp_pref *tlv = pcep_tlv_create_srpag_cp_pref(preference_default); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, @@ -586,6 +605,7 @@ void test_pcep_tlv_create_lsp_error_code() pcep_tlv_create_lsp_error_code( PCEP_TLV_LSP_ERROR_CODE_RSVP_SIGNALING_ERROR); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_LSP_ERROR_CODE); @@ -612,6 +632,7 @@ void test_pcep_tlv_create_rsvp_ipv4_error_spec() tlv = pcep_tlv_create_rsvp_ipv4_error_spec(&error_node_ip, error_code, error_value); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_RSVP_ERROR_SPEC); @@ -635,6 +656,7 @@ void test_pcep_tlv_create_rsvp_ipv6_error_spec() tlv = pcep_tlv_create_rsvp_ipv6_error_spec(&error_node_ip, error_code, error_value); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_RSVP_ERROR_SPEC); @@ -651,6 +673,7 @@ void test_pcep_tlv_create_nopath_vector() struct pcep_object_tlv_vendor_info *tlv = pcep_tlv_create_vendor_info( enterprise_number, enterprise_specific_info); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, PCEP_OBJ_TLV_TYPE_VENDOR_INFO); @@ -670,6 +693,7 @@ void test_pcep_tlv_create_arbitrary() struct pcep_object_tlv_arbitrary *tlv = pcep_tlv_create_tlv_arbitrary( data, data_length, tlv_id_unknown); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, tlv_id_unknown); @@ -688,6 +712,7 @@ void test_pcep_tlv_create_arbitrary() reset_tlv_buffer(); tlv = pcep_tlv_create_tlv_arbitrary(data, 3, tlv_id_unknown); CU_ASSERT_PTR_NOT_NULL(tlv); + assert(tlv != NULL); pcep_encode_tlv(&tlv->header, versioning, tlv_buf); CU_ASSERT_EQUAL(tlv->header.type, tlv_id_unknown); CU_ASSERT_EQUAL(tlv->header.encoded_tlv_length, 3); diff --git a/pceplib/test/pcep_msg_tools_test.c b/pceplib/test/pcep_msg_tools_test.c index 787df2fd7a..5a7644b21a 100644 --- a/pceplib/test/pcep_msg_tools_test.c +++ b/pceplib/test/pcep_msg_tools_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -213,6 +214,7 @@ void test_pcep_msg_read_pcep_initiate() } double_linked_list *msg_list = pcep_msg_read(fd); CU_ASSERT_PTR_NOT_NULL(msg_list); + assert(msg_list != NULL); CU_ASSERT_EQUAL(msg_list->num_entries, 1); struct pcep_message *msg = (struct pcep_message *)msg_list->head->data; @@ -274,6 +276,7 @@ void test_pcep_msg_read_pcep_initiate() double_linked_list *ero_subobj_list = ((struct pcep_object_ro *)obj_hdr)->sub_objects; CU_ASSERT_PTR_NOT_NULL(ero_subobj_list); + assert(ero_subobj_list != NULL); CU_ASSERT_EQUAL(ero_subobj_list->num_entries, 2); double_linked_list_node *subobj_node = ero_subobj_list->head; struct pcep_object_ro_subobj *subobj_hdr = @@ -312,6 +315,7 @@ void test_pcep_msg_read_pcep_initiate2() } double_linked_list *msg_list = pcep_msg_read(fd); CU_ASSERT_PTR_NOT_NULL(msg_list); + assert(msg_list != NULL); CU_ASSERT_EQUAL(msg_list->num_entries, 1); struct pcep_message *msg = (struct pcep_message *)msg_list->head->data; @@ -367,6 +371,7 @@ void test_pcep_msg_read_pcep_initiate2() double_linked_list *ero_subobj_list = ((struct pcep_object_ro *)obj_hdr)->sub_objects; CU_ASSERT_PTR_NOT_NULL(ero_subobj_list); + assert(ero_subobj_list != NULL); CU_ASSERT_EQUAL(ero_subobj_list->num_entries, 0); double_linked_list_node *subobj_node = ero_subobj_list->head; CU_ASSERT_PTR_NULL(subobj_node); @@ -399,6 +404,7 @@ void test_pcep_msg_read_pcep_open() } double_linked_list *msg_list = pcep_msg_read(fd); CU_ASSERT_PTR_NOT_NULL(msg_list); + assert(msg_list != NULL); CU_ASSERT_EQUAL(msg_list->num_entries, 1); struct pcep_message *msg = (struct pcep_message *)msg_list->head->data; @@ -443,6 +449,7 @@ void test_pcep_msg_read_pcep_update() } double_linked_list *msg_list = pcep_msg_read(fd); CU_ASSERT_PTR_NOT_NULL(msg_list); + assert(msg_list != NULL); CU_ASSERT_EQUAL(msg_list->num_entries, 1); struct pcep_message *msg = (struct pcep_message *)msg_list->head->data; @@ -492,6 +499,7 @@ void test_pcep_msg_read_pcep_update() double_linked_list *ero_subobj_list = ((struct pcep_object_ro *)obj_hdr)->sub_objects; CU_ASSERT_PTR_NOT_NULL(ero_subobj_list); + assert(ero_subobj_list != NULL); CU_ASSERT_EQUAL(ero_subobj_list->num_entries, 0); double_linked_list_node *subobj_node = ero_subobj_list->head; CU_ASSERT_PTR_NULL(subobj_node); @@ -525,6 +533,7 @@ void test_pcep_msg_read_pcep_open_initiate() } double_linked_list *msg_list = pcep_msg_read(fd); CU_ASSERT_PTR_NOT_NULL(msg_list); + assert(msg_list != NULL); CU_ASSERT_EQUAL(msg_list->num_entries, 2); struct pcep_message *msg = (struct pcep_message *)msg_list->head->data; @@ -554,6 +563,7 @@ void test_pcep_msg_read_pcep_open_cisco_pce() } double_linked_list *msg_list = pcep_msg_read(fd); CU_ASSERT_PTR_NOT_NULL(msg_list); + assert(msg_list != NULL); CU_ASSERT_EQUAL(msg_list->num_entries, 1); struct pcep_message *msg = (struct pcep_message *)msg_list->head->data; @@ -573,6 +583,7 @@ void test_pcep_msg_read_pcep_open_cisco_pce() CU_ASSERT_EQUAL(open->open_sid, 0); CU_ASSERT_EQUAL(open->open_version, 1); CU_ASSERT_PTR_NOT_NULL(open->header.tlv_list); + assert(open->header.tlv_list != NULL); CU_ASSERT_EQUAL(open->header.tlv_list->num_entries, 2); /* Stateful PCE Capability TLV */ @@ -616,6 +627,7 @@ void test_pcep_msg_read_pcep_update_cisco_pce() } double_linked_list *msg_list = pcep_msg_read(fd); CU_ASSERT_PTR_NOT_NULL(msg_list); + assert(msg_list != NULL); CU_ASSERT_EQUAL(msg_list->num_entries, 1); struct pcep_message *msg = (struct pcep_message *)msg_list->head->data; @@ -631,6 +643,7 @@ void test_pcep_msg_read_pcep_update_cisco_pce() CU_ASSERT_EQUAL(srp->header.object_type, PCEP_OBJ_TYPE_SRP); CU_ASSERT_EQUAL(srp->header.encoded_object_length, 20); CU_ASSERT_PTR_NOT_NULL(srp->header.tlv_list); + assert(srp->header.tlv_list != NULL); CU_ASSERT_EQUAL(srp->header.tlv_list->num_entries, 1); CU_ASSERT_EQUAL(srp->srp_id_number, 1); CU_ASSERT_FALSE(srp->flag_lsp_remove); @@ -651,6 +664,7 @@ void test_pcep_msg_read_pcep_update_cisco_pce() CU_ASSERT_EQUAL(lsp->header.object_type, PCEP_OBJ_TYPE_LSP); CU_ASSERT_EQUAL(lsp->header.encoded_object_length, 24); CU_ASSERT_PTR_NOT_NULL(lsp->header.tlv_list); + assert(lsp->header.tlv_list != NULL); CU_ASSERT_EQUAL(lsp->header.tlv_list->num_entries, 1); CU_ASSERT_EQUAL(lsp->plsp_id, 524303); CU_ASSERT_EQUAL(lsp->operational_status, PCEP_LSP_OPERATIONAL_DOWN); @@ -677,6 +691,7 @@ void test_pcep_msg_read_pcep_update_cisco_pce() CU_ASSERT_EQUAL(ero->header.encoded_object_length, 40); CU_ASSERT_PTR_NULL(ero->header.tlv_list); CU_ASSERT_PTR_NOT_NULL(ero->sub_objects); + assert(ero->sub_objects != NULL); CU_ASSERT_EQUAL(ero->sub_objects->num_entries, 3); /* ERO Subobjects */ @@ -757,6 +772,7 @@ void test_pcep_msg_read_pcep_report_cisco_pcc() } double_linked_list *msg_list = pcep_msg_read(fd); CU_ASSERT_PTR_NOT_NULL(msg_list); + assert(msg_list != NULL); CU_ASSERT_EQUAL(msg_list->num_entries, 1); struct pcep_message *msg = (struct pcep_message *)msg_list->head->data; @@ -772,6 +788,7 @@ void test_pcep_msg_read_pcep_report_cisco_pcc() CU_ASSERT_EQUAL(srp->header.object_type, PCEP_OBJ_TYPE_SRP); CU_ASSERT_EQUAL(srp->header.encoded_object_length, 20); CU_ASSERT_PTR_NOT_NULL(srp->header.tlv_list); + assert(srp->header.tlv_list != NULL); CU_ASSERT_EQUAL(srp->header.tlv_list->num_entries, 1); CU_ASSERT_EQUAL(srp->srp_id_number, 0); CU_ASSERT_FALSE(srp->flag_lsp_remove); @@ -838,6 +855,7 @@ void test_pcep_msg_read_pcep_report_cisco_pcc() CU_ASSERT_EQUAL(ero->header.encoded_object_length, 4); CU_ASSERT_PTR_NULL(ero->header.tlv_list); CU_ASSERT_PTR_NOT_NULL(ero->sub_objects); + assert(ero->sub_objects != NULL); CU_ASSERT_EQUAL(ero->sub_objects->num_entries, 0); /* LSPA object */ @@ -916,6 +934,7 @@ void test_pcep_msg_read_pcep_initiate_cisco_pcc() } double_linked_list *msg_list = pcep_msg_read(fd); CU_ASSERT_PTR_NOT_NULL(msg_list); + assert(msg_list != NULL); CU_ASSERT_EQUAL(msg_list->num_entries, 1); struct pcep_message *msg = (struct pcep_message *)msg_list->head->data; @@ -931,6 +950,7 @@ void test_pcep_msg_read_pcep_initiate_cisco_pcc() CU_ASSERT_EQUAL(srp->header.object_type, PCEP_OBJ_TYPE_SRP); CU_ASSERT_EQUAL(srp->header.encoded_object_length, 20); CU_ASSERT_PTR_NOT_NULL(srp->header.tlv_list); + assert(srp->header.tlv_list != NULL); CU_ASSERT_EQUAL(srp->header.tlv_list->num_entries, 1); CU_ASSERT_EQUAL(srp->srp_id_number, 1); CU_ASSERT_FALSE(srp->flag_lsp_remove); @@ -942,6 +962,7 @@ void test_pcep_msg_read_pcep_initiate_cisco_pcc() CU_ASSERT_EQUAL(lsp->header.object_type, PCEP_OBJ_TYPE_LSP); CU_ASSERT_EQUAL(lsp->header.encoded_object_length, 48); CU_ASSERT_PTR_NOT_NULL(lsp->header.tlv_list); + assert(lsp->header.tlv_list != NULL); CU_ASSERT_EQUAL(lsp->header.tlv_list->num_entries, 2); CU_ASSERT_EQUAL(lsp->plsp_id, 0); CU_ASSERT_EQUAL(lsp->operational_status, PCEP_LSP_OPERATIONAL_DOWN); @@ -988,7 +1009,9 @@ void test_pcep_msg_read_pcep_initiate_cisco_pcc() PCEP_OBJ_TYPE_SWITCH_LAYER); CU_ASSERT_EQUAL(switch_layer->header.encoded_object_length, 8); CU_ASSERT_PTR_NULL(switch_layer->header.tlv_list); + assert(switch_layer->header.tlv_list == NULL); CU_ASSERT_PTR_NOT_NULL(switch_layer->switch_layer_rows); + assert(switch_layer->switch_layer_rows != NULL); CU_ASSERT_EQUAL(switch_layer->switch_layer_rows->num_entries, 1); struct pcep_object_switch_layer_row *switch_layer_row = (struct pcep_object_switch_layer_row *) diff --git a/pceplib/test/pcep_pcc_api_test.c b/pceplib/test/pcep_pcc_api_test.c index 4adbb6374e..9106671873 100644 --- a/pceplib/test/pcep_pcc_api_test.c +++ b/pceplib/test/pcep_pcc_api_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <netdb.h> // gethostbyname #include <pthread.h> #include <stdlib.h> @@ -108,6 +109,8 @@ void test_connect_pce() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *open_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(open_msg); + assert(open_msg != NULL); + assert(open_msg->msg_header != NULL); CU_ASSERT_EQUAL(open_msg->msg_header->type, PCEP_TYPE_OPEN); pcep_msg_free_message(open_msg); @@ -134,6 +137,7 @@ void test_connect_pce_ipv6() pcep_session *session = connect_pce_ipv6(config, &dest_address); CU_ASSERT_PTR_NOT_NULL(session); + assert(session != NULL); CU_ASSERT_TRUE(session->socket_comm_session->is_ipv6); CU_ASSERT_EQUAL(mock_info->sent_message_list->num_entries, 1); /* What gets saved in the mock is the msg byte buffer. The msg struct @@ -144,6 +148,7 @@ void test_connect_pce_ipv6() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *open_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(open_msg); + assert(open_msg != NULL); CU_ASSERT_EQUAL(open_msg->msg_header->type, PCEP_TYPE_OPEN); pcep_msg_free_message(open_msg); @@ -175,6 +180,8 @@ void test_connect_pce_with_src_ip() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *open_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(open_msg); + assert(open_msg != NULL); + assert(open_msg->msg_header != NULL); CU_ASSERT_EQUAL(open_msg->msg_header->type, PCEP_TYPE_OPEN); pcep_msg_free_message(open_msg); @@ -207,6 +214,7 @@ void test_disconnect_pce() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(msg); + assert(msg != NULL); CU_ASSERT_EQUAL(msg->msg_header->type, PCEP_TYPE_OPEN); pcep_msg_free_message(msg); pceplib_free(PCEPLIB_MESSAGES, encoded_msg); @@ -216,6 +224,8 @@ void test_disconnect_pce() CU_ASSERT_PTR_NOT_NULL(encoded_msg); msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(msg); + assert(msg != NULL); + assert(msg->msg_header != NULL); CU_ASSERT_EQUAL(msg->msg_header->type, PCEP_TYPE_CLOSE); pcep_msg_free_message(msg); diff --git a/pceplib/test/pcep_session_logic_loop_test.c b/pceplib/test/pcep_session_logic_loop_test.c index d68b200549..4dfed7321f 100644 --- a/pceplib/test/pcep_session_logic_loop_test.c +++ b/pceplib/test/pcep_session_logic_loop_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <pthread.h> #include <stdlib.h> #include <string.h> @@ -161,6 +162,7 @@ void test_session_logic_msg_ready_handler() pcep_session_event *socket_event = (pcep_session_event *)queue_dequeue( session_logic_handle_->session_event_queue); CU_ASSERT_PTR_NOT_NULL(socket_event); + assert(socket_event != NULL); CU_ASSERT_TRUE(socket_event->socket_closed); pceplib_free(PCEPLIB_INFRA, socket_event); @@ -179,6 +181,7 @@ void test_session_logic_msg_ready_handler() socket_event = (pcep_session_event *)queue_dequeue( session_logic_handle_->session_event_queue); CU_ASSERT_PTR_NOT_NULL(socket_event); + assert(socket_event != NULL); CU_ASSERT_FALSE(socket_event->socket_closed); CU_ASSERT_PTR_EQUAL(socket_event->session, &session); CU_ASSERT_EQUAL(socket_event->expired_timer_id, TIMER_ID_NOT_SET); @@ -206,6 +209,7 @@ void test_session_logic_conn_except_notifier() pcep_session_event *socket_event = (pcep_session_event *)queue_dequeue( session_logic_handle_->session_event_queue); CU_ASSERT_PTR_NOT_NULL_FATAL(socket_event); + assert(socket_event != NULL); CU_ASSERT_TRUE(socket_event->socket_closed); CU_ASSERT_PTR_EQUAL(socket_event->session, &session); CU_ASSERT_EQUAL(socket_event->expired_timer_id, TIMER_ID_NOT_SET); @@ -230,6 +234,7 @@ void test_session_logic_timer_expire_handler() pcep_session_event *socket_event = (pcep_session_event *)queue_dequeue( session_logic_handle_->session_event_queue); CU_ASSERT_PTR_NOT_NULL_FATAL(socket_event); + assert(socket_event != NULL); CU_ASSERT_FALSE(socket_event->socket_closed); CU_ASSERT_PTR_EQUAL(socket_event->session, &session); CU_ASSERT_EQUAL(socket_event->expired_timer_id, 42); diff --git a/pceplib/test/pcep_session_logic_states_test.c b/pceplib/test/pcep_session_logic_states_test.c index 24741fa345..e967d74e48 100644 --- a/pceplib/test/pcep_session_logic_states_test.c +++ b/pceplib/test/pcep_session_logic_states_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <stdlib.h> #include <string.h> @@ -394,6 +395,7 @@ void test_handle_socket_comm_event_open() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(msg); + assert(msg != NULL); CU_ASSERT_EQUAL(PCEP_TYPE_ERROR, msg->msg_header->type); /* Verify the error object */ CU_ASSERT_EQUAL(1, msg->obj_list->num_entries); @@ -456,6 +458,7 @@ void test_handle_socket_comm_event_open_error() uint8_t *encoded_msg = dll_delete_first_node(mock_info->sent_message_list); CU_ASSERT_PTR_NOT_NULL(encoded_msg); + assert(encoded_msg != NULL); struct pcep_message *open_msg_corrected = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(open_msg_corrected); @@ -463,6 +466,7 @@ void test_handle_socket_comm_event_open_error() (struct pcep_object_open *)pcep_obj_get( open_msg_corrected->obj_list, PCEP_OBJ_CLASS_OPEN); CU_ASSERT_PTR_NOT_NULL(open_object_corrected); + assert(open_object_corrected != NULL); /* Verify the Keep-alive and Dead timers have been negotiated */ CU_ASSERT_EQUAL(error_open_object->open_keepalive, open_object_corrected->open_keepalive); @@ -596,6 +600,7 @@ void test_handle_socket_comm_event_pcreq() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *error_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(error_msg); + assert(error_msg != NULL); CU_ASSERT_EQUAL(PCEP_TYPE_ERROR, error_msg->msg_header->type); /* Verify the error object */ CU_ASSERT_EQUAL(1, error_msg->obj_list->num_entries); @@ -627,6 +632,7 @@ void test_handle_socket_comm_event_report() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *error_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(error_msg); + assert(error_msg != NULL); CU_ASSERT_EQUAL(PCEP_TYPE_ERROR, error_msg->msg_header->type); /* Verify the error object */ CU_ASSERT_EQUAL(1, error_msg->obj_list->num_entries); @@ -744,6 +750,7 @@ void test_handle_socket_comm_event_unknown_msg() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(msg); + assert(msg != NULL); CU_ASSERT_EQUAL(PCEP_TYPE_ERROR, msg->msg_header->type); /* Verify the error object */ CU_ASSERT_EQUAL(1, msg->obj_list->num_entries); @@ -776,6 +783,7 @@ void test_handle_socket_comm_event_unknown_msg() /* Verify the error message */ encoded_msg = dll_delete_first_node(mock_info->sent_message_list); CU_ASSERT_PTR_NOT_NULL(encoded_msg); + assert(encoded_msg != NULL); msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(msg); CU_ASSERT_EQUAL(PCEP_TYPE_ERROR, msg->msg_header->type); @@ -793,8 +801,10 @@ void test_handle_socket_comm_event_unknown_msg() /* Verify the Close message */ encoded_msg = dll_delete_first_node(mock_info->sent_message_list); CU_ASSERT_PTR_NOT_NULL(encoded_msg); + assert(encoded_msg != NULL); msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(msg); + assert(msg != NULL); CU_ASSERT_EQUAL(PCEP_TYPE_CLOSE, msg->msg_header->type); /* Verify the error object */ CU_ASSERT_EQUAL(1, msg->obj_list->num_entries); diff --git a/pceplib/test/pcep_session_logic_test.c b/pceplib/test/pcep_session_logic_test.c index 503e77c20e..8339a7a280 100644 --- a/pceplib/test/pcep_session_logic_test.c +++ b/pceplib/test/pcep_session_logic_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <stdlib.h> #include <string.h> #include <time.h> @@ -134,6 +135,7 @@ void test_create_destroy_pcep_session() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *open_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(open_msg); + assert(open_msg != NULL); /* Should be an Open, with no TLVs: length = 12 */ CU_ASSERT_EQUAL(open_msg->msg_header->type, PCEP_TYPE_OPEN); CU_ASSERT_EQUAL(open_msg->encoded_message_length, 12); @@ -166,6 +168,7 @@ void test_create_destroy_pcep_session_ipv6() mock_info->send_message_save_message = true; session = create_pcep_session_ipv6(&config, &pce_ip); CU_ASSERT_PTR_NOT_NULL(session); + assert(session != NULL); CU_ASSERT_TRUE(session->socket_comm_session->is_ipv6); /* What gets saved in the mock is the msg byte buffer. The msg struct * was deleted when it was sent. Instead of inspecting the msg byte @@ -175,6 +178,7 @@ void test_create_destroy_pcep_session_ipv6() CU_ASSERT_PTR_NOT_NULL(encoded_msg); struct pcep_message *open_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(open_msg); + assert(open_msg != NULL); /* Should be an Open, with no TLVs: length = 12 */ CU_ASSERT_EQUAL(open_msg->msg_header->type, PCEP_TYPE_OPEN); CU_ASSERT_EQUAL(open_msg->encoded_message_length, 12); @@ -215,14 +219,17 @@ void test_create_pcep_session_open_tlvs() CU_ASSERT_PTR_NOT_NULL(encoded_msg); open_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(open_msg); + assert(open_msg != NULL); /* Get and verify the Open Message objects */ CU_ASSERT_PTR_NOT_NULL(open_msg->obj_list); + assert(open_msg->obj_list != NULL); CU_ASSERT_TRUE(open_msg->obj_list->num_entries > 0); /* Get and verify the Open object */ open_obj = pcep_obj_get(open_msg->obj_list, PCEP_OBJ_CLASS_OPEN); CU_ASSERT_PTR_NOT_NULL(open_obj); /* Get and verify the Open object TLVs */ CU_ASSERT_PTR_NOT_NULL(open_obj->tlv_list); + assert(open_obj->tlv_list != NULL); CU_ASSERT_EQUAL(open_obj->tlv_list->num_entries, 1); CU_ASSERT_EQUAL(((struct pcep_object_tlv_header *) open_obj->tlv_list->head->data) @@ -250,12 +257,14 @@ void test_create_pcep_session_open_tlvs() CU_ASSERT_PTR_NOT_NULL(open_msg); /* Get and verify the Open Message objects */ CU_ASSERT_PTR_NOT_NULL(open_msg->obj_list); + assert(open_msg != NULL); CU_ASSERT_TRUE(open_msg->obj_list->num_entries > 0); /* Get and verify the Open object */ open_obj = pcep_obj_get(open_msg->obj_list, PCEP_OBJ_CLASS_OPEN); CU_ASSERT_PTR_NOT_NULL(open_obj); /* Get and verify the Open object TLVs */ CU_ASSERT_PTR_NOT_NULL(open_obj->tlv_list); + assert(open_obj->tlv_list != NULL); CU_ASSERT_EQUAL(open_obj->tlv_list->num_entries, 2); CU_ASSERT_EQUAL(((struct pcep_object_tlv_header *) open_obj->tlv_list->head->data) @@ -287,14 +296,17 @@ void test_create_pcep_session_open_tlvs() CU_ASSERT_PTR_NOT_NULL(encoded_msg); open_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(open_msg); + assert(open_msg != NULL); /* Get and verify the Open Message objects */ CU_ASSERT_PTR_NOT_NULL(open_msg->obj_list); + assert(open_msg->obj_list != NULL); CU_ASSERT_TRUE(open_msg->obj_list->num_entries > 0); /* Get and verify the Open object */ open_obj = pcep_obj_get(open_msg->obj_list, PCEP_OBJ_CLASS_OPEN); CU_ASSERT_PTR_NOT_NULL(open_obj); /* Get and verify the Open object TLVs */ CU_ASSERT_PTR_NOT_NULL(open_obj->tlv_list); + assert(open_obj->tlv_list != NULL); CU_ASSERT_EQUAL(open_obj->tlv_list->num_entries, 3); double_linked_list_node *tlv_node = open_obj->tlv_list->head; CU_ASSERT_EQUAL(((struct pcep_object_tlv_header *)tlv_node->data)->type, @@ -324,16 +336,21 @@ void test_create_pcep_session_open_tlvs() /* Get and verify the Open Message */ encoded_msg = dll_delete_first_node(mock_info->sent_message_list); CU_ASSERT_PTR_NOT_NULL(encoded_msg); + assert(encoded_msg != NULL); open_msg = pcep_decode_message(encoded_msg); CU_ASSERT_PTR_NOT_NULL(open_msg); + assert(open_msg != NULL); /* Get and verify the Open Message objects */ CU_ASSERT_PTR_NOT_NULL(open_msg->obj_list); + assert(open_msg->obj_list != NULL); CU_ASSERT_TRUE(open_msg->obj_list->num_entries > 0); /* Get and verify the Open object */ open_obj = pcep_obj_get(open_msg->obj_list, PCEP_OBJ_CLASS_OPEN); CU_ASSERT_PTR_NOT_NULL(open_obj); + assert(open_obj != NULL); /* Get and verify the Open object TLVs */ CU_ASSERT_PTR_NOT_NULL(open_obj->tlv_list); + assert(open_obj->tlv_list != NULL); CU_ASSERT_EQUAL(open_obj->tlv_list->num_entries, 4); tlv_node = open_obj->tlv_list->head; CU_ASSERT_EQUAL(((struct pcep_object_tlv_header *)tlv_node->data)->type, diff --git a/pceplib/test/pcep_socket_comm_test.c b/pceplib/test/pcep_socket_comm_test.c index 0ab38bf96e..116531f12d 100644 --- a/pceplib/test/pcep_socket_comm_test.c +++ b/pceplib/test/pcep_socket_comm_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <netinet/in.h> #include <CUnit/CUnit.h> @@ -112,6 +113,7 @@ void test_pcep_socket_comm_initialize() test_connection_except_notifier, &test_host_ip, test_port, connect_timeout_millis, NULL, false, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_FALSE(test_session->is_ipv6); } @@ -123,6 +125,7 @@ void test_pcep_socket_comm_initialize_ipv6() test_connection_except_notifier, &test_host_ipv6, test_port, connect_timeout_millis, NULL, false, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_TRUE(test_session->is_ipv6); } @@ -135,6 +138,7 @@ void test_pcep_socket_comm_initialize_with_src() test_connection_except_notifier, NULL, 0, &test_host_ip, test_port, connect_timeout_millis, NULL, false, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_EQUAL( test_session->src_sock_addr.src_sock_addr_ipv4.sin_addr.s_addr, INADDR_ANY); @@ -147,6 +151,7 @@ void test_pcep_socket_comm_initialize_with_src() &test_host_ip, test_port, connect_timeout_millis, NULL, false, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_EQUAL( test_session->src_sock_addr.src_sock_addr_ipv4.sin_addr.s_addr, test_src_ip.s_addr); @@ -164,6 +169,7 @@ void test_pcep_socket_comm_initialize_with_src_ipv6() test_connection_except_notifier, NULL, 0, &test_host_ipv6, test_port, connect_timeout_millis, NULL, false, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_EQUAL(memcmp(&test_session->src_sock_addr.src_sock_addr_ipv6 .sin6_addr, &in6addr_any, sizeof(struct in6_addr)), @@ -177,6 +183,7 @@ void test_pcep_socket_comm_initialize_with_src_ipv6() &test_host_ipv6, test_port, connect_timeout_millis, NULL, false, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_EQUAL(memcmp(&test_session->src_sock_addr.src_sock_addr_ipv6 .sin6_addr, &test_src_ipv6, sizeof(struct in6_addr)), @@ -198,6 +205,7 @@ void test_pcep_socket_comm_initialize_tcpmd5() test_connection_except_notifier, &test_host_ip, test_port, 1, tcp_md5_str, true, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_EQUAL(0, strncmp(tcp_md5_str, test_session->tcp_authentication_str, tcp_md5_strlen)); @@ -213,6 +221,7 @@ void test_pcep_socket_comm_initialize_tcpmd5() test_connection_except_notifier, &test_host_ip, test_port, 1, tcp_md5_str, false, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_EQUAL(0, strncmp(tcp_md5_str, test_session->tcp_authentication_str, tcp_md5_strlen)); @@ -231,6 +240,7 @@ void test_pcep_socket_comm_initialize_ipv6_tcpmd5() test_connection_except_notifier, &test_host_ipv6, test_port, 1, tcp_md5_str, true, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_EQUAL(0, strncmp(tcp_md5_str, test_session->tcp_authentication_str, tcp_md5_strlen)); @@ -246,6 +256,7 @@ void test_pcep_socket_comm_initialize_ipv6_tcpmd5() test_connection_except_notifier, &test_host_ipv6, test_port, 1, tcp_md5_str, false, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_EQUAL(0, strncmp(tcp_md5_str, test_session->tcp_authentication_str, tcp_md5_strlen)); @@ -300,7 +311,9 @@ void test_pcep_socket_comm_session_destroy() test_connection_except_notifier, &test_host_ip, test_port, connect_timeout_millis, NULL, false, NULL); CU_ASSERT_PTR_NOT_NULL(test_session); + assert(test_session != NULL); CU_ASSERT_PTR_NOT_NULL(socket_comm_handle_); + assert(socket_comm_handle_ != NULL); CU_ASSERT_EQUAL(socket_comm_handle_->num_active_sessions, 1); CU_ASSERT_TRUE(socket_comm_session_teardown(test_session)); diff --git a/pceplib/test/pcep_utils_counters_test.c b/pceplib/test/pcep_utils_counters_test.c index bcdce36188..b31715f7ac 100644 --- a/pceplib/test/pcep_utils_counters_test.c +++ b/pceplib/test/pcep_utils_counters_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <stdlib.h> #include <CUnit/CUnit.h> @@ -47,6 +48,7 @@ void test_create_counters_group() group = create_counters_group(group_name, num_subgroups); CU_ASSERT_PTR_NOT_NULL(group); + assert(group != NULL); CU_ASSERT_EQUAL(group->num_subgroups, 0); CU_ASSERT_EQUAL(group->max_subgroups, num_subgroups); @@ -76,6 +78,7 @@ void test_create_counters_subgroup() subgroup = create_counters_subgroup(subgroup_name, subgroup_id, num_counters); CU_ASSERT_PTR_NOT_NULL(subgroup); + assert(subgroup != NULL); CU_ASSERT_EQUAL(subgroup->subgroup_id, subgroup_id); CU_ASSERT_EQUAL(subgroup->num_counters, 0); diff --git a/pceplib/test/pcep_utils_double_linked_list_test.c b/pceplib/test/pcep_utils_double_linked_list_test.c index 4eb85816b9..181cbeca37 100644 --- a/pceplib/test/pcep_utils_double_linked_list_test.c +++ b/pceplib/test/pcep_utils_double_linked_list_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <CUnit/CUnit.h> #include "pcep_utils_double_linked_list.h" @@ -72,16 +73,22 @@ void test_dll_prepend_data() CU_ASSERT_EQUAL(handle->num_entries, 3); double_linked_list_node *node = handle->head; + CU_ASSERT_PTR_NOT_NULL(node); + assert(node != NULL); CU_ASSERT_PTR_EQUAL(node->data, &data1); CU_ASSERT_PTR_NULL(node->prev_node); CU_ASSERT_PTR_NOT_NULL(node->next_node); node = node->next_node; + CU_ASSERT_PTR_NOT_NULL(node); + assert(node != NULL); CU_ASSERT_PTR_EQUAL(node->data, &data2); CU_ASSERT_PTR_NOT_NULL(node->prev_node); CU_ASSERT_PTR_NOT_NULL(node->next_node); node = node->next_node; + CU_ASSERT_PTR_NOT_NULL(node); + assert(node != NULL); CU_ASSERT_PTR_EQUAL(node->data, &data3); CU_ASSERT_PTR_NOT_NULL(node->prev_node); CU_ASSERT_PTR_NULL(node->next_node); @@ -112,11 +119,15 @@ void test_dll_append_data() CU_ASSERT_PTR_NOT_NULL(node->next_node); node = node->next_node; + CU_ASSERT_PTR_NOT_NULL(node); + assert(node != NULL); CU_ASSERT_PTR_EQUAL(node->data, &data2); CU_ASSERT_PTR_NOT_NULL(node->prev_node); CU_ASSERT_PTR_NOT_NULL(node->next_node); node = node->next_node; + CU_ASSERT_PTR_NOT_NULL(node); + assert(node != NULL); CU_ASSERT_PTR_EQUAL(node->data, &data3); CU_ASSERT_PTR_NOT_NULL(node->prev_node); CU_ASSERT_PTR_NULL(node->next_node); @@ -278,8 +289,11 @@ void test_dll_delete_node() node2 = dll_append(handle, &data2); node3 = dll_append(handle, &data3); CU_ASSERT_PTR_NOT_NULL(node1); + assert(node1 != NULL); CU_ASSERT_PTR_NOT_NULL(node2); + assert(node2 != NULL); CU_ASSERT_PTR_NOT_NULL(node3); + assert(node3 != NULL); CU_ASSERT_EQUAL(handle->num_entries, 3); /* Delete the middle entry */ diff --git a/pceplib/test/pcep_utils_ordered_list_test.c b/pceplib/test/pcep_utils_ordered_list_test.c index d20f5e68af..12ac456e23 100644 --- a/pceplib/test/pcep_utils_ordered_list_test.c +++ b/pceplib/test/pcep_utils_ordered_list_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <CUnit/CUnit.h> #include "pcep_utils_ordered_list.h" @@ -55,6 +56,7 @@ void test_empty_list() ordered_list_initialize(node_data_compare); CU_ASSERT_PTR_NOT_NULL(handle); + assert(handle != NULL); CU_ASSERT_PTR_NULL(handle->head); CU_ASSERT_PTR_NOT_NULL(handle->compare_function); CU_ASSERT_EQUAL(handle->num_entries, 0); @@ -134,14 +136,17 @@ void test_find() ordered_list_node *node = ordered_list_find(handle, &data1); CU_ASSERT_PTR_NOT_NULL(node); + assert(node != NULL); CU_ASSERT_PTR_EQUAL(node->data, &data1); node = ordered_list_find(handle, &data2); CU_ASSERT_PTR_NOT_NULL(node); + assert(node != NULL); CU_ASSERT_PTR_EQUAL(node->data, &data2); node = ordered_list_find(handle, &data3); CU_ASSERT_PTR_NOT_NULL(node); + assert(node != NULL); CU_ASSERT_PTR_EQUAL(node->data, &data3); node = ordered_list_find(handle, &data_not_inList); diff --git a/pceplib/test/pcep_utils_queue_test.c b/pceplib/test/pcep_utils_queue_test.c index 061dfbf37b..6e62c75636 100644 --- a/pceplib/test/pcep_utils_queue_test.c +++ b/pceplib/test/pcep_utils_queue_test.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <assert.h> #include <CUnit/CUnit.h> #include "pcep_utils_queue.h" @@ -41,6 +42,7 @@ void test_empty_queue() queue_handle *handle = queue_initialize(); CU_ASSERT_PTR_NOT_NULL(handle); + assert(handle != NULL); CU_ASSERT_PTR_NULL(handle->head); CU_ASSERT_EQUAL(handle->num_entries, 0); diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index d2f7dad820..90aa15beee 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -7213,7 +7213,8 @@ DEFUN (no_ip_pim_rp_keep_alive, char rp_ka_timer[5]; char rp_ka_timer_xpath[XPATH_MAXLEN]; - snprintf(rp_ka_timer, sizeof(rp_ka_timer), "%d", PIM_KEEPALIVE_PERIOD); + snprintf(rp_ka_timer, sizeof(rp_ka_timer), "%d", + PIM_RP_KEEPALIVE_PERIOD); vrfname = pim_cli_get_vrf_name(vty); if (vrfname == NULL) @@ -11090,9 +11091,7 @@ void pim_cmd_init(void) install_element(CONFIG_NODE, &ip_pim_ssm_prefix_list_cmd); install_element(VRF_NODE, &ip_pim_ssm_prefix_list_cmd); install_element(CONFIG_NODE, &ip_pim_register_suppress_cmd); - install_element(VRF_NODE, &ip_pim_register_suppress_cmd); install_element(CONFIG_NODE, &no_ip_pim_register_suppress_cmd); - install_element(VRF_NODE, &no_ip_pim_register_suppress_cmd); install_element(CONFIG_NODE, &ip_pim_spt_switchover_infinity_cmd); install_element(VRF_NODE, &ip_pim_spt_switchover_infinity_cmd); install_element(CONFIG_NODE, &ip_pim_spt_switchover_infinity_plist_cmd); @@ -11105,9 +11104,7 @@ void pim_cmd_init(void) install_element(CONFIG_NODE, &pim_register_accept_list_cmd); install_element(VRF_NODE, &pim_register_accept_list_cmd); install_element(CONFIG_NODE, &ip_pim_joinprune_time_cmd); - install_element(VRF_NODE, &ip_pim_joinprune_time_cmd); install_element(CONFIG_NODE, &no_ip_pim_joinprune_time_cmd); - install_element(VRF_NODE, &no_ip_pim_joinprune_time_cmd); install_element(CONFIG_NODE, &ip_pim_keep_alive_cmd); install_element(VRF_NODE, &ip_pim_keep_alive_cmd); install_element(CONFIG_NODE, &ip_pim_rp_keep_alive_cmd); @@ -11117,9 +11114,7 @@ void pim_cmd_init(void) install_element(CONFIG_NODE, &no_ip_pim_rp_keep_alive_cmd); install_element(VRF_NODE, &no_ip_pim_rp_keep_alive_cmd); install_element(CONFIG_NODE, &ip_pim_packets_cmd); - install_element(VRF_NODE, &ip_pim_packets_cmd); install_element(CONFIG_NODE, &no_ip_pim_packets_cmd); - install_element(VRF_NODE, &no_ip_pim_packets_cmd); install_element(CONFIG_NODE, &ip_pim_v6_secondary_cmd); install_element(VRF_NODE, &ip_pim_v6_secondary_cmd); install_element(CONFIG_NODE, &no_ip_pim_v6_secondary_cmd); diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index da2daea7c3..4598297f93 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -763,8 +763,8 @@ int pim_register_suppress_time_modify(struct nb_cb_modify_args *args) case NB_EV_ABORT: break; case NB_EV_APPLY: - router->register_suppress_time = - yang_dnode_get_uint16(args->dnode, NULL); + pim_update_suppress_timers( + yang_dnode_get_uint16(args->dnode, NULL)); break; } diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 9899172e6c..918a9a9c7d 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -407,6 +407,28 @@ static void pim_upstream_join_timer_restart_msec(struct pim_upstream *up, &up->t_join_timer); } +void pim_update_suppress_timers(uint32_t suppress_time) +{ + struct pim_instance *pim; + struct vrf *vrf; + unsigned int old_rp_ka_time; + + /* stash the old one so we know which values were manually configured */ + old_rp_ka_time = (3 * router->register_suppress_time + + router->register_probe_time); + router->register_suppress_time = suppress_time; + + RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { + pim = vrf->info; + if (!pim) + continue; + + /* Only adjust if not manually configured */ + if (pim->rp_keep_alive_time == old_rp_ka_time) + pim->rp_keep_alive_time = PIM_RP_KEEPALIVE_PERIOD; + } +} + void pim_upstream_join_suppress(struct pim_upstream *up, struct in_addr rpf_addr, int holdtime) { diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h index adea3cd9ef..56039d5605 100644 --- a/pimd/pim_upstream.h +++ b/pimd/pim_upstream.h @@ -317,6 +317,7 @@ int pim_upstream_eval_inherit_if(struct pim_upstream *up, void pim_upstream_update_join_desired(struct pim_instance *pim, struct pim_upstream *up); +void pim_update_suppress_timers(uint32_t suppress_time); void pim_upstream_join_suppress(struct pim_upstream *up, struct in_addr rpf_addr, int holdtime); diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index 76e9c3f0aa..929d35101e 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -186,16 +186,24 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty) writes += pim_rp_config_write(pim, vty, spaces); - if (router->register_suppress_time - != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) { - vty_out(vty, "%sip pim register-suppress-time %d\n", spaces, - router->register_suppress_time); - ++writes; - } - if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) { - vty_out(vty, "%sip pim join-prune-interval %d\n", spaces, - router->t_periodic); - ++writes; + if (pim->vrf_id == VRF_DEFAULT) { + if (router->register_suppress_time + != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) { + vty_out(vty, "%sip pim register-suppress-time %d\n", + spaces, router->register_suppress_time); + ++writes; + } + if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) { + vty_out(vty, "%sip pim join-prune-interval %d\n", + spaces, router->t_periodic); + ++writes; + } + + if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) { + vty_out(vty, "%sip pim packets %d\n", spaces, + router->packet_process); + ++writes; + } } if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) { vty_out(vty, "%sip pim keep-alive-timer %d\n", spaces, @@ -207,11 +215,6 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty) pim->rp_keep_alive_time); ++writes; } - if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) { - vty_out(vty, "%sip pim packets %d\n", spaces, - router->packet_process); - ++writes; - } if (ssm->plist_name) { vty_out(vty, "%sip pim ssm prefix-list %s\n", spaces, ssm->plist_name); diff --git a/pimd/pimd.c b/pimd/pimd.c index 1679480794..38e7273945 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -29,6 +29,7 @@ #include "jhash.h" #include "vrf.h" #include "lib_errors.h" +#include "bfd.h" #include "pimd.h" #include "pim_cmd.h" @@ -137,6 +138,8 @@ void pim_terminate(void) { struct zclient *zclient; + bfd_protocol_integration_set_shutdown(true); + /* reverse prefix_list_init */ prefix_list_add_hook(NULL); prefix_list_delete_hook(NULL); diff --git a/tests/lib/test_nexthop.c b/tests/lib/test_nexthop.c new file mode 100644 index 0000000000..659d207b4e --- /dev/null +++ b/tests/lib/test_nexthop.c @@ -0,0 +1,201 @@ +/* + * Nexthop module test. + * + * Copyright (C) 2021 by Volta Networks, Inc. + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <zebra.h> +#include <nexthop.h> + +static bool verbose; + +static void test_run_first(void) +{ + int ret, i; + struct nexthop *nh1, *nh2; + struct in_addr addr; + struct in6_addr addr6; + mpls_label_t labels[MPLS_MAX_LABELS]; + + /* Test comparison apis */ + + /* ifindex comparisons */ + nh1 = nexthop_from_ifindex(11, 0); + nh2 = nexthop_from_ifindex(12, 0); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret < 0); + + nexthop_free(nh1); + nh1 = nexthop_from_ifindex(12, 0); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret == 0); + + nexthop_free(nh1); + nexthop_free(nh2); + + /* ipv4, vrf */ + addr.s_addr = 0x04030201; + nh1 = nexthop_from_ipv4(&addr, NULL, 0); + nh2 = nexthop_from_ipv4(&addr, NULL, 111); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret != 0); + + nexthop_free(nh2); + + addr.s_addr = 0x04030202; + nh2 = nexthop_from_ipv4(&addr, NULL, 0); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret != 0); + + nexthop_free(nh2); + + addr.s_addr = 0x04030201; + nh2 = nexthop_from_ipv4(&addr, NULL, 0); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret == 0); + + /* Weight */ + nh2->weight = 20; + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret != 0); + + nexthop_free(nh1); + nexthop_free(nh2); + + /* ipv6 */ + memset(addr6.s6_addr, 0, sizeof(addr6.s6_addr)); + nh1 = nexthop_from_ipv6(&addr6, 0); + nh2 = nexthop_from_ipv6(&addr6, 0); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret == 0); + + nexthop_free(nh2); + + nh2 = nexthop_from_ipv6(&addr6, 1); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret != 0); + + nexthop_free(nh2); + + addr6.s6_addr[14] = 1; + addr6.s6_addr[15] = 1; + nh2 = nexthop_from_ipv6(&addr6, 0); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret != 0); + + nexthop_free(nh1); + nexthop_free(nh2); + + /* Blackhole */ + nh1 = nexthop_from_blackhole(BLACKHOLE_REJECT); + nh2 = nexthop_from_blackhole(BLACKHOLE_REJECT); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret == 0); + + nexthop_free(nh2); + + nh2 = nexthop_from_blackhole(BLACKHOLE_NULL); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret != 0); + + /* Labels */ + addr.s_addr = 0x04030201; + nh1 = nexthop_from_ipv4(&addr, NULL, 0); + nh2 = nexthop_from_ipv4(&addr, NULL, 0); + + memset(labels, 0, sizeof(labels)); + labels[0] = 111; + labels[1] = 222; + + nexthop_add_labels(nh1, ZEBRA_LSP_STATIC, 2, labels); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret != 0); + + nexthop_add_labels(nh2, ZEBRA_LSP_STATIC, 2, labels); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret == 0); + + nexthop_free(nh2); + + /* LSP type isn't included */ + nh2 = nexthop_from_ipv4(&addr, NULL, 0); + nexthop_add_labels(nh2, ZEBRA_LSP_LDP, 2, labels); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret == 0); + + nexthop_free(nh2); + + labels[2] = 333; + nh2 = nexthop_from_ipv4(&addr, NULL, 0); + nexthop_add_labels(nh2, ZEBRA_LSP_LDP, 3, labels); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret != 0); + + nexthop_free(nh1); + nexthop_free(nh2); + + nh1 = nexthop_from_ipv4(&addr, NULL, 0); + nh2 = nexthop_from_ipv4(&addr, NULL, 0); + + for (i = 0; i < MPLS_MAX_LABELS; i++) + labels[i] = 111 * (i + 1); + + nexthop_add_labels(nh1, ZEBRA_LSP_LDP, MPLS_MAX_LABELS, labels); + nexthop_add_labels(nh2, ZEBRA_LSP_LDP, MPLS_MAX_LABELS, labels); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret == 0); + + nexthop_free(nh2); + + /* Test very last label in stack */ + labels[15] = 999; + nh2 = nexthop_from_ipv4(&addr, NULL, 0); + nexthop_add_labels(nh2, ZEBRA_LSP_LDP, MPLS_MAX_LABELS, labels); + + ret = nexthop_cmp_basic(nh1, nh2); + assert(ret != 0); + + /* End */ + nexthop_free(nh1); + nexthop_free(nh2); +} + +int main(int argc, char **argv) +{ + if (argc >= 2 && !strcmp("-v", argv[1])) + verbose = true; + test_run_first(); + printf("Simple test passed.\n"); +} diff --git a/tests/lib/test_nexthop.py b/tests/lib/test_nexthop.py new file mode 100644 index 0000000000..81bfa43ab5 --- /dev/null +++ b/tests/lib/test_nexthop.py @@ -0,0 +1,8 @@ +import frrtest + + +class TestNexthopIter(frrtest.TestMultiOut): + program = "./test_nexthop" + + +TestNexthopIter.onesimple("Simple test passed.") diff --git a/tests/subdir.am b/tests/subdir.am index 139f4878c8..43fad29fa2 100644 --- a/tests/subdir.am +++ b/tests/subdir.am @@ -76,6 +76,7 @@ check_PROGRAMS = \ tests/lib/test_idalloc \ tests/lib/test_memory \ tests/lib/test_nexthop_iter \ + tests/lib/test_nexthop \ tests/lib/test_ntop \ tests/lib/test_prefix2str \ tests/lib/test_printfrr \ @@ -293,6 +294,10 @@ tests_lib_test_nexthop_iter_CFLAGS = $(TESTS_CFLAGS) tests_lib_test_nexthop_iter_CPPFLAGS = $(TESTS_CPPFLAGS) tests_lib_test_nexthop_iter_LDADD = $(ALL_TESTS_LDADD) tests_lib_test_nexthop_iter_SOURCES = tests/lib/test_nexthop_iter.c tests/helpers/c/prng.c +tests_lib_test_nexthop_CFLAGS = $(TESTS_CFLAGS) +tests_lib_test_nexthop_CPPFLAGS = $(TESTS_CPPFLAGS) +tests_lib_test_nexthop_LDADD = $(ALL_TESTS_LDADD) +tests_lib_test_nexthop_SOURCES = tests/lib/test_nexthop.c tests_lib_test_ntop_CFLAGS = $(TESTS_CFLAGS) tests_lib_test_ntop_CPPFLAGS = $(CPPFLAGS_BASE) # no assert override tests_lib_test_ntop_LDADD = # none @@ -412,6 +417,7 @@ EXTRA_DIST += \ tests/lib/test_assert.py \ tests/lib/test_atomlist.py \ tests/lib/test_nexthop_iter.py \ + tests/lib/test_nexthop.py \ tests/lib/test_ntop.py \ tests/lib/test_prefix2str.py \ tests/lib/test_printfrr.py \ diff --git a/tests/topotests/bgp-auth/test_bgp_auth.py b/tests/topotests/bgp-auth/test_bgp_auth.py index 521ca332d0..b2cdef1c93 100644 --- a/tests/topotests/bgp-auth/test_bgp_auth.py +++ b/tests/topotests/bgp-auth/test_bgp_auth.py @@ -357,9 +357,10 @@ def check_neigh_state(router, peer, state, vrf=""): "show bgp vrf {} neighbors {} json".format(vrf, peer) ) neigh_output_json = json.loads(neigh_output) - if neigh_output_json[peer]["bgpState"] == state: - matched = True - break + if peer in neigh_output_json.keys(): + if neigh_output_json[peer]["bgpState"] == state: + matched = True + break count += 1 sleep(1) diff --git a/tests/topotests/isis-topo1/r1/r1_topology.json b/tests/topotests/isis-topo1/r1/r1_topology.json index 6d2bbb80c9..337d6bf5ef 100644 --- a/tests/topotests/isis-topo1/r1/r1_topology.json +++ b/tests/topotests/isis-topo1/r1/r1_topology.json @@ -18,9 +18,9 @@ "vertex": "r1" }, { - "metric": "internal", - "parent": "0", - "type": "IP", + "metric": "0", + "parent": "r1(4)", + "type": "IP internal", "vertex": "10.0.20.0/24" }, { @@ -32,27 +32,27 @@ "vertex": "r3" }, { - "interface": "r3", - "metric": "TE", - "next-hop": "10", - "parent": "r1-eth0", - "type": "IP", + "interface": "r1-eth0", + "metric": "10", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP TE", "vertex": "10.0.10.0/24" }, { - "interface": "r3", - "metric": "TE", - "next-hop": "10", - "parent": "r1-eth0", - "type": "IP", + "interface": "r1-eth0", + "metric": "10", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP TE", "vertex": "10.0.20.0/24" }, { - "interface": "r3", - "metric": "TE", - "next-hop": "10", - "parent": "r1-eth0", - "type": "IP", + "interface": "r1-eth0", + "metric": "10", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP TE", "vertex": "10.254.0.3/32" } ], @@ -61,9 +61,9 @@ "vertex": "r1" }, { - "metric": "internal", - "parent": "0", - "type": "IP6", + "metric": "0", + "parent": "r1(4)", + "type": "IP6 internal", "vertex": "2001:db8:1:1::/64" }, { @@ -75,17 +75,19 @@ "vertex": "r3" }, { - "interface": "r3", - "next-hop": "10", - "parent": "r1-eth0", - "type": "IP6", + "metric": "10", + "interface": "r1-eth0", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP6 internal", "vertex": "2001:db8:2:1::/64" }, { - "interface": "r3", - "next-hop": "10", - "parent": "r1-eth0", - "type": "IP6", + "metric": "10", + "interface": "r1-eth0", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::3/128" } ] diff --git a/tests/topotests/isis-topo1/r2/r2_topology.json b/tests/topotests/isis-topo1/r2/r2_topology.json index 396c618caa..de90fb5a32 100644 --- a/tests/topotests/isis-topo1/r2/r2_topology.json +++ b/tests/topotests/isis-topo1/r2/r2_topology.json @@ -18,9 +18,9 @@ "vertex": "r2" }, { - "metric": "internal", - "parent": "0", - "type": "IP", + "metric": "0", + "parent": "r2(4)", + "type": "IP internal", "vertex": "10.0.21.0/24" }, { @@ -32,27 +32,27 @@ "vertex": "r4" }, { - "interface": "r4", - "metric": "TE", - "next-hop": "10", - "parent": "r2-eth0", - "type": "IP", + "interface": "r2-eth0", + "metric": "10", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP TE", "vertex": "10.0.11.0/24" }, { - "interface": "r4", - "metric": "TE", - "next-hop": "10", - "parent": "r2-eth0", - "type": "IP", + "interface": "r2-eth0", + "metric": "10", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP TE", "vertex": "10.0.21.0/24" }, { - "interface": "r4", - "metric": "TE", - "next-hop": "10", - "parent": "r2-eth0", - "type": "IP", + "interface": "r2-eth0", + "metric": "10", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP TE", "vertex": "10.254.0.4/32" } ], @@ -61,9 +61,9 @@ "vertex": "r2" }, { - "metric": "internal", - "parent": "0", - "type": "IP6", + "metric": "0", + "parent": "r2(4)", + "type": "IP6 internal", "vertex": "2001:db8:1:2::/64" }, { @@ -75,17 +75,19 @@ "vertex": "r4" }, { - "interface": "r4", - "next-hop": "10", - "parent": "r2-eth0", - "type": "IP6", + "metric": "10", + "interface": "r2-eth0", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP6 internal", "vertex": "2001:db8:2:2::/64" }, { - "interface": "r4", - "next-hop": "10", - "parent": "r2-eth0", - "type": "IP6", + "metric": "10", + "interface": "r2-eth0", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::4/128" } ] diff --git a/tests/topotests/isis-topo1/r3/r3_topology.json b/tests/topotests/isis-topo1/r3/r3_topology.json index 5ab58c41a6..2d36f9b427 100644 --- a/tests/topotests/isis-topo1/r3/r3_topology.json +++ b/tests/topotests/isis-topo1/r3/r3_topology.json @@ -6,9 +6,9 @@ "vertex": "r3" }, { - "metric": "internal", - "parent": "0", - "type": "IP", + "metric": "0", + "parent": "r3(4)", + "type": "IP internal", "vertex": "10.0.10.0/24" }, { @@ -20,27 +20,27 @@ "vertex": "r5" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "10", - "parent": "r3-eth1", - "type": "IP", + "interface": "r3-eth1", + "metric": "10", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP TE", "vertex": "10.0.10.0/24" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "10", - "parent": "r3-eth1", - "type": "IP", + "interface": "r3-eth1", + "metric": "10", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP TE", "vertex": "10.0.11.0/24" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "10", - "parent": "r3-eth1", - "type": "IP", + "interface": "r3-eth1", + "metric": "10", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP TE", "vertex": "10.254.0.5/32" }, { @@ -51,19 +51,19 @@ "vertex": "r4" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "20", - "parent": "r3-eth1", - "type": "IP", + "interface": "r3-eth1", + "metric": "20", + "next-hop": "r5", + "parent": "r4(4)", + "type": "IP TE", "vertex": "10.0.21.0/24" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "20", - "parent": "r3-eth1", - "type": "IP", + "interface": "r3-eth1", + "metric": "20", + "next-hop": "r5", + "parent": "r4(4)", + "type": "IP TE", "vertex": "10.254.0.4/32" } ], @@ -72,9 +72,9 @@ "vertex": "r3" }, { - "metric": "internal", - "parent": "0", - "type": "IP6", + "metric": "0", + "parent": "r3(4)", + "type": "IP6 internal", "vertex": "2001:db8:2:1::/64" }, { @@ -86,17 +86,19 @@ "vertex": "r5" }, { - "interface": "r5", - "next-hop": "10", - "parent": "r3-eth1", - "type": "IP6", + "metric": "10", + "interface": "r3-eth1", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP6 internal", "vertex": "2001:db8:2:2::/64" }, { - "interface": "r5", - "next-hop": "10", - "parent": "r3-eth1", - "type": "IP6", + "metric": "10", + "interface": "r3-eth1", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::5/128" }, { @@ -107,17 +109,19 @@ "vertex": "r4" }, { - "interface": "r5", - "next-hop": "20", - "parent": "r3-eth1", - "type": "IP6", + "metric": "20", + "interface": "r3-eth1", + "next-hop": "r5", + "parent": "r4(4)", + "type": "IP6 internal", "vertex": "2001:db8:1:2::/64" }, { - "interface": "r5", - "next-hop": "20", - "parent": "r3-eth1", - "type": "IP6", + "metric": "20", + "interface": "r3-eth1", + "next-hop": "r5", + "parent": "r4(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::4/128" } ] @@ -128,9 +132,9 @@ "vertex": "r3" }, { - "metric": "internal", - "parent": "0", - "type": "IP", + "metric": "0", + "parent": "r3(4)", + "type": "IP internal", "vertex": "10.0.20.0/24" }, { @@ -142,19 +146,19 @@ "vertex": "r1" }, { - "interface": "r1", - "metric": "TE", - "next-hop": "10", - "parent": "r3-eth0", - "type": "IP", + "interface": "r3-eth0", + "metric": "10", + "next-hop": "r1", + "parent": "r1(4)", + "type": "IP TE", "vertex": "10.0.20.0/24" }, { - "interface": "r1", - "metric": "TE", - "next-hop": "10", - "parent": "r3-eth0", - "type": "IP", + "interface": "r3-eth0", + "metric": "10", + "next-hop": "r1", + "parent": "r1(4)", + "type": "IP TE", "vertex": "10.254.0.1/32" } ], @@ -163,9 +167,9 @@ "vertex": "r3" }, { - "metric": "internal", - "parent": "0", - "type": "IP6", + "metric": "0", + "parent": "r3(4)", + "type": "IP6 internal", "vertex": "2001:db8:1:1::/64" }, { @@ -177,10 +181,11 @@ "vertex": "r1" }, { - "interface": "r1", - "next-hop": "10", - "parent": "r3-eth0", - "type": "IP6", + "metric": "10", + "interface": "r3-eth0", + "next-hop": "r1", + "parent": "r1(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::1/128" } ] diff --git a/tests/topotests/isis-topo1/r4/r4_topology.json b/tests/topotests/isis-topo1/r4/r4_topology.json index ae74a60948..e7d7841912 100644 --- a/tests/topotests/isis-topo1/r4/r4_topology.json +++ b/tests/topotests/isis-topo1/r4/r4_topology.json @@ -6,9 +6,9 @@ "vertex": "r4" }, { - "metric": "internal", - "parent": "0", - "type": "IP", + "metric": "0", + "parent": "r4(4)", + "type": "IP internal", "vertex": "10.0.11.0/24" }, { @@ -20,27 +20,27 @@ "vertex": "r5" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "10", - "parent": "r4-eth1", - "type": "IP", + "interface": "r4-eth1", + "metric": "10", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP TE", "vertex": "10.0.10.0/24" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "10", - "parent": "r4-eth1", - "type": "IP", + "interface": "r4-eth1", + "metric": "10", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP TE", "vertex": "10.0.11.0/24" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "10", - "parent": "r4-eth1", - "type": "IP", + "interface": "r4-eth1", + "metric": "10", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP TE", "vertex": "10.254.0.5/32" }, { @@ -51,19 +51,19 @@ "vertex": "r3" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "20", - "parent": "r4-eth1", - "type": "IP", + "interface": "r4-eth1", + "metric": "20", + "next-hop": "r5", + "parent": "r3(4)", + "type": "IP TE", "vertex": "10.0.20.0/24" }, { - "interface": "r5", - "metric": "TE", - "next-hop": "20", - "parent": "r4-eth1", - "type": "IP", + "interface": "r4-eth1", + "metric": "20", + "next-hop": "r5", + "parent": "r3(4)", + "type": "IP TE", "vertex": "10.254.0.3/32" } ], @@ -72,9 +72,9 @@ "vertex": "r4" }, { - "metric": "internal", - "parent": "0", - "type": "IP6", + "metric": "0", + "parent": "r4(4)", + "type": "IP6 internal", "vertex": "2001:db8:2:2::/64" }, { @@ -86,17 +86,19 @@ "vertex": "r5" }, { - "interface": "r5", - "next-hop": "10", - "parent": "r4-eth1", - "type": "IP6", + "metric": "10", + "interface": "r4-eth1", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP6 internal", "vertex": "2001:db8:2:1::/64" }, { - "interface": "r5", - "next-hop": "10", - "parent": "r4-eth1", - "type": "IP6", + "metric": "10", + "interface": "r4-eth1", + "next-hop": "r5", + "parent": "r5(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::5/128" }, { @@ -107,17 +109,19 @@ "vertex": "r3" }, { - "interface": "r5", - "next-hop": "20", - "parent": "r4-eth1", - "type": "IP6", + "metric": "20", + "interface": "r4-eth1", + "next-hop": "r5", + "parent": "r3(4)", + "type": "IP6 internal", "vertex": "2001:db8:1:1::/64" }, { - "interface": "r5", - "next-hop": "20", - "parent": "r4-eth1", - "type": "IP6", + "metric": "20", + "interface": "r4-eth1", + "next-hop": "r5", + "parent": "r3(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::3/128" } ] @@ -128,9 +132,9 @@ "vertex": "r4" }, { - "metric": "internal", - "parent": "0", - "type": "IP", + "metric": "0", + "parent": "r4(4)", + "type": "IP internal", "vertex": "10.0.21.0/24" }, { @@ -142,19 +146,19 @@ "vertex": "r2" }, { - "interface": "r2", - "metric": "TE", - "next-hop": "10", - "parent": "r4-eth0", - "type": "IP", + "interface": "r4-eth0", + "metric": "10", + "next-hop": "r2", + "parent": "r2(4)", + "type": "IP TE", "vertex": "10.0.21.0/24" }, { - "interface": "r2", - "metric": "TE", - "next-hop": "10", - "parent": "r4-eth0", - "type": "IP", + "interface": "r4-eth0", + "metric": "10", + "next-hop": "r2", + "parent": "r2(4)", + "type": "IP TE", "vertex": "10.254.0.2/32" } ], @@ -163,9 +167,9 @@ "vertex": "r4" }, { - "metric": "internal", - "parent": "0", - "type": "IP6", + "metric": "0", + "parent": "r4(4)", + "type": "IP6 internal", "vertex": "2001:db8:1:2::/64" }, { @@ -177,10 +181,11 @@ "vertex": "r2" }, { - "interface": "r2", - "next-hop": "10", - "parent": "r4-eth0", - "type": "IP6", + "metric": "10", + "interface": "r4-eth0", + "next-hop": "r2", + "parent": "r2(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::2/128" } ] diff --git a/tests/topotests/isis-topo1/r5/r5_topology.json b/tests/topotests/isis-topo1/r5/r5_topology.json index 0224661411..3d887b7cea 100644 --- a/tests/topotests/isis-topo1/r5/r5_topology.json +++ b/tests/topotests/isis-topo1/r5/r5_topology.json @@ -6,15 +6,15 @@ "vertex": "r5" }, { - "metric": "internal", - "parent": "0", - "type": "IP", + "metric": "0", + "parent": "r5(4)", + "type": "IP internal", "vertex": "10.0.10.0/24" }, { - "metric": "internal", - "parent": "0", - "type": "IP", + "metric": "0", + "parent": "r5(4)", + "type": "IP internal", "vertex": "10.0.11.0/24" }, { @@ -34,51 +34,51 @@ "vertex": "r4" }, { - "interface": "r3", - "metric": "TE", - "next-hop": "10", - "parent": "r5-eth0", - "type": "IP", + "interface": "r5-eth0", + "metric": "10", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP TE", "vertex": "10.0.10.0/24" }, { - "interface": "r3", - "metric": "TE", - "next-hop": "10", - "parent": "r5-eth0", - "type": "IP", + "interface": "r5-eth0", + "metric": "10", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP TE", "vertex": "10.0.20.0/24" }, { - "interface": "r3", - "metric": "TE", - "next-hop": "10", - "parent": "r5-eth0", - "type": "IP", + "interface": "r5-eth0", + "metric": "10", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP TE", "vertex": "10.254.0.3/32" }, { - "interface": "r4", - "metric": "TE", - "next-hop": "10", - "parent": "r5-eth1", - "type": "IP", + "interface": "r5-eth1", + "metric": "10", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP TE", "vertex": "10.0.11.0/24" }, { - "interface": "r4", - "metric": "TE", - "next-hop": "10", - "parent": "r5-eth1", - "type": "IP", + "interface": "r5-eth1", + "metric": "10", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP TE", "vertex": "10.0.21.0/24" }, { - "interface": "r4", - "metric": "TE", - "next-hop": "10", - "parent": "r5-eth1", - "type": "IP", + "interface": "r5-eth1", + "metric": "10", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP TE", "vertex": "10.254.0.4/32" } ], @@ -87,15 +87,15 @@ "vertex": "r5" }, { - "metric": "internal", - "parent": "0", - "type": "IP6", + "metric": "0", + "parent": "r5(4)", + "type": "IP6 internal", "vertex": "2001:db8:2:1::/64" }, { - "metric": "internal", - "parent": "0", - "type": "IP6", + "metric": "0", + "parent": "r5(4)", + "type": "IP6 internal", "vertex": "2001:db8:2:2::/64" }, { @@ -115,31 +115,35 @@ "vertex": "r4" }, { - "interface": "r3", - "next-hop": "10", - "parent": "r5-eth0", - "type": "IP6", + "metric": "10", + "interface": "r5-eth0", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP6 internal", "vertex": "2001:db8:1:1::/64" }, { - "interface": "r3", - "next-hop": "10", - "parent": "r5-eth0", - "type": "IP6", + "metric": "10", + "interface": "r5-eth0", + "next-hop": "r3", + "parent": "r3(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::3/128" }, { - "interface": "r4", - "next-hop": "10", - "parent": "r5-eth1", - "type": "IP6", + "metric": "10", + "interface": "r5-eth1", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP6 internal", "vertex": "2001:db8:1:2::/64" }, { - "interface": "r4", - "next-hop": "10", - "parent": "r5-eth1", - "type": "IP6", + "metric": "10", + "interface": "r5-eth1", + "next-hop": "r4", + "parent": "r4(4)", + "type": "IP6 internal", "vertex": "2001:db8:f::4/128" } ] diff --git a/tests/topotests/isis-topo1/test_isis_topo1.py b/tests/topotests/isis-topo1/test_isis_topo1.py index e7618c7bce..083a8b1e8d 100644 --- a/tests/topotests/isis-topo1/test_isis_topo1.py +++ b/tests/topotests/isis-topo1/test_isis_topo1.py @@ -47,6 +47,20 @@ from mininet.topo import Topo pytestmark = [pytest.mark.isisd] +VERTEX_TYPE_LIST = [ + "pseudo_IS", + "pseudo_TE-IS", + "IS", + "TE-IS", + "ES", + "IP internal", + "IP external", + "IP TE", + "IP6 internal", + "IP6 external", + "UNKNOWN", +] + class ISISTopo1(Topo): "Simple two layer ISIS topology" @@ -263,6 +277,7 @@ def parse_topology(lines, level): areas = {} area = None ipv = None + vertex_type_regex = "|".join(VERTEX_TYPE_LIST) for line in lines: area_match = re.match(r"Area (.+):", line) @@ -282,44 +297,57 @@ def parse_topology(lines, level): ipv = "ipv4" continue - item_match = re.match(r"([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)", line) - if item_match is not None: + item_match = re.match( + r"([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+)", line + ) + if ( + item_match is not None + and item_match.group(1) == "Vertex" + and item_match.group(2) == "Type" + and item_match.group(3) == "Metric" + and item_match.group(4) == "Next-Hop" + and item_match.group(5) == "Interface" + and item_match.group(6) == "Parent" + ): # Skip header - if ( - item_match.group(1) == "Vertex" - and item_match.group(2) == "Type" - and item_match.group(3) == "Metric" - and item_match.group(4) == "Next-Hop" - and item_match.group(5) == "Interface" - and item_match.group(6) == "Parent" - ): - continue + continue + item_match = re.match( + r"([^\s]+) ({}) ([0]|([1-9][0-9]*)) ([^\s]+) ([^\s]+) ([^\s]+)".format( + vertex_type_regex + ), + line, + ) + if item_match is not None: areas[area][level][ipv].append( { "vertex": item_match.group(1), "type": item_match.group(2), "metric": item_match.group(3), - "next-hop": item_match.group(4), - "interface": item_match.group(5), - "parent": item_match.group(6), + "next-hop": item_match.group(5), + "interface": item_match.group(6), + "parent": item_match.group(7), } ) continue - item_match = re.match(r"([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)", line) + item_match = re.match( + r"([^\s]+) ({}) ([0]|([1-9][0-9]*)) ([^\s]+)".format(vertex_type_regex), + line, + ) + if item_match is not None: areas[area][level][ipv].append( { "vertex": item_match.group(1), "type": item_match.group(2), "metric": item_match.group(3), - "parent": item_match.group(4), + "parent": item_match.group(5), } ) continue - item_match = re.match(r"([^ ]+)", line) + item_match = re.match(r"([^\s]+)", line) if item_match is not None: areas[area][level][ipv].append({"vertex": item_match.group(1)}) continue diff --git a/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py b/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py index e90230eb3b..7bef57b629 100755 --- a/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py +++ b/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py @@ -101,9 +101,9 @@ import os import sys import json import time -import pytest from time import sleep import datetime +import pytest # Save the Current Working Directory to find configuration files. CWD = os.path.dirname(os.path.realpath(__file__)) @@ -114,9 +114,12 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from lib.topogen import Topogen, get_topogen from mininet.topo import Topo +from lib.topogen import Topogen, get_topogen +from lib.topolog import logger +from lib.topojson import build_topo_from_json, build_config_from_json + from lib.common_config import ( start_topology, write_test_header, @@ -149,16 +152,14 @@ from lib.pim import ( clear_ip_mroute, clear_ip_mroute_verify, ) -from lib.topolog import logger -from lib.topojson import build_topo_from_json, build_config_from_json # Reading the data from JSON File for topology and configuration creation jsonFile = "{}/multicast_pim_static_rp.json".format(CWD) try: with open(jsonFile, "r") as topoJson: - topo = json.load(topoJson) + TOPO = json.load(topoJson) except IOError: - logger.info("Could not read file:", jsonFile) + logger.info("Could not read file: %s", jsonFile) # Global variables GROUP_RANGE_ALL = "224.0.0.0/4" @@ -203,7 +204,11 @@ class CreateTopo(Topo): tgen = get_topogen(self) # Building topology from json file - build_topo_from_json(tgen, topo) + build_topo_from_json(tgen, TOPO) + + def dumdum(self): + """ Dummy """ + print("%s", self.name) def setup_module(mod): @@ -212,10 +217,9 @@ def setup_module(mod): * `mod`: module name """ - global topo testsuite_run_time = time.asctime(time.localtime(time.time())) - logger.info("Testsuite start time: {}".format(testsuite_run_time)) + logger.info("Testsuite start time: %s", testsuite_run_time) logger.info("=" * 40) topology = """ @@ -229,7 +233,7 @@ def setup_module(mod): r4 """ - logger.info("Master Topology: \n {}".format(topology)) + logger.info("Master Topology: \n %s", topology) logger.info("Running setup_module to create topology") @@ -239,7 +243,7 @@ def setup_module(mod): # ... and here it calls Mininet initialization functions. # get list of daemons needs to be started for this suite. - daemons = topo_daemons(tgen, topo) + daemons = topo_daemons(tgen, TOPO) # Starting topology, create tmp files which are loaded to routers # to start deamons and then start routers @@ -250,10 +254,10 @@ def setup_module(mod): pytest.skip(tgen.errors) # Creating configuration from JSON - build_config_from_json(tgen, topo) + build_config_from_json(tgen, TOPO) # Verify PIM neighbors - result = verify_pim_neighbors(tgen, topo) + result = verify_pim_neighbors(tgen, TOPO) assert result is True, "setup_module :Failed \n Error:" " {}".format(result) logger.info("Running setup_module() done") @@ -269,9 +273,7 @@ def teardown_module(): # Stop toplogy and Remove tmp files tgen.stop_topology() - logger.info( - "Testsuite end time: {}".format(time.asctime(time.localtime(time.time()))) - ) + logger.info("Testsuite end time: %s", time.asctime(time.localtime(time.time()))) logger.info("=" * 40) @@ -335,9 +337,9 @@ def verify_mroute_repopulated(uptime_before, uptime_after): ) return errormsg - d1 = datetime.datetime.strptime(uptime_before[group][source], "%H:%M:%S") - d2 = datetime.datetime.strptime(uptime_after[group][source], "%H:%M:%S") - if d2 >= d1: + d_1 = datetime.datetime.strptime(uptime_before[group][source], "%H:%M:%S") + d_2 = datetime.datetime.strptime(uptime_after[group][source], "%H:%M:%S") + if d_2 >= d_1: errormsg = "mroute (%s, %s) is not " "repopulated [FAILED!!]" % ( source, group, @@ -360,7 +362,7 @@ def verify_state_incremented(state_before, state_after): """ for router, state_data in state_before.items(): - for state, value in state_data.items(): + for state, _ in state_data.items(): if state_before[router][state] >= state_after[router][state]: errormsg = ( "[DUT: %s]: state %s value has not" @@ -422,7 +424,7 @@ def test_add_delete_static_RP_p0(request): step("r1: Verify show ip igmp group without any IGMP join") dut = "r1" interface = "r1-r0-eth0" - result = verify_igmp_groups(tgen, dut, interface, GROUP_ADDRESS, expected=False) + result = verify_igmp_groups(tgen, dut, interface, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: igmp group present without any IGMP join \n Error: {}".format( @@ -436,8 +438,9 @@ def test_add_delete_static_RP_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n state_before is not dictionary\n Error: {}".format( + tc_name, result + ) step("r0 : Send IGMP join") result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS, join_interval=1) @@ -453,7 +456,7 @@ def test_add_delete_static_RP_p0(request): iif = "r1-r2-eth1" rp_address = "1.0.2.17" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -487,12 +490,12 @@ def test_add_delete_static_RP_p0(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify RP info") result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE, expected=False + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert ( result is not True @@ -501,16 +504,14 @@ def test_add_delete_static_RP_p0(request): ) step("r1: Verify upstream IIF interface") - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False) + result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream IIF interface present \n Error: {}".format(tc_name, result) ) step("r1: Verify upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream join state is up and join timer is running \n Error: {}".format( @@ -519,13 +520,13 @@ def test_add_delete_static_RP_p0(request): ) step("r1: Verify PIM state") - result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False) + result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS) assert result is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, result ) step("r1: Verify ip mroutes") - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert ( result is not True ), "Testcase {} : Failed \n " "r1: mroutes are still present \n Error: {}".format( @@ -536,8 +537,9 @@ def test_add_delete_static_RP_p0(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -576,7 +578,7 @@ def test_SPT_RPT_path_same_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -604,7 +606,7 @@ def test_SPT_RPT_path_same_p1(request): rp_address = "1.0.2.17" iif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -684,9 +686,7 @@ def test_SPT_RPT_path_same_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S, G) upstream join state is up and join timer is running\n Error: {}".format( @@ -732,7 +732,7 @@ def test_not_reachable_static_RP_p0(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -754,8 +754,9 @@ def test_not_reachable_static_RP_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("Enable IGMP on r1 interface and send IGMP " "join (225.1.1.1) to r1") step("Configure r2 loopback interface as RP") @@ -770,7 +771,7 @@ def test_not_reachable_static_RP_p0(request): iif = "r1-r2-eth1" rp_address = "1.0.2.17" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -810,7 +811,7 @@ def test_not_reachable_static_RP_p0(request): step("r1: Check RP detail using show ip pim rp-info OIF should be unknown") result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, "Unknown", rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, "Unknown", rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -818,7 +819,7 @@ def test_not_reachable_static_RP_p0(request): "r1 : OIL should be same and IIF should be cleared on R1 verify" "using show ip pim state" ) - result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False) + result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "OIL is not same and IIF is not cleared on R1 \n Error: {}".format( @@ -827,7 +828,7 @@ def test_not_reachable_static_RP_p0(request): ) step("r1: upstream IIF should be unknown , verify using show ip pim" "upstream") - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False) + result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream IIF is not unknown \n Error: {}".format(tc_name, result) @@ -837,9 +838,7 @@ def test_not_reachable_static_RP_p0(request): "r1: join state should not be joined and join timer should stop," "verify using show ip pim upstream" ) - result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: join state is joined and timer is not stopped \n Error: {}".format( @@ -854,21 +853,22 @@ def test_not_reachable_static_RP_p0(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) step("r1: (*, G) cleared from mroute table using show ip mroute") - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r1: (*, G) are not cleared from mroute table \n Error: {}".format( tc_name, result ) ) - logger.info("Expected behavior: {}".format(result)) + logger.info("Expected behavior: %s", result) # Uncomment next line for debugging # tgen.mininet_cli() @@ -898,7 +898,7 @@ def test_add_RP_after_join_received_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -924,7 +924,7 @@ def test_add_RP_after_join_received_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify rp-info") @@ -932,7 +932,7 @@ def test_add_RP_after_join_received_p1(request): rp_address = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE, expected=False + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert ( result is not True @@ -945,8 +945,9 @@ def test_add_RP_after_join_received_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("r0 : Send IGMP join (225.1.1.1) to r1, when rp is not configured" "in r1") result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS, join_interval=1) @@ -958,7 +959,7 @@ def test_add_RP_after_join_received_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify upstream IIF interface") - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False) + result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream IFF interface is present \n Error: {}".format(tc_name, result) @@ -966,9 +967,7 @@ def test_add_RP_after_join_received_p1(request): step("r1: Verify upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream join state is joined and timer is running \n Error: {}".format( @@ -977,7 +976,7 @@ def test_add_RP_after_join_received_p1(request): ) step("r1: Verify PIM state") - result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False) + result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS) assert ( result is not True ), "Testcase {} : Failed \n " "r1: PIM state is up\n Error: {}".format( @@ -985,7 +984,7 @@ def test_add_RP_after_join_received_p1(request): ) step("r1: Verify ip mroutes") - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert ( result is not True ), "Testcase {} : Failed \n " "r1: mroutes are still present\n Error: {}".format( @@ -1006,12 +1005,12 @@ def test_add_RP_after_join_received_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify rp-info") result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -1030,13 +1029,14 @@ def test_add_RP_after_join_received_p1(request): step("r1 : Verify ip mroutes") result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - logger.info("Expected behavior: {}".format(result)) + logger.info("Expected behavior: %s", result) state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) @@ -1068,7 +1068,7 @@ def test_reachable_static_RP_after_join_p0(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1083,8 +1083,9 @@ def test_reachable_static_RP_after_join_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("r1: Make RP un-reachable") dut = "r1" @@ -1098,7 +1099,7 @@ def test_reachable_static_RP_after_join_p0(request): step("r1: Verify rp-info") rp_address = "1.0.2.17" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_ADDRESS, "Unknown", rp_address, SOURCE + tgen, TOPO, dut, GROUP_ADDRESS, "Unknown", rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -1113,16 +1114,14 @@ def test_reachable_static_RP_after_join_p0(request): step("r1 : Verify upstream IIF interface") iif = "r1-r2-eth1" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False) + result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream IIF interface is present\n Error: {}".format(tc_name, result) ) step("r1 : Verify upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream join state is joined and timer is running\n Error: {}".format( @@ -1131,7 +1130,7 @@ def test_reachable_static_RP_after_join_p0(request): ) step("r1 : Verify PIM state") - result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False) + result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS) assert ( result is not True ), "Testcase {} : Failed \n " "r1: PIM state is up\n Error: {}".format( @@ -1139,7 +1138,7 @@ def test_reachable_static_RP_after_join_p0(request): ) step("r1 : Verify ip mroutes") - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert ( result is not True ), "Testcase {} : Failed \n " "r1: mroutes are still present\n Error: {}".format( @@ -1156,7 +1155,7 @@ def test_reachable_static_RP_after_join_p0(request): step("r1 : Verify rp-info") result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -1175,14 +1174,15 @@ def test_reachable_static_RP_after_join_p0(request): step("r1 : Verify ip mroutes") result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - logger.info("Expected behavior: {}".format(result)) + logger.info("Expected behavior: %s", result) step("r1 : Verify pim interface traffic") state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -1235,7 +1235,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1272,8 +1272,9 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("r0 : Send IGMP join for 225.1.1.1") result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS, join_interval=1) @@ -1299,21 +1300,21 @@ def test_send_join_on_higher_preffered_rp_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify RP info for group 224.0.0.0/4") rp_address_1 = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify RP info for group 225.1.1.1") rp_address_2 = "1.0.4.17" iif = "r1-r4-eth3" - result = verify_pim_rp_info(tgen, topo, dut, GROUP_RANGE, iif, rp_address_2, SOURCE) + result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_RANGE, iif, rp_address_2, SOURCE) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify join is sent to higher preferred RP") @@ -1321,8 +1322,9 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -1344,7 +1346,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("r1 : Verify joinTx, pruneTx count before RP gets deleted") state_dict = {"r1": {"r1-r2-eth1": ["joinTx"], "r1-r4-eth3": ["pruneTx"]}} @@ -1352,8 +1354,9 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("r1 : Delete RP configuration for 225.1.1.1") input_dict = { @@ -1370,21 +1373,19 @@ def test_send_join_on_higher_preffered_rp_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify rp-info for group 224.0.0.0/4") iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify rp-info for group 225.1.1.1") iif = "r1-r4-eth3" - result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE, oif, rp_address_2, SOURCE, expected=False - ) + result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_RANGE, oif, rp_address_2, SOURCE) assert result is not True, ( "Testcase {} : Failed \n " "r1: rp-info is present for group 225.1.1.1 \n Error: {}".format( @@ -1399,7 +1400,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): iif = "r1-r2-eth1" result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - logger.info("Expected behavior: {}".format(result)) + logger.info("Expected behavior: %s", result) step( "r1 : Verify IIF and OIL in show ip pim state updated when higher" @@ -1433,8 +1434,9 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -1472,7 +1474,7 @@ def test_RP_configured_as_LHR_1_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1532,7 +1534,7 @@ def test_RP_configured_as_LHR_1_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Configure r1(LHR) as RP") @@ -1579,7 +1581,7 @@ def test_RP_configured_as_LHR_1_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) shutdown_bringup_interface(tgen, "r1", "lo", False) @@ -1592,7 +1594,7 @@ def test_RP_configured_as_LHR_1_p1(request): rp_address = "1.0.1.17" iif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -1641,9 +1643,7 @@ def test_RP_configured_as_LHR_1_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S, G) upstream join state is joined and join" @@ -1688,7 +1688,7 @@ def test_RP_configured_as_LHR_2_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1748,7 +1748,7 @@ def test_RP_configured_as_LHR_2_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1, r2, r3, r4: Configure r1(LHR) as RP") @@ -1795,14 +1795,14 @@ def test_RP_configured_as_LHR_2_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify RP info") dut = "r1" rp_address = "1.0.1.17" iif = "lo" - result = verify_pim_rp_info(tgen, topo, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) + result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r5: Send multicast traffic for group 225.1.1.1") @@ -1850,9 +1850,7 @@ def test_RP_configured_as_LHR_2_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -1898,7 +1896,7 @@ def test_RP_configured_as_FHR_1_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1957,7 +1955,7 @@ def test_RP_configured_as_FHR_1_p1(request): } }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1, r2, r3, r4: Configure r3(FHR) as RP") @@ -2004,7 +2002,7 @@ def test_RP_configured_as_FHR_1_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify RP info") @@ -2012,7 +2010,7 @@ def test_RP_configured_as_FHR_1_p1(request): rp_address = "1.0.3.17" iif = "r1-r3-eth2" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -2060,9 +2058,7 @@ def test_RP_configured_as_FHR_1_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2107,7 +2103,7 @@ def test_RP_configured_as_FHR_2_p2(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2167,7 +2163,7 @@ def test_RP_configured_as_FHR_2_p2(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1, r2, r3, r4: Configure r3(FHR) as RP") @@ -2214,7 +2210,7 @@ def test_RP_configured_as_FHR_2_p2(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify RP info") @@ -2222,7 +2218,7 @@ def test_RP_configured_as_FHR_2_p2(request): rp_address = "1.0.3.17" iif = "r1-r3-eth2" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -2271,9 +2267,7 @@ def test_RP_configured_as_FHR_2_p2(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2320,7 +2314,7 @@ def test_SPT_RPT_path_different_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2335,7 +2329,7 @@ def test_SPT_RPT_path_different_p1(request): dut = "r2" rp_address = "1.0.2.17" iif = "lo" - result = verify_pim_rp_info(tgen, topo, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) + result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r0: Send IGMP join") @@ -2400,9 +2394,7 @@ def test_SPT_RPT_path_different_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2424,9 +2416,7 @@ def test_SPT_RPT_path_different_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2475,7 +2465,7 @@ def test_clear_pim_configuration_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2492,7 +2482,7 @@ def test_clear_pim_configuration_p1(request): rp_address = "1.0.2.17" oif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -2572,7 +2562,7 @@ def test_restart_pimd_process_p2(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2589,7 +2579,7 @@ def test_restart_pimd_process_p2(request): rp_address = "1.0.2.17" oif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -2655,9 +2645,7 @@ def test_restart_pimd_process_p2(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2676,7 +2664,7 @@ def test_restart_pimd_process_p2(request): logger.info("waiting for 10 sec to make sure old mroute time is higher") sleep(10) uptime_before = verify_ip_mroutes( - tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, wait=60 + tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, mwait=60 ) assert isinstance(uptime_before, dict), "Testcase{} : Failed Error: {}".format( tc_name, result @@ -2692,7 +2680,7 @@ def test_restart_pimd_process_p2(request): sleep(5) uptime_after = verify_ip_mroutes( - tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, wait=10 + tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, mwait=10 ) assert isinstance(uptime_after, dict), "Testcase{} : Failed Error: {}".format( tc_name, result @@ -2731,7 +2719,7 @@ def test_multiple_groups_same_RP_address_p2(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2754,79 +2742,79 @@ def test_multiple_groups_same_RP_address_p2(request): rp_address = "1.0.2.17" oif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - GROUP_ADDRESS_LIST = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2 + group_address_list = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2 step("r0: Send IGMP join for 10 groups") - result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS_LIST, join_interval=1) + result = iperfSendIGMPJoin(tgen, "r0", group_address_list, join_interval=1) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify IGMP groups") dut = "r1" oif = "r1-r0-eth0" - result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS_LIST) + result = verify_igmp_groups(tgen, dut, oif, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r5: Send multicast traffic for group 225.1.1.1") - result = iperfSendTraffic(tgen, "r5", GROUP_ADDRESS_LIST, 32, 2500) + result = iperfSendTraffic(tgen, "r5", group_address_list, 32, 2500) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) upstream IIF interface") dut = "r1" iif = "r1-r2-eth1" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) upstream join state and join timer") - result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) ip mroutes") oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) upstream IIF interface") iif = "r1-r3-eth2" - result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) ip mroutes") - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) upstream IIF interface") dut = "r2" iif = "lo" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) upstream join state and join timer") - result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) ip mroutes") oif = "r2-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream IIF interface") dut = "r3" iif = "r3-r5-eth3" - result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, expected=False + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2837,20 +2825,20 @@ def test_multiple_groups_same_RP_address_p2(request): step("r3: Verify (S, G) ip mroutes") oif = "r3-r1-eth0" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream IIF interface") dut = "r2" iif = "r2-r3-eth1" result = verify_upstream_iif( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, joinState="NotJoined" + tgen, dut, iif, SOURCE_ADDRESS, group_address_list, joinState="NotJoined" ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, expected=False + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2861,7 +2849,7 @@ def test_multiple_groups_same_RP_address_p2(request): step("r2: Verify (S, G) ip mroutes") oif = "none" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Delete RP configuration") @@ -2879,7 +2867,7 @@ def test_multiple_groups_same_RP_address_p2(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Shut the interface r1-r2-eth1 from R1 to R2") @@ -2905,7 +2893,7 @@ def test_multiple_groups_same_RP_address_p2(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Shut the interface r1-r0-eth0 from R1 to R2") @@ -2919,59 +2907,59 @@ def test_multiple_groups_same_RP_address_p2(request): step("r1: Verify (*, G) upstream IIF interface") dut = "r1" iif = "r1-r2-eth1" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) upstream join state and join timer") - result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) ip mroutes") oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) upstream IIF interface") iif = "r1-r3-eth2" - result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) ip mroutes") - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) upstream IIF interface") dut = "r2" iif = "lo" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) upstream join state and join timer") - result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) ip mroutes") oif = "r2-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream IIF interface") dut = "r2" iif = "r2-r3-eth1" result = verify_upstream_iif( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, joinState="NotJoined" + tgen, dut, iif, SOURCE_ADDRESS, group_address_list, joinState="NotJoined" ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, expected=False + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2982,18 +2970,18 @@ def test_multiple_groups_same_RP_address_p2(request): step("r2: Verify (S, G) ip mroutes") oif = "none" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream IIF interface") dut = "r3" iif = "r3-r5-eth3" - result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, expected=False + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3004,7 +2992,7 @@ def test_multiple_groups_same_RP_address_p2(request): step("r3: Verify (S, G) ip mroutes") oif = "r3-r1-eth0" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) write_test_footer(tc_name) @@ -3040,7 +3028,7 @@ def test_multiple_groups_different_RP_address_p2(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -3060,7 +3048,7 @@ def test_multiple_groups_different_RP_address_p2(request): } } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) input_dict = { @@ -3085,7 +3073,7 @@ def test_multiple_groups_different_RP_address_p2(request): } }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify RP info") @@ -3093,7 +3081,7 @@ def test_multiple_groups_different_RP_address_p2(request): rp_address = "1.0.2.17" oif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_LIST_1, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_LIST_1, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -3101,23 +3089,23 @@ def test_multiple_groups_different_RP_address_p2(request): dut = "r4" rp_address = "1.0.4.17" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_LIST_2, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_LIST_2, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - GROUP_ADDRESS_LIST = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2 + group_address_list = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2 step("r0: Send IGMP join") - result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS_LIST, join_interval=1) + result = iperfSendIGMPJoin(tgen, "r0", group_address_list, join_interval=1) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify IGMP groups") dut = "r1" oif = "r1-r0-eth0" - result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS_LIST) + result = verify_igmp_groups(tgen, dut, oif, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r5: Send multicast traffic for group 225.1.1.1") - result = iperfSendTraffic(tgen, "r5", GROUP_ADDRESS_LIST, 32, 2500) + result = iperfSendTraffic(tgen, "r5", group_address_list, 32, 2500) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) upstream IIF interface") @@ -3175,7 +3163,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r2: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3199,7 +3187,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3271,7 +3259,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r4: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3295,7 +3283,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2 ) assert result is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, result @@ -3333,7 +3321,7 @@ def test_multiple_groups_different_RP_address_p2(request): } }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1, r2, r3, r4: Re-configure RP") @@ -3359,7 +3347,7 @@ def test_multiple_groups_different_RP_address_p2(request): } }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Shut the interface r1-r2-eth1 from R1 to R2") @@ -3448,7 +3436,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r2: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3472,7 +3460,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3544,7 +3532,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r4: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3568,7 +3556,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3611,7 +3599,7 @@ def test_shutdown_primary_path_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -3630,7 +3618,7 @@ def test_shutdown_primary_path_p1(request): rp_address = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -3701,7 +3689,7 @@ def test_shutdown_primary_path_p1(request): dut = "r1" iif = "r1-r3-eth2" oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r1: (*,G) mroutes are not cleared after shut of R1 to R3 link\n Error: {}".format( @@ -3713,7 +3701,7 @@ def test_shutdown_primary_path_p1(request): dut = "r2" iif = "lo" oif = "r2-r3-eth1" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r2: (*,G) mroutes are not cleared after shut of R1 to R3 link\n Error: {}".format( @@ -3725,7 +3713,7 @@ def test_shutdown_primary_path_p1(request): dut = "r3" iif = "r3-r2-eth1" oif = "r3-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r3: (*,G) mroutes are not cleared after shut of R1 to R3 link\n Error: {}".format( @@ -3804,7 +3792,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -3821,7 +3809,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): rp_address = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -3863,7 +3851,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Shut the interface r1-r2-eth1 from R1 to R2") @@ -3890,7 +3878,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): dut = "r1" iif = "r1-r2-eth1" oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r1: (*,G) mroutes are not cleared after shut of R1 to R0 link\n Error: {}".format( @@ -3902,7 +3890,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): dut = "r2" iif = "lo" oif = "r2-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r2: (*,G) mroutes are not cleared after shut of R1 to R0 link\n Error: {}".format( @@ -3937,7 +3925,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -3954,7 +3942,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): rp_address = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -3995,7 +3983,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Shut the RP interface lo") @@ -4017,7 +4005,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): dut = "r1" iif = "r1-r2-eth1" oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r1: (*,G) mroutes are not cleared after shut of R1 to R2 and R3 link\n Error: {}".format( @@ -4029,7 +4017,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): dut = "r2" iif = "lo" oif = "r2-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r2: (*,G) mroutes are not cleared after shut of R1 to R2 and R3 link\n Error: {}".format( @@ -4041,5 +4029,5 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): if __name__ == "__main__": - args = ["-s"] + sys.argv[1:] - sys.exit(pytest.main(args)) + ARGS = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(ARGS)) diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py index a4cc8e8e7a..a16c4ae297 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py @@ -40,10 +40,11 @@ import platform CWD = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) + # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo from lib.topogen import Topogen, get_topogen +from mininet.topo import Topo from lib.topotest import version_cmp # Import topoJson from lib, to create topology and initial configuration @@ -68,15 +69,14 @@ from lib.topojson import build_topo_from_json, build_config_from_json pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] # Reading the data from JSON File for topology creation -jsonFile = "{}/static_routes_topo1_ebgp.json".format(CWD) +JSONFILE = "{}/static_routes_topo1_ebgp.json".format(CWD) try: - with open(jsonFile, "r") as topoJson: + with open(JSONFILE, "r") as topoJson: topo = json.load(topoJson) except IOError: - assert False, "Could not read file {}".format(jsonFile) + assert False, "Could not read file {}".format(JSONFILE) # Global variables -BGP_CONVERGENCE = False ADDR_TYPES = check_address_types() NETWORK = {"ipv4": ["11.0.20.1/32", "11.0.20.2/32"], "ipv6": ["2::1/128", "2::2/128"]} NETWORK2 = {"ipv4": "11.0.20.1/32", "ipv6": "2::1/128"} @@ -98,6 +98,10 @@ class CreateTopo(Topo): # Building topology from json file build_topo_from_json(tgen, topo) + def dumdum(self): + """ Dummy """ + print("%s", self.name) + def setup_module(mod): """ @@ -105,7 +109,7 @@ def setup_module(mod): * `mod`: module name """ - global topo + testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("=" * 40) @@ -131,16 +135,14 @@ def setup_module(mod): pytest.skip(error_msg) # Checking BGP convergence - global BGP_CONVERGENCE - global ADDR_TYPES + # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) + # Api call verify whether BGP is converged - BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo) - assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format( - BGP_CONVERGENCE - ) + converged = verify_bgp_convergence(tgen, topo) + assert converged is True, "setup_module :Failed \n Error: {}".format(converged) logger.info("Running setup_module() done") @@ -152,7 +154,7 @@ def teardown_module(mod): * `mod`: module name """ - logger.info("Running teardown_module to delete topology") + logger.info("Running teardown_module to delete topology: %s", mod) tgen = get_topogen() @@ -166,7 +168,11 @@ def teardown_module(mod): def populate_nh(): - NEXT_HOP_IP = { + """ + Populate nexthops. + """ + + next_hop_ip = { "nh1": { "ipv4": topo["routers"]["r1"]["links"]["r2-link0"]["ipv4"].split("/")[0], "ipv6": topo["routers"]["r1"]["links"]["r2-link0"]["ipv6"].split("/")[0], @@ -176,7 +182,7 @@ def populate_nh(): "ipv6": topo["routers"]["r1"]["links"]["r2-link1"]["ipv6"].split("/")[0], }, } - return NEXT_HOP_IP + return next_hop_ip ##################################################### @@ -199,7 +205,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): pytest.skip(tgen.errors) reset_config_on_routers(tgen) - NEXT_HOP_IP = populate_nh() + next_hop_ip = populate_nh() step( "Configure IPv4 static route (10.1.1.1) in R2 with next hop N1" @@ -213,11 +219,11 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], }, { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], }, ] } @@ -233,7 +239,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "On R2, static route installed in RIB using show ip route" " with 2 ECMP next hop " ) - nh = [NEXT_HOP_IP["nh1"][addr_type], NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type], next_hop_ip["nh2"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -268,7 +274,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "delete": True, } ] @@ -284,7 +290,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "On R2, after removing the static route with N1 , " "route become active with nexthop N2 and vice versa." ) - nh = NEXT_HOP_IP["nh1"][addr_type] + nh = next_hop_ip["nh1"][addr_type] result = verify_rib( tgen, addr_type, @@ -300,12 +306,13 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): tc_name ) - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N1") @@ -314,7 +321,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], } ] } @@ -333,7 +340,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "delete": True, } ] @@ -350,7 +357,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "On R2, after removing the static route with N2 , " "route become active with nexthop N1 and vice versa." ) - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, addr_type, @@ -360,15 +367,19 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") input_dict_4 = { @@ -376,7 +387,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], } ] } @@ -395,14 +406,15 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): step("Only one the nexthops should be active in RIB.") - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) - nh = NEXT_HOP_IP["nh1"][addr_type] + nh = next_hop_ip["nh1"][addr_type] result = verify_rib( tgen, addr_type, @@ -412,15 +424,21 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) dut = "r3" result = verify_bgp_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) result = verify_rib( tgen, @@ -431,27 +449,35 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) dut = "r2" - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) dut = "r2" step("No shut the nexthop interface N1") @@ -461,13 +487,14 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "after shut of nexthop N1 , route become active " "with nexthop N2 and vice versa." ) - nh = [NEXT_HOP_IP["nh1"][addr_type], NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type], next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Shut nexthop interface N2") intf = topo["routers"]["r2"]["links"]["r1-link1"]["interface"] @@ -478,7 +505,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): " after shut of nexthop N1 , route become active with " "nexthop N2 and vice versa." ) - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, @@ -489,28 +516,36 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("No shut nexthop interface N2") dut = "r2" @@ -520,24 +555,29 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "after shut of nexthop N1 , route become active " "with nexthop N2 and vice versa." ) - nh = [NEXT_HOP_IP["nh1"][addr_type], NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type], next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -553,19 +593,26 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -583,7 +630,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): pytest.skip(tgen.errors) reset_config_on_routers(tgen) - NEXT_HOP_IP = populate_nh() + step( "Configure IPv4 static route (10.1.1.1) in R2 with next hop N1" "(28.1.1.2 ) AD 10 and N2 (29.1.1.2) AD 20 , Static route next-hop" @@ -592,19 +639,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): ) reset_config_on_routers(tgen) - NEXT_HOP_IP = populate_nh() + next_hop_ip = populate_nh() for addr_type in ADDR_TYPES: input_dict_4 = { "r2": { "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, }, { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, }, ] @@ -625,33 +672,34 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] } } - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] } } - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -664,8 +712,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) step("Configure IBGP IPv4 peering between R2 and R3 router.") step("Explicit route is added in R3 for R2 nexthop rechability") @@ -673,11 +722,11 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "r3": { "static_routes": [ { - "network": NEXT_HOP_IP["nh1"][addr_type] + "/32", + "network": next_hop_ip["nh1"][addr_type] + "/32", "next_hop": topo["routers"]["r2"]["links"]["r3"][addr_type], }, { - "network": NEXT_HOP_IP["nh2"][addr_type] + "/32", + "network": next_hop_ip["nh2"][addr_type] + "/32", "next_hop": topo["routers"]["r2"]["links"]["r3"][addr_type], }, ] @@ -712,7 +761,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, "delete": True, } @@ -735,13 +784,13 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] } } - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -754,26 +803,28 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] } } - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) step("Configure the static route with nexthop N1") rte1_nh1 = { @@ -781,7 +832,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] @@ -799,7 +850,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, "delete": True, } @@ -816,7 +867,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "On R2, after removing the static route with N2 , " "route become active with nexthop N1 and vice versa." ) - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, addr_type, @@ -826,15 +877,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") rte2_nh2 = { @@ -842,7 +897,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] @@ -862,7 +917,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): step("after shut of nexthop N1 , route become active with nexthop N2") - nh = NEXT_HOP_IP["nh1"][addr_type] + nh = next_hop_ip["nh1"][addr_type] result = verify_rib( tgen, addr_type, @@ -872,15 +927,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("No shut the nexthop interface N1") shutdown_bringup_interface(tgen, dut, intf, True) @@ -889,13 +948,14 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "after shut of nexthop N1 , route become active " "with nexthop N2 and vice versa." ) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Shut nexthop interface N2") intf = topo["routers"]["r2"]["links"]["r1-link1"]["interface"] @@ -906,7 +966,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): " after shut of nexthop N1 , route become active with " "nexthop N2 and vice versa." ) - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, @@ -917,15 +977,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("No shut nexthop interface N2") shutdown_bringup_interface(tgen, dut, intf, True) @@ -939,33 +1003,34 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] } } - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] } } - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -978,8 +1043,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" @@ -994,8 +1060,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r2" step("Reload the FRR router") @@ -1013,39 +1080,41 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] } } - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte1_nh1, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] } } - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -1058,14 +1127,16 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte2_nh2, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) result = verify_rib( tgen, @@ -1077,8 +1148,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) write_test_footer(tc_name) @@ -1148,14 +1220,20 @@ def test_same_rte_from_bgp_static_p0_tc5_ebgp(request): step("Verify on R3 , route receive on R3 BGP table ") dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("Verify route installed in the RIB and FIB of R3") protocol = "bgp" result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step( "Configure 2 links/interfaces between R1 and R3 , keep one" @@ -1206,15 +1284,19 @@ def test_same_rte_from_bgp_static_p0_tc5_ebgp(request): ) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in BGP RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in BGP RIB".format( + tc_name + ) protocol = "bgp" result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) step("Remove the static route on R3 configured with active" "interface") for addr_type in ADDR_TYPES: @@ -1249,15 +1331,19 @@ def test_same_rte_from_bgp_static_p0_tc5_ebgp(request): ) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in BGP RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in BGP RIB".format( + tc_name + ) protocol = "bgp" result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py index 6649915dec..bbb4370a93 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py @@ -314,8 +314,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -338,8 +339,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -384,8 +386,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed\nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed\nError: Routes is" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") for addr_type in ADDR_TYPES: @@ -410,8 +415,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed\nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed\nError: Routes are" " missing in RIB".format( + tc_name + ) protocol = "static" step("Random shut of the nexthop interfaces") @@ -455,8 +463,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") dut = "r2" @@ -493,8 +502,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) for addr_type in ADDR_TYPES: input_dict_4 = { @@ -546,8 +556,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Remove the redistribute static knob") for addr_type in ADDR_TYPES: @@ -580,8 +591,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -661,8 +675,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -679,8 +694,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -723,8 +739,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") @@ -770,8 +789,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): nh.append(NEXT_HOP_IP["nh" + str(nhp)][addr_type]) @@ -787,8 +807,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -815,8 +836,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -826,8 +850,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) dut = "r2" protocol = "static" @@ -955,8 +980,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -971,8 +997,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -1015,8 +1042,11 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") @@ -1062,8 +1092,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): nh.append(NEXT_HOP_IP["nh" + str(nhp)][addr_type]) @@ -1077,8 +1108,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -1105,8 +1137,11 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -1116,8 +1151,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) dut = "r2" protocol = "static" @@ -1230,8 +1266,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") nh = [] @@ -1249,8 +1286,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -1312,8 +1350,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") for addr_type in ADDR_TYPES: @@ -1355,8 +1396,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - "lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + "lowest AD is missing in RIB".format(tc_name) + ) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -1383,8 +1426,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -1394,8 +1440,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") for addr_type in ADDR_TYPES: @@ -1434,8 +1481,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route " - " is still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Route " + " is still present in RIB".format(tc_name) + ) step("Reconfigure the deleted routes and verify they are installed") for nhp in range(1, 9): @@ -1460,8 +1509,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol = "static" nh = NEXT_HOP_IP["nh1"][addr_type] result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route " - " is still present in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route " + " is still present in RIB".format(tc_name) + ) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -1577,8 +1628,9 @@ def test_static_route_delete_p0_tc11_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") nh = [] @@ -1594,8 +1646,9 @@ def test_static_route_delete_p0_tc11_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -1647,8 +1700,11 @@ def test_static_route_delete_p0_tc11_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) for addr_type in ADDR_TYPES: for nhp in range(1, 9): @@ -1715,8 +1771,12 @@ def test_static_route_delete_p0_tc11_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still active in RIB".format( + tc_name + ) + write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py index 175a1123d7..8525e3655c 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py @@ -297,8 +297,9 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: input_dict_2 = { @@ -351,8 +352,11 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by" "one") @@ -379,8 +383,9 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -407,8 +412,11 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -418,8 +426,9 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -429,8 +438,9 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) write_test_footer(tc_name) @@ -509,8 +519,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -525,8 +537,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -569,8 +583,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -613,8 +629,11 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by" "one") for addr_type in ADDR_TYPES: @@ -655,8 +674,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -671,8 +692,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -699,8 +722,11 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -710,8 +736,9 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -740,8 +767,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -756,8 +785,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) write_test_footer(tc_name) @@ -818,18 +849,25 @@ def test_bgp_local_nexthop_p1_tc14_ebgp(request): step("Verify R2 BGP table has IPv4 route") dut = "r2" result = verify_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB of R2".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB of R2".format( + tc_name + ) step(" Verify route did not install in the R3 BGP table, RIB/FIB") dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in BGP RIB of R2".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes is" + " still present in BGP RIB of R2".format(tc_name) + ) result = verify_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB of R2".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes is" + " still present in RIB of R2".format(tc_name) + ) write_test_footer(tc_name) @@ -889,8 +927,9 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, next_hop=nh ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) input_dict_nh = { "r1": { @@ -902,8 +941,9 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): } } result = verify_ip_nht(tgen, input_dict_nh) - assert result is True, "Testcase {} : Failed \nError: Nexthop is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Nexthop is" " missing in RIB".format(tc_name) step( "Shut / no shut IPv4 and IPv6 static next hop interface from" @@ -925,8 +965,9 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) shutdown_bringup_interface(tgen, dut, intf, True) @@ -970,8 +1011,11 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -1034,8 +1078,9 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure route-map on R2 with allow tag1 and deny tag2") @@ -1116,8 +1161,10 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_0, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route with " - "tag 4002 is still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Route with " + "tag 4002 is still present in RIB".format(tc_name) + ) dut = "r2" input_dict_1 = { @@ -1125,8 +1172,10 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): } result = verify_rib(tgen, addr_type, dut, input_dict_0, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route with " - "tag 4001 is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + "tag 4001 is missing in RIB".format(tc_name) + ) step("Modify the route-map to allow tag2 and deny tag1") # Create route map @@ -1164,8 +1213,10 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): } result = verify_rib(tgen, addr_type, dut, input_dict_0, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route with " - "tag 4002 is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + "tag 4002 is missing in RIB".format(tc_name) + ) input_dict_1 = { "r2": {"static_routes": [{"network": NETWORK[addr_type], "tag": 4001}]} @@ -1173,8 +1224,10 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_1, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route with " - "tag 4001 is still present in RIB".format(tc_name, result) + assert result is not True, ( + "Testcase {} : Failed \nError: Route with " + "tag 4001 is still present in RIB".format(tc_name) + ) step("Configure one static route with 2 ECMP nexthop N1 and N2") step("For N1 configure tag 1 and for N2 configure tag 2") @@ -1213,8 +1266,9 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("shut/no shut of tag1 and tag2 nexthop") diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py index 5d4950a70e..812b39797f 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py @@ -109,7 +109,7 @@ def setup_module(mod): Set up the pytest environment. * `mod`: module name """ - global topo + testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("=" * 40) @@ -135,8 +135,7 @@ def setup_module(mod): pytest.skip(error_msg) # Checking BGP convergence - global BGP_CONVERGENCE - global ADDR_TYPES + # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) @@ -173,7 +172,7 @@ def teardown_module(mod): # Tests starting # ##################################################### -def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): +def test_static_routes_rmap_pfxlist_p0_tc7_ebgp(request): """ Verify static route are blocked from route-map & prefix-list applied in BGP nbrs @@ -200,7 +199,7 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): ) for addr_type in ADDR_TYPES: - # Api call to modfiy BGP timerse + # Api call to modify BGP timers input_dict = { "r2": { "bgp": { @@ -241,8 +240,11 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): step(" All BGP nbrs are down as authentication is mismatch on both" " the sides") bgp_convergence = verify_bgp_convergence(tgen, topo, expected=False) - assert bgp_convergence is not True, "Testcase {} : " - "Failed \n BGP nbrs must be down. Error: {}".format(tc_name, bgp_convergence) + assert ( + bgp_convergence is not True + ), "Testcase {} : " "Failed \n BGP nbrs must be down. Error: {}".format( + tc_name, bgp_convergence + ) step( "Configure 4 IPv4 and 4 IPv6 nbrs with macthing password " @@ -337,8 +339,9 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): "show ip prefix list" ) result = verify_prefix_lists(tgen, input_dict_2) - assert result is not True, "Testcase {} : Failed \n" - " Error: {}".format(tc_name, result) + assert result is not True, "Testcase {} : Failed \n" " Error: {}".format( + tc_name, result + ) step("Redistribute all the routes (connected, static)") input_dict_2_r1 = { @@ -588,8 +591,10 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): result4 = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result4 is not True, "Testcase {} : Failed , VM1 route is " - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is not True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) step( "VM4 and VM6 IPV4 and IPv6 address are present in local and " @@ -964,8 +969,10 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) step("vm4 should be present in FRR2") dut = "r2" @@ -976,8 +983,10 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) dut = "r3" protocol = "bgp" diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py index 8c2fdfca13..4e23a72423 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py @@ -242,8 +242,9 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure IBGP IPv4 peering between R2 and R3 router.") step("Configure redistribute static in BGP on R2 router") @@ -296,15 +297,19 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N1") @@ -359,15 +364,19 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") input_dict_4 = { @@ -398,8 +407,9 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) nh = NEXT_HOP_IP["nh1"][addr_type] result = verify_rib( @@ -411,15 +421,21 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) dut = "r3" result = verify_bgp_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) result = verify_rib( tgen, @@ -430,27 +446,35 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) dut = "r2" nh = [NEXT_HOP_IP["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) dut = "r2" step("No shut the nexthop interface N1") @@ -465,8 +489,9 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Shut nexthop interface N2") intf = topo["routers"]["r2"]["links"]["r1-link1"]["interface"] @@ -488,8 +513,11 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh1"][addr_type]] dut = "r2" @@ -497,19 +525,24 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("No shut nexthop interface N2") dut = "r2" @@ -524,19 +557,24 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -552,19 +590,26 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -636,8 +681,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -663,8 +709,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) step("Configure IBGP IPv4 peering between R2 and R3 router.") step("Explicit route is added in R3 for R2 nexthop rechability") @@ -753,8 +800,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -771,8 +819,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) step("Configure the static route with nexthop N1") rte1_nh1 = { @@ -825,15 +874,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") rte2_nh2 = { @@ -871,15 +924,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("No shut the nexthop interface N1") shutdown_bringup_interface(tgen, dut, intf, True) @@ -893,8 +950,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Shut nexthop interface N2") intf = topo["routers"]["r2"]["links"]["r1-link1"]["interface"] @@ -916,15 +974,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("No shut nexthop interface N2") shutdown_bringup_interface(tgen, dut, intf, True) @@ -950,8 +1012,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -977,8 +1040,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" @@ -993,8 +1057,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r2" step("Reload the FRR router") @@ -1024,14 +1089,16 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte1_nh1, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -1057,14 +1124,16 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte2_nh2, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) result = verify_rib( tgen, @@ -1076,8 +1145,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py index 644ddc02d4..ee0e01b411 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py @@ -318,8 +318,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -342,8 +343,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -388,8 +390,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed\nError: Routes is" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed\nError: Routes is" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") for addr_type in ADDR_TYPES: @@ -414,8 +419,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed\nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed\nError: Routes are" " missing in RIB".format( + tc_name + ) protocol = "static" step("Random shut of the nexthop interfaces") @@ -423,7 +431,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): # Shutdown interface dut = "r2" step( - " interface which is about to be shut no shut between r1 and r2 is " "%s", + " interface which is about to be shut no shut between r1 and r2 is %s", topo["routers"]["r2"]["links"]["r1-link{}".format(randnum)]["interface"], ) intf = topo["routers"]["r2"]["links"]["r1-link{}".format(randnum)]["interface"] @@ -459,8 +467,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") dut = "r2" @@ -497,8 +506,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) for addr_type in ADDR_TYPES: input_dict_4 = { @@ -550,8 +560,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Remove the redistribute static knob") for addr_type in ADDR_TYPES: @@ -584,8 +595,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -665,8 +679,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -683,8 +698,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -727,8 +743,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") @@ -774,8 +793,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): nh.append(NEXT_HOP_IP["nh" + str(nhp)][addr_type]) @@ -791,8 +811,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -819,8 +840,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -830,8 +854,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) protocol = "bgp" # this is next hop reachability route in r3 as we are using ibgp @@ -856,8 +881,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): for addr_type in ADDR_TYPES: input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) protocol = "static" dut = "r2" @@ -866,7 +892,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {}: Failed \n " "Error: Routes are missing in RIB".format(tc_name) + ), "Testcase {}: Failed \n Error: Routes are missing in RIB".format(tc_name) protocol = "bgp" dut = "r3" @@ -875,7 +901,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {}: Failed \n " "Error: Routes are missing in RIB".format(tc_name) + ), "Testcase {}: Failed \n Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -888,7 +914,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \nError: Routes are still present in RIB".format( tc_name ) @@ -912,7 +938,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \nError: Routes are still present in RIB".format( tc_name ) @@ -923,7 +949,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \nError: Routes are still present in RIB".format( tc_name ) @@ -964,8 +990,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " strill present in RIB of R3".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes are" + " strill present in RIB of R3".format(tc_name) + ) write_test_footer(tc_name) @@ -1060,8 +1088,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -1076,8 +1105,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -1120,8 +1150,11 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") @@ -1167,8 +1200,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): nh.append(NEXT_HOP_IP["nh" + str(nhp)][addr_type]) @@ -1182,8 +1216,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -1210,8 +1245,11 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -1221,8 +1259,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) dut = "r2" protocol = "bgp" @@ -1249,8 +1288,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): for addr_type in ADDR_TYPES: input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) protocol = "static" dut = "r2" @@ -1259,7 +1299,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {}: Failed \n " "Error: Routes are missing in RIB".format(tc_name) + ), "Testcase {}: Failed \n Error: Routes are missing in RIB".format(tc_name) protocol = "bgp" dut = "r3" @@ -1268,7 +1308,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {}: Failed \n " "Error: Routes are missing in RIB".format(tc_name) + ), "Testcase {}: Failed \n Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -1281,7 +1321,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \n Error: Routes are still present in RIB".format( tc_name ) @@ -1305,7 +1345,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \n Error: Routes are still present in RIB".format( tc_name ) @@ -1316,7 +1356,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \n Error: Routes are still present in RIB".format( tc_name ) @@ -1357,8 +1397,10 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB of R3".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes are" + " still present in RIB of R3".format(tc_name) + ) write_test_footer(tc_name) @@ -1453,8 +1495,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") nh = [] @@ -1472,8 +1515,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -1535,8 +1579,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") for addr_type in ADDR_TYPES: @@ -1578,8 +1625,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - "lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + "lowest AD is missing in RIB".format(tc_name) + ) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -1606,8 +1655,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -1617,8 +1669,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") for addr_type in ADDR_TYPES: @@ -1657,8 +1710,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route " - " is still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Route " + " is still present in RIB".format(tc_name) + ) step("Reconfigure the deleted routes and verify they are installed") for nhp in range(1, 9): @@ -1683,8 +1738,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol = "static" nh = NEXT_HOP_IP["nh1"][addr_type] result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route " - " is still present in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route " + " is still present in RIB".format(tc_name) + ) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -1704,9 +1761,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): ) assert ( result is True - ), "Testcase {} : Failed \nError: Route " " is missing in RIB".format( - tc_name - ) + ), "Testcase {} : Failed \nError: Route is missing in RIB".format(tc_name) step("Remove the redistribute static knob") for addr_type in ADDR_TYPES: @@ -1750,8 +1805,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -1845,8 +1903,9 @@ def test_static_route_delete_p0_tc11_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") nh = [] @@ -1862,8 +1921,9 @@ def test_static_route_delete_p0_tc11_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -1915,8 +1975,11 @@ def test_static_route_delete_p0_tc11_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) for addr_type in ADDR_TYPES: for nhp in range(1, 9): @@ -1983,8 +2046,12 @@ def test_static_route_delete_p0_tc11_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still active in RIB".format( + tc_name + ) + write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py index 8f9d88a442..c84c88ac35 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py @@ -298,8 +298,9 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: input_dict_2 = { @@ -352,8 +353,11 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by" "one") @@ -380,8 +384,9 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -408,8 +413,11 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -419,8 +427,9 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -430,8 +439,9 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) write_test_footer(tc_name) @@ -510,8 +520,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -526,8 +538,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -570,8 +584,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -614,8 +630,11 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by" "one") for addr_type in ADDR_TYPES: @@ -656,8 +675,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -672,8 +693,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -700,8 +723,11 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -711,8 +737,9 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -741,8 +768,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -757,8 +786,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Remove the redistribute static knob") @@ -796,8 +827,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " strill present in RIB of R3".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes are" + " still present in RIB of R3".format(tc_name) + ) write_test_footer(tc_name) @@ -858,18 +891,25 @@ def test_bgp_local_nexthop_p1_tc14_ibgp(request): step("Verify R2 BGP table has IPv4 route") dut = "r2" result = verify_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes is" - " missing in RIB of R2".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB of R2".format( + tc_name + ) step(" Verify route did not install in the R3 BGP table, RIB/FIB") dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in BGP RIB of R2".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes is" + " still present in BGP RIB of R2".format(tc_name) + ) result = verify_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" - " still present in RIB of R2".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes is" + " still present in RIB of R2".format(tc_name) + ) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py index 09c437c3c4..a82ee64538 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py @@ -239,8 +239,11 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): step(" All BGP nbrs are down as authentication is mismatch on both" " the sides") bgp_convergence = verify_bgp_convergence(tgen, topo, expected=False) - assert bgp_convergence is not True, "Testcase {} : " - "Failed \n BGP nbrs must be down. Error: {}".format(tc_name, bgp_convergence) + assert ( + bgp_convergence is not True + ), "Testcase {} : " "Failed \n BGP nbrs must be down. Error: {}".format( + tc_name, bgp_convergence + ) step( "Configure 4 IPv4 and 4 IPv6 nbrs with macthing password " @@ -335,8 +338,9 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): "show ip prefix list" ) result = verify_prefix_lists(tgen, input_dict_2) - assert result is not True, "Testcase {} : Failed \n" - " Error: {}".format(tc_name, result) + assert result is not True, "Testcase {} : Failed \n" " Error: {}".format( + tc_name, result + ) step("Redistribute all the routes (connected, static)") input_dict_2_r1 = { @@ -586,8 +590,10 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): result4 = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result4 is not True, "Testcase {} : Failed , VM1 route is " - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is not True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) step( "VM4 and VM6 IPV4 and IPv6 address are present in local and " @@ -962,8 +968,10 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) step("vm4 should be present in FRR2") dut = "r2" @@ -974,8 +982,10 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) dut = "r3" protocol = "bgp" diff --git a/tools/frr-reload.py b/tools/frr-reload.py index a617c0a9c5..c28a971525 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -423,17 +423,6 @@ class Config(object): re_lege.group(2), re_lege.group(4), ) - re_lege = re.search(r"(.*)ge\s+(\d+)\s+le\s+(\d+)(.*)", legestr) - - if re_lege and ( - (re_key_rt.group(1) == "ip" and re_lege.group(3) == "32") - or (re_key_rt.group(1) == "ipv6" and re_lege.group(3) == "128") - ): - legestr = "%sge %s%s" % ( - re_lege.group(1), - re_lege.group(2), - re_lege.group(4), - ) key[0] = "%s prefix-list%s%s %s%s" % ( re_key_rt.group(1), diff --git a/bgpd/valgrind.supp b/tools/valgrind.supp index 31f2477a58..fbfb640b2a 100644 --- a/bgpd/valgrind.supp +++ b/tools/valgrind.supp @@ -16,3 +16,17 @@ obj:/usr/lib/x86_64-linux-gnu/libyang.so.1.9.2 fun:ly_load_plugins } +{ + <zprivs_init leak in a function we do not control> + Memcheck:Leak + fun:calloc + fun:cap_init + fun:zprivs_caps_init +} +{ + <sqlite3 leak in a function we do not control> + Memcheck:Leak + fun:malloc + ... + fun:sqlite3_step +} diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c index 80e06d913d..30f4a44769 100644 --- a/zebra/zebra_evpn.c +++ b/zebra/zebra_evpn.c @@ -1011,6 +1011,7 @@ zebra_evpn_t *zebra_evpn_lookup(vni_t vni) */ zebra_evpn_t *zebra_evpn_add(vni_t vni) { + char buffer[80]; struct zebra_vrf *zvrf; zebra_evpn_t tmp_zevpn; zebra_evpn_t *zevpn = NULL; @@ -1024,11 +1025,14 @@ zebra_evpn_t *zebra_evpn_add(vni_t vni) zebra_evpn_es_evi_init(zevpn); + snprintf(buffer, sizeof(buffer), "Zebra EVPN MAC Table vni: %u", vni); /* Create hash table for MAC */ - zevpn->mac_table = zebra_mac_db_create("Zebra EVPN MAC Table"); + zevpn->mac_table = zebra_mac_db_create(buffer); + snprintf(buffer, sizeof(buffer), "Zebra EVPN Neighbor Table vni: %u", + vni); /* Create hash table for neighbors */ - zevpn->neigh_table = zebra_neigh_db_create("Zebra EVPN Neighbor Table"); + zevpn->neigh_table = zebra_neigh_db_create(buffer); return zevpn; } diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c index 7bbe092d8c..fe3167dc29 100644 --- a/zebra/zebra_evpn_mac.c +++ b/zebra/zebra_evpn_mac.c @@ -1323,7 +1323,7 @@ int zebra_evpn_mac_send_del_to_client(vni_t vni, struct ethaddr *macaddr, */ struct hash *zebra_mac_db_create(const char *desc) { - return hash_create(mac_hash_keymake, mac_cmp, desc); + return hash_create_size(8, mac_hash_keymake, mac_cmp, desc); } /* program sync mac flags in the dataplane */ diff --git a/zebra/zebra_evpn_neigh.c b/zebra/zebra_evpn_neigh.c index d1b93dbe8a..4c7a1542fc 100644 --- a/zebra/zebra_evpn_neigh.c +++ b/zebra/zebra_evpn_neigh.c @@ -85,7 +85,7 @@ int neigh_list_cmp(void *p1, void *p2) struct hash *zebra_neigh_db_create(const char *desc) { - return hash_create(neigh_hash_keymake, neigh_cmp, desc); + return hash_create_size(8, neigh_hash_keymake, neigh_cmp, desc); } uint32_t num_dup_detected_neighs(zebra_evpn_t *zevpn) diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index a923782bfe..850ca17636 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -3952,11 +3952,18 @@ void zebra_mpls_close_tables(struct zebra_vrf *zvrf) */ void zebra_mpls_init_tables(struct zebra_vrf *zvrf) { + char buffer[80]; + if (!zvrf) return; - zvrf->slsp_table = - hash_create(label_hash, label_cmp, "ZEBRA SLSP table"); - zvrf->lsp_table = hash_create(label_hash, label_cmp, "ZEBRA LSP table"); + + snprintf(buffer, sizeof(buffer), "ZEBRA SLSP table: %s", + zvrf->vrf->name); + zvrf->slsp_table = hash_create_size(8, label_hash, label_cmp, buffer); + + snprintf(buffer, sizeof(buffer), "ZEBRA LSP table: %s", + zvrf->vrf->name); + zvrf->lsp_table = hash_create_size(8, label_hash, label_cmp, buffer); zvrf->fec_table[AFI_IP] = route_table_init(); zvrf->fec_table[AFI_IP6] = route_table_init(); zvrf->mpls_flags = 0; diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 212557423b..a0c63e4202 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -103,9 +103,7 @@ static int zebra_vrf_new(struct vrf *vrf) if (IS_ZEBRA_DEBUG_EVENT) zlog_debug("VRF %s created, id %u", vrf->name, vrf->vrf_id); - zvrf = zebra_vrf_alloc(); - vrf->info = zvrf; - zvrf->vrf = vrf; + zvrf = zebra_vrf_alloc(vrf); if (!vrf_is_backend_netns()) zvrf->zns = zebra_ns_lookup(NS_DEFAULT); @@ -427,12 +425,15 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi, } /* Allocate new zebra VRF. */ -struct zebra_vrf *zebra_vrf_alloc(void) +struct zebra_vrf *zebra_vrf_alloc(struct vrf *vrf) { struct zebra_vrf *zvrf; zvrf = XCALLOC(MTYPE_ZEBRA_VRF, sizeof(struct zebra_vrf)); + zvrf->vrf = vrf; + vrf->info = zvrf; + zebra_vxlan_init_tables(zvrf); zebra_mpls_init_tables(zvrf); zebra_pw_init(zvrf); diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h index 000b5a7238..b2b0fcfbb2 100644 --- a/zebra/zebra_vrf.h +++ b/zebra/zebra_vrf.h @@ -251,7 +251,7 @@ extern struct route_table *zebra_vrf_get_table_with_table_id(afi_t afi, extern void zebra_vrf_update_all(struct zserv *client); extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id); extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *); -extern struct zebra_vrf *zebra_vrf_alloc(void); +extern struct zebra_vrf *zebra_vrf_alloc(struct vrf *vrf); extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t); extern void zebra_vrf_init(void); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 3ac7ee8f4f..4e86ab3b4f 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -5752,13 +5752,20 @@ stream_failure: */ void zebra_vxlan_init_tables(struct zebra_vrf *zvrf) { + char buffer[80]; + if (!zvrf) return; - zvrf->evpn_table = - hash_create(zebra_evpn_hash_keymake, zebra_evpn_hash_cmp, - "Zebra VRF EVPN Table"); - zvrf->vxlan_sg_table = hash_create(zebra_vxlan_sg_hash_key_make, - zebra_vxlan_sg_hash_eq, "Zebra VxLAN SG Table"); + + snprintf(buffer, sizeof(buffer), "Zebra VRF EVPN Table: %s", + zvrf->vrf->name); + zvrf->evpn_table = hash_create_size(8, zebra_evpn_hash_keymake, + zebra_evpn_hash_cmp, buffer); + + snprintf(buffer, sizeof(buffer), "Zebra VxLAN SG Table: %s", + zvrf->vrf->name); + zvrf->vxlan_sg_table = hash_create_size(8, zebra_vxlan_sg_hash_key_make, + zebra_vxlan_sg_hash_eq, buffer); } /* Cleanup EVPN info, but don't free the table. */ |
