diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index ad872aeda32d..234dbb0715a5 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -2720,7 +2720,7 @@ int bgp_gr_lookup_n_update_all_peer(struct bgp *bgp, return BGP_GR_SUCCESS; } -int bgp_gr_update_all(struct bgp *bgp, int global_gr_cmd) +int bgp_gr_update_all(struct bgp *bgp, enum global_gr_command global_gr_cmd) { enum global_mode global_new_state = GLOBAL_INVALID; enum global_mode global_old_state = GLOBAL_INVALID; @@ -2874,7 +2874,8 @@ enum peer_mode bgp_peer_gr_mode_get(struct peer *peer) return peer->peer_gr_present_state; } -int bgp_neighbor_graceful_restart(struct peer *peer, int peer_gr_cmd) +int bgp_neighbor_graceful_restart(struct peer *peer, + enum peer_gr_command peer_gr_cmd) { enum peer_mode peer_new_state = PEER_INVALID; enum peer_mode peer_old_state = PEER_INVALID; @@ -2933,8 +2934,8 @@ int bgp_neighbor_graceful_restart(struct peer *peer, int peer_gr_cmd) return result; } -unsigned int bgp_peer_gr_action(struct peer *peer, int old_peer_state, - int new_peer_state) +unsigned int bgp_peer_gr_action(struct peer *peer, enum peer_mode old_peer_state, + enum peer_mode new_peer_state) { if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) zlog_debug( @@ -2942,7 +2943,7 @@ unsigned int bgp_peer_gr_action(struct peer *peer, int old_peer_state, __func__, print_peer_gr_mode(old_peer_state), print_peer_gr_mode(new_peer_state)); - int bgp_gr_global_mode = GLOBAL_INVALID; + enum global_mode bgp_gr_global_mode = GLOBAL_INVALID; unsigned int ret = BGP_GR_FAILURE; if (old_peer_state == new_peer_state) { @@ -2974,10 +2975,10 @@ unsigned int bgp_peer_gr_action(struct peer *peer, int old_peer_state, BGP_PEER_GR_GLOBAL_INHERIT_UNSET(peer); - if (new_peer_state == bgp_gr_global_mode) { - /*This is incremental updates i.e no tear down - *of the existing session - *as the peer is already working in the same mode. + if ((int)new_peer_state == (int)bgp_gr_global_mode) { + /* This is incremental updates i.e no tear down + * of the existing session + * as the peer is already working in the same mode. */ ret = BGP_GR_SUCCESS; } else { @@ -3004,8 +3005,7 @@ unsigned int bgp_peer_gr_action(struct peer *peer, int old_peer_state, BGP_PEER_GR_GLOBAL_INHERIT_SET(peer); - if (old_peer_state == bgp_gr_global_mode) { - + if ((int)old_peer_state == (int)bgp_gr_global_mode) { /* This is incremental updates *i.e no tear down of the existing session *as the peer is already working in the same mode. diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h index fd46b7994e3a..2e96ac4c106d 100644 --- a/bgpd/bgp_fsm.h +++ b/bgpd/bgp_fsm.h @@ -143,10 +143,11 @@ extern void bgp_adjust_routeadv(struct peer *); DECLARE_HOOK(peer_backward_transition, (struct peer *peer), (peer)); DECLARE_HOOK(peer_established, (struct peer *peer), (peer)); -int bgp_gr_update_all(struct bgp *bgp, int global_gr_cmd); -int bgp_neighbor_graceful_restart(struct peer *peer, int peer_gr_cmd); -unsigned int bgp_peer_gr_action(struct peer *peer, - int old_peer_state, int new_peer_state); +int bgp_gr_update_all(struct bgp *bgp, enum global_gr_command global_gr_cmd); +int bgp_neighbor_graceful_restart(struct peer *peer, + enum peer_gr_command peer_gr_cmd); +unsigned int bgp_peer_gr_action(struct peer *peer, enum peer_mode old_peer_state, + enum peer_mode new_peer_state); void bgp_peer_move_to_gr_mode(struct peer *peer, int new_state); unsigned int bgp_peer_gr_helper_enable(struct peer *peer); unsigned int bgp_peer_gr_enable(struct peer *peer); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index e1387b032181..ae3a88ddcc2c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -11634,7 +11634,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa total_count); } else vty_out(vty, - "\nDisplayed %ld routes and %ld total paths\n", + "\nDisplayed %ld routes and %ld total paths\n", output_count, total_count); } } @@ -11685,7 +11685,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, total_cum); else vty_out(vty, - "\nDisplayed %ld routes and %ld total paths\n", + "\nDisplayed %ld routes and %ld total paths\n", output_cum, total_cum); } else { if (use_json && output_cum == 0 && json_header_depth == 0) diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 9604578d9fd2..94275762f669 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -1320,7 +1320,7 @@ static int rpki_create_socket(void *_cache) else { ssh_config = cache->tr_config.ssh_config; host = ssh_config->host; - snprintf(s_port, sizeof(s_port), "%hu", ssh_config->port); + snprintf(s_port, sizeof(s_port), "%u", ssh_config->port); port = s_port; hints.ai_flags |= AI_NUMERICHOST; diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 2fc1bd63f7e7..d13515af6f4b 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -453,14 +453,14 @@ static unsigned int updgrp_hash_key_make(const void *p) peer, peer->sort, peer->sub_sort, (intmax_t)CHECK_FLAG(peer->flags, PEER_UPDGRP_FLAGS), (intmax_t)CHECK_FLAG(flags, PEER_UPDGRP_AF_FLAGS)); - zlog_debug( - "%pBP Update Group Hash: addpath: %u UpdGrpCapFlag: %u UpdGrpCapAFFlag: %u route_adv: %u change local as: %u, as_path_loop_detection: %d", - peer, (uint32_t)peer->addpath_type[afi][safi], - CHECK_FLAG(peer->cap, PEER_UPDGRP_CAP_FLAGS), - CHECK_FLAG(peer->af_cap[afi][safi], - PEER_UPDGRP_AF_CAP_FLAGS), - peer->v_routeadv, peer->change_local_as, - peer->as_path_loop_detection); + zlog_debug("%pBP Update Group Hash: addpath: %u UpdGrpCapFlag: %ju UpdGrpCapAFFlag: %u route_adv: %u change local as: %u, as_path_loop_detection: %d", + peer, (uint32_t)peer->addpath_type[afi][safi], + (intmax_t)CHECK_FLAG(peer->cap, + PEER_UPDGRP_CAP_FLAGS), + CHECK_FLAG(peer->af_cap[afi][safi], + PEER_UPDGRP_AF_CAP_FLAGS), + peer->v_routeadv, peer->change_local_as, + peer->as_path_loop_detection); zlog_debug( "%pBP Update Group Hash: max packet size: %u pmax_out: %u Peer Group: %s rmap out: %s", peer, peer->max_packet_size, peer->pmax_out[afi][safi], diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 1cc82748b613..a1593421beb6 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1051,7 +1051,8 @@ enum peer_gr_command { NO_PEER_HELPER_CMD }; -typedef unsigned int (*bgp_peer_gr_action_ptr)(struct peer *, int, int); +typedef unsigned int (*bgp_peer_gr_action_ptr)(struct peer *, enum peer_mode, + enum peer_mode); struct bgp_peer_gr { enum peer_mode next_state; @@ -1299,39 +1300,39 @@ struct peer { uint8_t afc_recv[AFI_MAX][SAFI_MAX]; /* Capability flags (reset in bgp_stop) */ - uint32_t cap; -#define PEER_CAP_REFRESH_ADV (1U << 0) /* refresh advertised */ -#define PEER_CAP_REFRESH_RCV (1U << 2) /* refresh rfc received */ -#define PEER_CAP_DYNAMIC_ADV (1U << 3) /* dynamic advertised */ -#define PEER_CAP_DYNAMIC_RCV (1U << 4) /* dynamic received */ -#define PEER_CAP_RESTART_ADV (1U << 5) /* restart advertised */ -#define PEER_CAP_RESTART_RCV (1U << 6) /* restart received */ -#define PEER_CAP_AS4_ADV (1U << 7) /* as4 advertised */ -#define PEER_CAP_AS4_RCV (1U << 8) /* as4 received */ + uint64_t cap; +#define PEER_CAP_REFRESH_ADV (1ULL << 0) /* refresh advertised */ +#define PEER_CAP_REFRESH_RCV (1ULL << 2) /* refresh rfc received */ +#define PEER_CAP_DYNAMIC_ADV (1ULL << 3) /* dynamic advertised */ +#define PEER_CAP_DYNAMIC_RCV (1ULL << 4) /* dynamic received */ +#define PEER_CAP_RESTART_ADV (1ULL << 5) /* restart advertised */ +#define PEER_CAP_RESTART_RCV (1ULL << 6) /* restart received */ +#define PEER_CAP_AS4_ADV (1ULL << 7) /* as4 advertised */ +#define PEER_CAP_AS4_RCV (1ULL << 8) /* as4 received */ /* sent graceful-restart restart (R) bit */ -#define PEER_CAP_GRACEFUL_RESTART_R_BIT_ADV (1U << 9) +#define PEER_CAP_GRACEFUL_RESTART_R_BIT_ADV (1ULL << 9) /* received graceful-restart restart (R) bit */ -#define PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV (1U << 10) -#define PEER_CAP_ADDPATH_ADV (1U << 11) /* addpath advertised */ -#define PEER_CAP_ADDPATH_RCV (1U << 12) /* addpath received */ -#define PEER_CAP_ENHE_ADV (1U << 13) /* Extended nexthop advertised */ -#define PEER_CAP_ENHE_RCV (1U << 14) /* Extended nexthop received */ -#define PEER_CAP_HOSTNAME_ADV (1U << 15) /* hostname advertised */ -#define PEER_CAP_HOSTNAME_RCV (1U << 16) /* hostname received */ -#define PEER_CAP_ENHANCED_RR_ADV (1U << 17) /* enhanced rr advertised */ -#define PEER_CAP_ENHANCED_RR_RCV (1U << 18) /* enhanced rr received */ -#define PEER_CAP_EXTENDED_MESSAGE_ADV (1U << 19) -#define PEER_CAP_EXTENDED_MESSAGE_RCV (1U << 20) -#define PEER_CAP_LLGR_ADV (1U << 21) -#define PEER_CAP_LLGR_RCV (1U << 22) +#define PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV (1ULL << 10) +#define PEER_CAP_ADDPATH_ADV (1ULL << 11) /* addpath advertised */ +#define PEER_CAP_ADDPATH_RCV (1ULL << 12) /* addpath received */ +#define PEER_CAP_ENHE_ADV (1ULL << 13) /* Extended nexthop advertised */ +#define PEER_CAP_ENHE_RCV (1ULL << 14) /* Extended nexthop received */ +#define PEER_CAP_HOSTNAME_ADV (1ULL << 15) /* hostname advertised */ +#define PEER_CAP_HOSTNAME_RCV (1ULL << 16) /* hostname received */ +#define PEER_CAP_ENHANCED_RR_ADV (1ULL << 17) /* enhanced rr advertised */ +#define PEER_CAP_ENHANCED_RR_RCV (1ULL << 18) /* enhanced rr received */ +#define PEER_CAP_EXTENDED_MESSAGE_ADV (1ULL << 19) +#define PEER_CAP_EXTENDED_MESSAGE_RCV (1ULL << 20) +#define PEER_CAP_LLGR_ADV (1ULL << 21) +#define PEER_CAP_LLGR_RCV (1ULL << 22) /* sent graceful-restart notification (N) bit */ -#define PEER_CAP_GRACEFUL_RESTART_N_BIT_ADV (1U << 23) +#define PEER_CAP_GRACEFUL_RESTART_N_BIT_ADV (1ULL << 23) /* received graceful-restart notification (N) bit */ -#define PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV (1U << 24) -#define PEER_CAP_ROLE_ADV (1U << 25) /* role advertised */ -#define PEER_CAP_ROLE_RCV (1U << 26) /* role received */ -#define PEER_CAP_SOFT_VERSION_ADV (1U << 27) -#define PEER_CAP_SOFT_VERSION_RCV (1U << 28) +#define PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV (1ULL << 24) +#define PEER_CAP_ROLE_ADV (1ULL << 25) /* role advertised */ +#define PEER_CAP_ROLE_RCV (1ULL << 26) /* role received */ +#define PEER_CAP_SOFT_VERSION_ADV (1ULL << 27) +#define PEER_CAP_SOFT_VERSION_RCV (1ULL << 28) /* Capability flags (reset in bgp_stop) */ uint32_t af_cap[AFI_MAX][SAFI_MAX]; diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 676d0771cd66..a452ebe48eb4 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -531,7 +531,7 @@ rfapi_group_new(struct bgp *bgp, rfapi_group_cfg_type_t type, const char *name) rfg = XCALLOC(MTYPE_RFAPI_GROUP_CFG, sizeof(struct rfapi_nve_group_cfg)); rfg->type = type; - rfg->name = strdup(name); + rfg->name = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, name); /* add to tail of list */ listnode_add(bgp->rfapi_cfg->nve_groups_sequential, rfg); rfg->label = MPLS_LABEL_NONE; @@ -832,8 +832,8 @@ DEFUN (vnc_redistribute_protocol, if (bgp->rfapi_cfg->redist_bgp_exterior_view_name) { VNC_REDIST_DISABLE(bgp, afi, type); /* disabled view implicitly */ - free(bgp->rfapi_cfg->redist_bgp_exterior_view_name); - bgp->rfapi_cfg->redist_bgp_exterior_view_name = NULL; + XFREE(MTYPE_RFAPI_GROUP_CFG, + bgp->rfapi_cfg->redist_bgp_exterior_view_name); } bgp->rfapi_cfg->redist_bgp_exterior_view = bgp; } @@ -873,10 +873,8 @@ DEFUN (vnc_no_redistribute_protocol, VNC_REDIST_DISABLE(bgp, afi, type); if (type == ZEBRA_ROUTE_BGP_DIRECT_EXT) { - if (bgp->rfapi_cfg->redist_bgp_exterior_view_name) { - free(bgp->rfapi_cfg->redist_bgp_exterior_view_name); - bgp->rfapi_cfg->redist_bgp_exterior_view_name = NULL; - } + XFREE(MTYPE_RFAPI_GROUP_CFG, + bgp->rfapi_cfg->redist_bgp_exterior_view_name); bgp->rfapi_cfg->redist_bgp_exterior_view = NULL; } @@ -905,9 +903,10 @@ DEFUN (vnc_redistribute_bgp_exterior, return CMD_WARNING_CONFIG_FAILED; } - if (bgp->rfapi_cfg->redist_bgp_exterior_view_name) - free(bgp->rfapi_cfg->redist_bgp_exterior_view_name); - bgp->rfapi_cfg->redist_bgp_exterior_view_name = strdup(argv[5]->arg); + XFREE(MTYPE_RFAPI_GROUP_CFG, + bgp->rfapi_cfg->redist_bgp_exterior_view_name); + bgp->rfapi_cfg->redist_bgp_exterior_view_name = + XSTRDUP(MTYPE_RFAPI_GROUP_CFG, argv[5]->arg); /* could be NULL if name is not defined yet */ bgp->rfapi_cfg->redist_bgp_exterior_view = bgp_lookup_by_name(argv[5]->arg); @@ -935,9 +934,9 @@ DEFUN (vnc_redistribute_nvegroup, */ bgp->rfapi_cfg->rfg_redist = bgp_rfapi_cfg_match_byname( bgp, argv[3]->arg, RFAPI_GROUP_CFG_NVE); - if (bgp->rfapi_cfg->rfg_redist_name) - free(bgp->rfapi_cfg->rfg_redist_name); - bgp->rfapi_cfg->rfg_redist_name = strdup(argv[3]->arg); + XFREE(MTYPE_RFAPI_GROUP_CFG, bgp->rfapi_cfg->rfg_redist_name); + bgp->rfapi_cfg->rfg_redist_name = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, + argv[3]->arg); vnc_redistribute_postchange(bgp); @@ -959,9 +958,7 @@ DEFUN (vnc_redistribute_no_nvegroup, vnc_redistribute_prechange(bgp); bgp->rfapi_cfg->rfg_redist = NULL; - if (bgp->rfapi_cfg->rfg_redist_name) - free(bgp->rfapi_cfg->rfg_redist_name); - bgp->rfapi_cfg->rfg_redist_name = NULL; + XFREE(MTYPE_RFAPI_GROUP_CFG, bgp->rfapi_cfg->rfg_redist_name); vnc_redistribute_postchange(bgp); @@ -1030,9 +1027,7 @@ DEFUN (vnc_redist_bgpdirect_no_prefixlist, vnc_redistribute_prechange(bgp); - if (hc->plist_redist_name[route_type][afi]) - free(hc->plist_redist_name[route_type][afi]); - hc->plist_redist_name[route_type][afi] = NULL; + XFREE(MTYPE_RFAPI_GROUP_CFG, hc->plist_redist_name[route_type][afi]); hc->plist_redist[route_type][afi] = NULL; vnc_redistribute_postchange(bgp); @@ -1074,9 +1069,9 @@ DEFUN (vnc_redist_bgpdirect_prefixlist, vnc_redistribute_prechange(bgp); - if (hc->plist_redist_name[route_type][afi]) - free(hc->plist_redist_name[route_type][afi]); - hc->plist_redist_name[route_type][afi] = strdup(argv[5]->arg); + XFREE(MTYPE_RFAPI_GROUP_CFG, hc->plist_redist_name[route_type][afi]); + hc->plist_redist_name[route_type][afi] = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, + argv[5]->arg); hc->plist_redist[route_type][afi] = prefix_list_lookup(afi, argv[5]->arg); @@ -1110,9 +1105,7 @@ DEFUN (vnc_redist_bgpdirect_no_routemap, vnc_redistribute_prechange(bgp); - if (hc->routemap_redist_name[route_type]) - free(hc->routemap_redist_name[route_type]); - hc->routemap_redist_name[route_type] = NULL; + XFREE(MTYPE_RFAPI_GROUP_CFG, hc->routemap_redist_name[route_type]); hc->routemap_redist[route_type] = NULL; vnc_redistribute_postchange(bgp); @@ -1144,15 +1137,16 @@ DEFUN (vnc_redist_bgpdirect_routemap, vnc_redistribute_prechange(bgp); - if (hc->routemap_redist_name[route_type]) - free(hc->routemap_redist_name[route_type]); + XFREE(MTYPE_RFAPI_GROUP_CFG, hc->routemap_redist_name[route_type]); /* If the old route map config overwrite with new * route map config , old routemap counter have to be * reduced. */ route_map_counter_decrement(hc->routemap_redist[route_type]); - hc->routemap_redist_name[route_type] = strdup(argv[4]->arg); + hc->routemap_redist_name[route_type] = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, + argv[4]->arg); + hc->routemap_redist[route_type] = route_map_lookup_by_name(argv[4]->arg); route_map_counter_increment(hc->routemap_redist[route_type]); @@ -1197,9 +1191,8 @@ DEFUN (vnc_nve_group_redist_bgpdirect_no_prefixlist, vnc_redistribute_prechange(bgp); - if (rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]) - free(rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]); - rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi] = NULL; + XFREE(MTYPE_RFAPI_GROUP_CFG, + rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]); rfg->plist_redist[ZEBRA_ROUTE_BGP_DIRECT][afi] = NULL; vnc_redistribute_postchange(bgp); @@ -1238,10 +1231,10 @@ DEFUN (vnc_nve_group_redist_bgpdirect_prefixlist, vnc_redistribute_prechange(bgp); - if (rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]) - free(rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]); + XFREE(MTYPE_RFAPI_GROUP_CFG, + rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]); rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi] = - strdup(argv[4]->arg); + XSTRDUP(MTYPE_RFAPI_GROUP_CFG, argv[4]->arg); rfg->plist_redist[ZEBRA_ROUTE_BGP_DIRECT][afi] = prefix_list_lookup(afi, argv[4]->arg); @@ -1272,11 +1265,10 @@ DEFUN (vnc_nve_group_redist_bgpdirect_no_routemap, vnc_redistribute_prechange(bgp); - if (rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]) - free(rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]); + XFREE(MTYPE_RFAPI_GROUP_CFG, + rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]); route_map_counter_decrement( rfg->routemap_redist[ZEBRA_ROUTE_BGP_DIRECT]); - rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT] = NULL; rfg->routemap_redist[ZEBRA_ROUTE_BGP_DIRECT] = NULL; vnc_redistribute_postchange(bgp); @@ -1305,12 +1297,12 @@ DEFUN (vnc_nve_group_redist_bgpdirect_routemap, vnc_redistribute_prechange(bgp); - if (rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]) - free(rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]); + XFREE(MTYPE_RFAPI_GROUP_CFG, + rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]); route_map_counter_decrement( rfg->routemap_redist[ZEBRA_ROUTE_BGP_DIRECT]); rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT] = - strdup(argv[3]->arg); + XSTRDUP(MTYPE_RFAPI_GROUP_CFG, argv[3]->arg); rfg->routemap_redist[ZEBRA_ROUTE_BGP_DIRECT] = route_map_lookup_by_name(argv[3]->arg); route_map_counter_increment( @@ -1451,7 +1443,7 @@ DEFUN (vnc_export_nvegroup, } rfgn = rfgn_new(); - rfgn->name = strdup(argv[5]->arg); + rfgn->name = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, argv[5]->arg); rfgn->rfg = rfg_new; /* OK if not set yet */ listnode_add(bgp->rfapi_cfg->rfg_export_direct_bgp_l, rfgn); @@ -1487,7 +1479,7 @@ DEFUN (vnc_export_nvegroup, } rfgn = rfgn_new(); - rfgn->name = strdup(argv[5]->arg); + rfgn->name = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, argv[5]->arg); rfgn->rfg = rfg_new; /* OK if not set yet */ listnode_add(bgp->rfapi_cfg->rfg_export_zebra_l, rfgn); @@ -1531,7 +1523,7 @@ DEFUN (vnc_no_export_nvegroup, if (rfgn->rfg) vnc_direct_bgp_del_group(bgp, rfgn->rfg); - free(rfgn->name); + XFREE(MTYPE_RFAPI_GROUP_CFG, rfgn->name); list_delete_node( bgp->rfapi_cfg->rfg_export_direct_bgp_l, node); @@ -1548,7 +1540,7 @@ DEFUN (vnc_no_export_nvegroup, if (rfgn->name && !strcmp(rfgn->name, argv[6]->arg)) { if (rfgn->rfg) vnc_zebra_del_group(bgp, rfgn->rfg); - free(rfgn->name); + XFREE(MTYPE_RFAPI_GROUP_CFG, rfgn->name); list_delete_node( bgp->rfapi_cfg->rfg_export_zebra_l, node); @@ -1612,9 +1604,8 @@ DEFUN (vnc_nve_group_export_no_prefixlist, || (rfg->plist_export_zebra_name[afi] && strmatch(argv[idx]->arg, rfg->plist_export_zebra_name[afi]))) { - if (rfg->plist_export_zebra_name[afi]) - free(rfg->plist_export_zebra_name[afi]); - rfg->plist_export_zebra_name[afi] = NULL; + XFREE(MTYPE_RFAPI_GROUP_CFG, + rfg->plist_export_zebra_name[afi]); rfg->plist_export_zebra[afi] = NULL; vnc_zebra_reexport_group_afi(bgp, rfg, afi); @@ -1667,18 +1658,18 @@ DEFUN (vnc_nve_group_export_prefixlist, idx = argc - 1; if (is_bgp) { - if (rfg->plist_export_bgp_name[afi]) - free(rfg->plist_export_bgp_name[afi]); - rfg->plist_export_bgp_name[afi] = strdup(argv[idx]->arg); + XFREE(MTYPE_RFAPI_GROUP_CFG, rfg->plist_export_bgp_name[afi]); + rfg->plist_export_bgp_name[afi] = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, + argv[idx]->arg); rfg->plist_export_bgp[afi] = prefix_list_lookup(afi, argv[idx]->arg); vnc_direct_bgp_reexport_group_afi(bgp, rfg, afi); } else { - if (rfg->plist_export_zebra_name[afi]) - free(rfg->plist_export_zebra_name[afi]); - rfg->plist_export_zebra_name[afi] = strdup(argv[idx]->arg); + XFREE(MTYPE_RFAPI_GROUP_CFG, rfg->plist_export_zebra_name[afi]); + rfg->plist_export_zebra_name[afi] = + XSTRDUP(MTYPE_RFAPI_GROUP_CFG, argv[idx]->arg); rfg->plist_export_zebra[afi] = prefix_list_lookup(afi, argv[idx]->arg); @@ -1735,10 +1726,9 @@ DEFUN (vnc_nve_group_export_no_routemap, || (rfg->routemap_export_bgp_name && strmatch(argv[idx]->arg, rfg->routemap_export_bgp_name))) { - if (rfg->routemap_export_bgp_name) - free(rfg->routemap_export_bgp_name); + XFREE(MTYPE_RFAPI_GROUP_CFG, + rfg->routemap_export_bgp_name); route_map_counter_decrement(rfg->routemap_export_bgp); - rfg->routemap_export_bgp_name = NULL; rfg->routemap_export_bgp = NULL; vnc_direct_bgp_reexport_group_afi(bgp, rfg, AFI_IP); @@ -1749,10 +1739,8 @@ DEFUN (vnc_nve_group_export_no_routemap, || (rfg->routemap_export_zebra_name && strmatch(argv[idx]->arg, rfg->routemap_export_zebra_name))) { - if (rfg->routemap_export_zebra_name) - free(rfg->routemap_export_zebra_name); + XFREE(MTYPE_RFAPI_GROUP_CFG, rfg->routemap_export_zebra_name); route_map_counter_decrement(rfg->routemap_export_zebra); - rfg->routemap_export_zebra_name = NULL; rfg->routemap_export_zebra = NULL; vnc_zebra_reexport_group_afi(bgp, rfg, AFI_IP); @@ -1796,20 +1784,20 @@ DEFUN (vnc_nve_group_export_routemap, idx = argc - 1; if (is_bgp) { - if (rfg->routemap_export_bgp_name) - free(rfg->routemap_export_bgp_name); + XFREE(MTYPE_RFAPI_GROUP_CFG, rfg->routemap_export_bgp_name); route_map_counter_decrement(rfg->routemap_export_bgp); - rfg->routemap_export_bgp_name = strdup(argv[idx]->arg); + rfg->routemap_export_bgp_name = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, + argv[idx]->arg); rfg->routemap_export_bgp = route_map_lookup_by_name(argv[idx]->arg); route_map_counter_increment(rfg->routemap_export_bgp); vnc_direct_bgp_reexport_group_afi(bgp, rfg, AFI_IP); vnc_direct_bgp_reexport_group_afi(bgp, rfg, AFI_IP6); } else { - if (rfg->routemap_export_zebra_name) - free(rfg->routemap_export_zebra_name); + XFREE(MTYPE_RFAPI_GROUP_CFG, rfg->routemap_export_zebra_name); route_map_counter_decrement(rfg->routemap_export_zebra); - rfg->routemap_export_zebra_name = strdup(argv[idx]->arg); + rfg->routemap_export_zebra_name = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, + argv[idx]->arg); rfg->routemap_export_zebra = route_map_lookup_by_name(argv[idx]->arg); route_map_counter_increment(rfg->routemap_export_zebra); @@ -1854,9 +1842,8 @@ DEFUN (vnc_nve_export_no_prefixlist, if (((argc > 6) && hc->plist_export_bgp_name[afi] && strmatch(argv[6]->text, hc->plist_export_bgp_name[afi])) || (argc <= 6)) { - - free(hc->plist_export_bgp_name[afi]); - hc->plist_export_bgp_name[afi] = NULL; + XFREE(MTYPE_RFAPI_GROUP_CFG, + hc->plist_export_bgp_name[afi]); hc->plist_export_bgp[afi] = NULL; vnc_direct_bgp_reexport(bgp, afi); } @@ -1865,9 +1852,8 @@ DEFUN (vnc_nve_export_no_prefixlist, && strmatch(argv[6]->text, hc->plist_export_zebra_name[afi])) || (argc <= 6)) { - - free(hc->plist_export_zebra_name[afi]); - hc->plist_export_zebra_name[afi] = NULL; + XFREE(MTYPE_RFAPI_GROUP_CFG, + hc->plist_export_zebra_name[afi]); hc->plist_export_zebra[afi] = NULL; /* TBD vnc_zebra_rh_reexport(bgp, afi); */ } @@ -1900,16 +1886,16 @@ DEFUN (vnc_nve_export_prefixlist, } if (argv[2]->arg[0] == 'b') { - if (hc->plist_export_bgp_name[afi]) - free(hc->plist_export_bgp_name[afi]); - hc->plist_export_bgp_name[afi] = strdup(argv[5]->arg); + XFREE(MTYPE_RFAPI_GROUP_CFG, hc->plist_export_bgp_name[afi]); + hc->plist_export_bgp_name[afi] = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, + argv[5]->arg); hc->plist_export_bgp[afi] = prefix_list_lookup(afi, argv[5]->arg); vnc_direct_bgp_reexport(bgp, afi); } else { - if (hc->plist_export_zebra_name[afi]) - free(hc->plist_export_zebra_name[afi]); - hc->plist_export_zebra_name[afi] = strdup(argv[5]->arg); + XFREE(MTYPE_RFAPI_GROUP_CFG, hc->plist_export_zebra_name[afi]); + hc->plist_export_zebra_name[afi] = + XSTRDUP(MTYPE_RFAPI_GROUP_CFG, argv[5]->arg); hc->plist_export_zebra[afi] = prefix_list_lookup(afi, argv[5]->arg); /* TBD vnc_zebra_rh_reexport(bgp, afi); */ @@ -1937,10 +1923,9 @@ DEFUN (vnc_nve_export_no_routemap, if (((argc > 5) && hc->routemap_export_bgp_name && strmatch(argv[5]->text, hc->routemap_export_bgp_name)) || (argc <= 5)) { - - free(hc->routemap_export_bgp_name); + XFREE(MTYPE_RFAPI_GROUP_CFG, + hc->routemap_export_bgp_name); route_map_counter_decrement(hc->routemap_export_bgp); - hc->routemap_export_bgp_name = NULL; hc->routemap_export_bgp = NULL; vnc_direct_bgp_reexport(bgp, AFI_IP); vnc_direct_bgp_reexport(bgp, AFI_IP6); @@ -1950,9 +1935,8 @@ DEFUN (vnc_nve_export_no_routemap, && strmatch(argv[5]->text, hc->routemap_export_zebra_name)) || (argc <= 5)) { - free(hc->routemap_export_zebra_name); + XFREE(MTYPE_RFAPI_GROUP_CFG, hc->routemap_export_zebra_name); route_map_counter_decrement(hc->routemap_export_zebra); - hc->routemap_export_zebra_name = NULL; hc->routemap_export_zebra = NULL; /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */ /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */ @@ -1977,20 +1961,20 @@ DEFUN (vnc_nve_export_routemap, hc = bgp->rfapi_cfg; if (argv[2]->arg[0] == 'b') { - if (hc->routemap_export_bgp_name) - free(hc->routemap_export_bgp_name); + XFREE(MTYPE_RFAPI_GROUP_CFG, hc->routemap_export_bgp_name); route_map_counter_decrement(hc->routemap_export_bgp); - hc->routemap_export_bgp_name = strdup(argv[4]->arg); + hc->routemap_export_bgp_name = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, + argv[4]->arg); hc->routemap_export_bgp = route_map_lookup_by_name(argv[4]->arg); route_map_counter_increment(hc->routemap_export_bgp); vnc_direct_bgp_reexport(bgp, AFI_IP); vnc_direct_bgp_reexport(bgp, AFI_IP6); } else { - if (hc->routemap_export_zebra_name) - free(hc->routemap_export_zebra_name); + XFREE(MTYPE_RFAPI_GROUP_CFG, hc->routemap_export_zebra_name); route_map_counter_decrement(hc->routemap_export_zebra); - hc->routemap_export_zebra_name = strdup(argv[4]->arg); + hc->routemap_export_zebra_name = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, + argv[4]->arg); hc->routemap_export_zebra = route_map_lookup_by_name(argv[4]->arg); route_map_counter_increment(hc->routemap_export_zebra); @@ -2320,7 +2304,7 @@ static void bgp_rfapi_delete_nve_group(struct vty *vty, /* NULL = no output */ } /* delete it */ - free(rfg->name); + XFREE(MTYPE_RFAPI_GROUP_CFG, rfg->name); if (rfg->rfapi_import_table) rfapiImportTableRefDelByIt(bgp, rfg->rfapi_import_table); if (rfg->rt_import_list) @@ -3411,7 +3395,7 @@ DEFUN_NOSH (vnc_l2_group, vty_out(vty, "Can't allocate memory for L2 group\n"); return CMD_WARNING_CONFIG_FAILED; } - rfg->name = strdup(argv[2]->arg); + rfg->name = XSTRDUP(MTYPE_RFAPI_GROUP_CFG, argv[2]->arg); /* add to tail of list */ listnode_add(bgp->rfapi_cfg->l2_groups, rfg); } @@ -3429,7 +3413,7 @@ static void bgp_rfapi_delete_l2_group(struct vty *vty, /* NULL = no output */ struct rfapi_l2_group_cfg *rfg) { /* delete it */ - free(rfg->name); + XFREE(MTYPE_RFAPI_GROUP_CFG, rfg->name); if (rfg->rt_import_list) ecommunity_free(&rfg->rt_import_list); if (rfg->rt_export_list) @@ -3843,7 +3827,8 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg) static void bgp_rfapi_rfgn_list_delete(void *data) { struct rfapi_rfg_name *rfgn = data; - free(rfgn->name); + + XFREE(MTYPE_RFAPI_GROUP_CFG, rfgn->name); rfgn_free(rfgn); } diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index 232abfd745c3..540fa6d4079f 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -3786,7 +3786,7 @@ When default route is present in R2'2 BGP table, 10.139.224.0/20 and 192.0.2.1/3 *> 192.0.2.1/32 10.10.10.1 0 0 1 i *> 192.0.2.5/32 10.10.10.1 0 0 1 i - Displayed 4 routes and 4 total paths + Displayed 4 routes and 4 total paths Router2# show ip bgp neighbors 10.10.20.3 !--- Output suppressed. @@ -3834,7 +3834,7 @@ When default route is not present in R2'2 BGP table, 10.139.224.0/20 and 192.0.2 *> 192.0.2.1/32 10.10.10.1 0 0 1 i *> 192.0.2.5/32 10.10.10.1 0 0 1 i - Displayed 3 routes and 3 total paths + Displayed 3 routes and 3 total paths Router2# show ip bgp neighbors 10.10.20.3 @@ -4455,7 +4455,7 @@ incoming/outgoing directions. Origin incomplete, metric 0, weight 32768, valid, sourced, bestpath-from-AS Local, best (First path received) Last update: Wed May 8 12:54:41 2023 - Displayed 2 routes and 2 total paths + Displayed 2 routes and 2 total paths .. code-block:: frr @@ -4480,7 +4480,7 @@ incoming/outgoing directions. Origin incomplete, metric 0, weight 32768, valid, sourced, bestpath-from-AS Local, best (First path received) Last update: Wed May 8 12:45:01 2023 - Displayed 2 routes and 2 total paths + Displayed 2 routes and 2 total paths Instance vrf3: @@ -4505,7 +4505,7 @@ incoming/outgoing directions. Extended Community: RT:65000:1009 ET:8 Rmac:00:02:00:00:00:58 Last update: Fri May 8 02:41:55 2023 - Displayed 2 routes and 2 total paths + Displayed 2 routes and 2 total paths .. code-block:: frr @@ -4533,7 +4533,7 @@ incoming/outgoing directions. Extended Community: RT:65000:1009 ET:8 Rmac:00:02:00:00:00:58 Last update: Fri May 8 02:23:55 2023 - Displayed 2 routes and 2 total paths + Displayed 2 routes and 2 total paths .. _bgp-display-routes-by-community: diff --git a/doc/user/zebra.rst b/doc/user/zebra.rst index 71201b42781d..8f4c9e1d45af 100644 --- a/doc/user/zebra.rst +++ b/doc/user/zebra.rst @@ -802,7 +802,7 @@ IS-IS are part of it. Allocated label chunks table can be dumped using the command -.. clicmd:: show debugging label-table +.. clicmd:: show debugging label-table [json] :: diff --git a/eigrpd/eigrp_cli.c b/eigrpd/eigrp_cli.c index 4bd3434aebad..eaede73fb3a3 100644 --- a/eigrpd/eigrp_cli.c +++ b/eigrpd/eigrp_cli.c @@ -131,12 +131,14 @@ DEFPY_YANG( "Suppress routing updates on an interface\n" "Interface to suppress on\n") { + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./passive-interface[.='%s']", ifname); + if (no) - nb_cli_enqueue_change(vty, "./passive-interface", - NB_OP_DESTROY, ifname); + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, "./passive-interface", - NB_OP_CREATE, ifname); + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -354,12 +356,14 @@ DEFPY_YANG( "Enable routing on an IP network\n" "EIGRP network prefix\n") { + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./network[.='%s']", prefix_str); + if (no) - nb_cli_enqueue_change(vty, "./network", NB_OP_DESTROY, - prefix_str); + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, "./network", NB_OP_CREATE, - prefix_str); + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -383,12 +387,14 @@ DEFPY_YANG( "Specify a neighbor router\n" "Neighbor address\n") { + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./neighbor[.='%s']", addr_str); + if (no) - nb_cli_enqueue_change(vty, "./neighbor", NB_OP_DESTROY, - addr_str); + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, "./neighbor", NB_OP_CREATE, - addr_str); + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -769,8 +775,9 @@ DEFPY_YANG( as_str); nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); - snprintf(xpath_auth, sizeof(xpath_auth), "%s/summarize-addresses", xpath); - nb_cli_enqueue_change(vty, xpath_auth, NB_OP_CREATE, prefix_str); + snprintf(xpath_auth, sizeof(xpath_auth), + "%s/summarize-addresses[.='%s']", xpath, prefix_str); + nb_cli_enqueue_change(vty, xpath_auth, NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -792,8 +799,9 @@ DEFPY_YANG( as_str); nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); - snprintf(xpath_auth, sizeof(xpath_auth), "%s/summarize-addresses", xpath); - nb_cli_enqueue_change(vty, xpath_auth, NB_OP_DESTROY, prefix_str); + snprintf(xpath_auth, sizeof(xpath_auth), + "%s/summarize-addresses[.='%s']", xpath, prefix_str); + nb_cli_enqueue_change(vty, xpath_auth, NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index bcc9456d2c00..2b19cbba849d 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -300,8 +300,12 @@ DEFPY_YANG(net, net_cmd, "[no] net WORD", "A Network Entity Title for this process (OSI only)\n" "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") { - nb_cli_enqueue_change(vty, "./area-address", - no ? NB_OP_DESTROY : NB_OP_CREATE, net); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, XPATH_MAXLEN, "./area-address[.='%s']", net); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -3054,12 +3058,16 @@ void cli_show_ip_isis_circ_type(struct vty *vty, const struct lyd_node *dnode, } static int ag_change(struct vty *vty, int argc, struct cmd_token **argv, - const char *xpath, bool no, int start_idx) + const char *xpath_base, bool no, int start_idx) { - for (int i = start_idx; i < argc; i++) + char xpath[XPATH_MAXLEN]; + + for (int i = start_idx; i < argc; i++) { + snprintf(xpath, XPATH_MAXLEN, "%s[.='%s']", xpath_base, + argv[i]->arg); nb_cli_enqueue_change(vty, xpath, - no ? NB_OP_DESTROY : NB_OP_CREATE, - argv[i]->arg); + no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); + } return nb_cli_apply_changes(vty, NULL); } @@ -3302,31 +3310,27 @@ DEFPY(isis_lfa_exclude_interface, isis_lfa_exclude_interface_cmd, "Exclude an interface from computation\n" "Interface name\n") { + char xpath[XPATH_MAXLEN]; + if (!level || strmatch(level, "level-1")) { - if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface", - NB_OP_DESTROY, ifname); - } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface", - NB_OP_CREATE, ifname); - } + snprintf(xpath, sizeof(xpath), + "./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface[.='%s']", + ifname); + + if (no) + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + else + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); } if (!level || strmatch(level, "level-2")) { - if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface", - NB_OP_DESTROY, ifname); - } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface", - NB_OP_CREATE, ifname); - } + snprintf(xpath, sizeof(xpath), + "./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface[.='%s']", + ifname); + + if (no) + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + else + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); } return nb_cli_apply_changes(vty, NULL); diff --git a/lib/log_vty.c b/lib/log_vty.c index 1ce25196da5a..323b1b1d55a3 100644 --- a/lib/log_vty.c +++ b/lib/log_vty.c @@ -902,6 +902,8 @@ void log_config_write(struct vty *vty) vty_out(vty, "no log error-category\n"); if (!zlog_get_prefix_xid()) vty_out(vty, "no log unique-id\n"); + if (zlog_get_immediate_mode()) + vty_out(vty, "log immediate-mode\n"); if (logmsgs_with_persist_bt) { struct xrefdata *xrd; diff --git a/lib/northbound.c b/lib/northbound.c index a831fc58b2af..949218332aa4 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -695,35 +695,22 @@ static int dnode_create(struct nb_config *candidate, const char *xpath, int nb_candidate_edit(struct nb_config *candidate, const struct nb_node *nb_node, enum nb_operation operation, const char *xpath, - bool in_backend, const struct yang_data *previous, + const struct yang_data *previous, const struct yang_data *data) { struct lyd_node *dnode, *dep_dnode, *old_dnode; - char xpath_edit[XPATH_MAXLEN]; char dep_xpath[XPATH_MAXLEN]; struct lyd_node *parent = NULL; uint32_t options = 0; LY_ERR err; - /* - * Use special notation for leaf-lists (RFC 6020, section 9.13.5). - * if we are in a backend client this notation was already applied - * by mgmtd before sending to us. - */ - if (!in_backend && nb_node->snode->nodetype == LYS_LEAFLIST && - (operation == NB_OP_DESTROY || operation == NB_OP_DELETE)) - snprintf(xpath_edit, sizeof(xpath_edit), "%s[.='%s']", xpath, - data->value); - else - strlcpy(xpath_edit, xpath, sizeof(xpath_edit)); - switch (operation) { case NB_OP_CREATE: case NB_OP_MODIFY: options = LYD_NEW_PATH_UPDATE; fallthrough; case NB_OP_CREATE_EXCL: - err = dnode_create(candidate, xpath_edit, data->value, options, + err = dnode_create(candidate, xpath, data->value, options, &dnode); if (err) { return err; @@ -750,7 +737,7 @@ int nb_candidate_edit(struct nb_config *candidate, const struct nb_node *nb_node break; case NB_OP_DESTROY: case NB_OP_DELETE: - dnode = yang_dnode_get(candidate->dnode, xpath_edit); + dnode = yang_dnode_get(candidate->dnode, xpath); if (!dnode) { if (operation == NB_OP_DELETE) return NB_ERR; @@ -768,12 +755,12 @@ int nb_candidate_edit(struct nb_config *candidate, const struct nb_node *nb_node lyd_free_tree(dnode); break; case NB_OP_REPLACE: - old_dnode = yang_dnode_get(candidate->dnode, xpath_edit); + old_dnode = yang_dnode_get(candidate->dnode, xpath); if (old_dnode) { parent = lyd_parent(old_dnode); lyd_unlink_tree(old_dnode); } - err = dnode_create(candidate, xpath_edit, data->value, options, + err = dnode_create(candidate, xpath, data->value, options, &dnode); if (!err && dnode && !old_dnode) { /* create dependency if the node didn't exist */ @@ -908,8 +895,7 @@ void nb_candidate_edit_config_changes(struct nb_config *candidate_config, * configuration. */ ret = nb_candidate_edit(candidate_config, nb_node, - change->operation, xpath, in_backend, - NULL, data); + change->operation, xpath, NULL, data); yang_data_free(data); if (ret != NB_OK) { flog_warn( diff --git a/lib/northbound.h b/lib/northbound.h index 0a6bc88921cf..493e5ce703b1 100644 --- a/lib/northbound.h +++ b/lib/northbound.h @@ -950,9 +950,6 @@ extern bool nb_is_operation_allowed(struct nb_node *nb_node, * xpath * XPath of the configuration node being edited. * - * in_backend - * Specify whether the changes are being applied in the backend or not. - * * previous * Previous value of the configuration node. Should be used only when the * operation is NB_OP_MOVE, otherwise this parameter is ignored. @@ -967,7 +964,7 @@ extern bool nb_is_operation_allowed(struct nb_node *nb_node, extern int nb_candidate_edit(struct nb_config *candidate, const struct nb_node *nb_node, enum nb_operation operation, const char *xpath, - bool in_backend, const struct yang_data *previous, + const struct yang_data *previous, const struct yang_data *data); /* diff --git a/lib/northbound_confd.c b/lib/northbound_confd.c index c866b0afb466..8503d18002c7 100644 --- a/lib/northbound_confd.c +++ b/lib/northbound_confd.c @@ -256,7 +256,7 @@ frr_confd_cdb_diff_iter(confd_hkeypath_t *kp, enum cdb_iter_op cdb_op, /* Edit the candidate configuration. */ data = yang_data_new(xpath, value_str); ret = nb_candidate_edit(iter_args->candidate, nb_node, nb_op, xpath, - false, NULL, data); + NULL, data); yang_data_free(data); if (ret != NB_OK) { flog_warn( diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c index 050477af9177..198d96e3811c 100644 --- a/lib/northbound_sysrepo.c +++ b/lib/northbound_sysrepo.c @@ -219,7 +219,7 @@ static int frr_sr_process_change(struct nb_config *candidate, sr_val_to_buff(sr_data, value_str, sizeof(value_str)); data = yang_data_new(xpath, value_str); - ret = nb_candidate_edit(candidate, nb_node, nb_op, xpath, false, NULL, data); + ret = nb_candidate_edit(candidate, nb_node, nb_op, xpath, NULL, data); yang_data_free(data); if (ret != NB_OK) { flog_warn( diff --git a/lib/zclient.c b/lib/zclient.c index 25c6e2b8e559..51ebb5627557 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -4520,6 +4520,24 @@ static void zclient_event(enum zclient_event event, struct zclient *zclient) } } +enum zclient_send_status zclient_interface_set_arp(struct zclient *client, + struct interface *ifp, + bool arp_enable) +{ + struct stream *s; + + s = client->obuf; + stream_reset(s); + + zclient_create_header(s, ZEBRA_INTERFACE_SET_ARP, ifp->vrf->vrf_id); + + stream_putl(s, ifp->ifindex); + stream_putc(s, arp_enable); + + stream_putw_at(s, 0, stream_get_endp(s)); + return zclient_send_message(client); +} + enum zclient_send_status zclient_interface_set_master(struct zclient *client, struct interface *master, struct interface *slave) diff --git a/lib/zclient.h b/lib/zclient.h index 3027c2c37846..1bf91064e2d0 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -98,6 +98,7 @@ typedef enum { ZEBRA_INTERFACE_UP, ZEBRA_INTERFACE_DOWN, ZEBRA_INTERFACE_SET_MASTER, + ZEBRA_INTERFACE_SET_ARP, ZEBRA_INTERFACE_SET_PROTODOWN, ZEBRA_ROUTE_ADD, ZEBRA_ROUTE_DELETE, @@ -1036,6 +1037,9 @@ extern int zclient_read_header(struct stream *s, int sock, uint16_t *size, */ extern bool zapi_parse_header(struct stream *zmsg, struct zmsghdr *hdr); +extern enum zclient_send_status zclient_interface_set_arp(struct zclient *client, + struct interface *ifp, + bool arp_enable); extern enum zclient_send_status zclient_interface_set_master(struct zclient *client, struct interface *master, struct interface *slave); diff --git a/lib/zlog.c b/lib/zlog.c index 77592c33ff04..8734fd55af3e 100644 --- a/lib/zlog.c +++ b/lib/zlog.c @@ -84,7 +84,7 @@ static struct zlog_targets_head zlog_targets; /* Global setting for buffered vs immediate output. The default is * per-pthread buffering. */ -static bool default_immediate; +static bool zlog_default_immediate; /* cf. zlog.h for additional comments on this struct. * @@ -445,7 +445,7 @@ static void vzlog_tls(struct zlog_tls *zlog_tls, const struct xref_logmsg *xref, struct zlog_msg *msg; char *buf; bool ignoremsg = true; - bool immediate = default_immediate; + bool immediate = zlog_default_immediate; /* avoid further processing cost if no target wants this message */ rcu_read_lock(); @@ -966,7 +966,12 @@ struct zlog_target *zlog_target_replace(struct zlog_target *oldzt, */ void zlog_set_immediate(bool set_p) { - default_immediate = set_p; + zlog_default_immediate = set_p; +} + +bool zlog_get_immediate_mode(void) +{ + return zlog_default_immediate; } /* common init */ diff --git a/lib/zlog.h b/lib/zlog.h index a207b29a3b6d..27401d51fb13 100644 --- a/lib/zlog.h +++ b/lib/zlog.h @@ -276,6 +276,7 @@ extern void zlog_tls_buffer_fini(void); /* Enable or disable 'immediate' output - default is to buffer messages. */ extern void zlog_set_immediate(bool set_p); +bool zlog_get_immediate_mode(void); extern const char *zlog_priority_str(int priority); diff --git a/nhrpd/linux.c b/nhrpd/linux.c index b25df9ff2fd2..e4df0dd9640d 100644 --- a/nhrpd/linux.c +++ b/nhrpd/linux.c @@ -8,7 +8,6 @@ #include #include #include -#include #include "nhrp_protocol.h" #include "os.h" @@ -98,25 +97,6 @@ int os_recvmsg(uint8_t *buf, size_t *len, int *ifindex, uint8_t *addr, return 0; } -static int linux_configure_arp(const char *iface, int on) -{ - struct ifreq ifr; - - strlcpy(ifr.ifr_name, iface, IFNAMSIZ); - if (ioctl(nhrp_socket_fd, SIOCGIFFLAGS, &ifr)) - return -1; - - if (on) - ifr.ifr_flags &= ~IFF_NOARP; - else - ifr.ifr_flags |= IFF_NOARP; - - if (ioctl(nhrp_socket_fd, SIOCSIFFLAGS, &ifr)) - return -1; - - return 0; -} - static int linux_icmp_redirect_off(const char *iface) { char fname[PATH_MAX]; @@ -144,7 +124,6 @@ int os_configure_dmvpn(unsigned int ifindex, const char *ifname, int af) ret |= linux_icmp_redirect_off(ifname); break; } - ret |= linux_configure_arp(ifname, 1); return ret; } diff --git a/nhrpd/netlink.h b/nhrpd/netlink.h index 7a3029b6c133..33af1a02c1f6 100644 --- a/nhrpd/netlink.h +++ b/nhrpd/netlink.h @@ -11,7 +11,6 @@ extern int netlink_nflog_group; extern int netlink_mcast_nflog_group; -int netlink_configure_arp(unsigned int ifindex, int pf); void netlink_update_binding(struct interface *ifp, union sockunion *proto, union sockunion *nbma); void netlink_set_nflog_group(int nlgroup); diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c index b82743f001f9..7d0ab9762f71 100644 --- a/nhrpd/nhrp_interface.c +++ b/nhrpd/nhrp_interface.c @@ -351,6 +351,7 @@ void nhrp_interface_update(struct interface *ifp) if (!if_ad->configured) { os_configure_dmvpn(ifp->ifindex, ifp->name, afi2family(afi)); + nhrp_interface_update_arp(ifp, true); nhrp_send_zebra_configure_arp(ifp, afi2family(afi)); if_ad->configured = 1; nhrp_interface_update_address(ifp, afi, 1); diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c index c05a8a3ba25d..fd9090bd6e74 100644 --- a/nhrpd/nhrp_route.c +++ b/nhrpd/nhrp_route.c @@ -452,6 +452,12 @@ int nhrp_send_zebra_gre_request(struct interface *ifp) return zclient_send_zebra_gre_request(zclient, ifp); } +void nhrp_interface_update_arp(struct interface *ifp, bool arp_enable) +{ + zclient_interface_set_arp(zclient, ifp, arp_enable); +} + + void nhrp_zebra_terminate(void) { zclient_register_neigh(zclient, VRF_DEFAULT, AFI_IP, false); diff --git a/nhrpd/nhrpd.h b/nhrpd/nhrpd.h index 1421f0fc387a..50653c784acc 100644 --- a/nhrpd/nhrpd.h +++ b/nhrpd/nhrpd.h @@ -362,6 +362,7 @@ int sock_open_unix(const char *path); void nhrp_interface_init(void); void nhrp_interface_update(struct interface *ifp); +void nhrp_interface_update_arp(struct interface *ifp, bool arp_enable); void nhrp_interface_update_mtu(struct interface *ifp, afi_t afi); void nhrp_interface_update_nbma(struct interface *ifp, struct nhrp_gre_info *gre_info); diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index b9d1ca9bb7ab..ff252f850534 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -650,7 +650,15 @@ static void pbr_nht_release_individual_nexthop(struct pbr_map_sequence *pbrms) void pbr_nht_delete_individual_nexthop(struct pbr_map_sequence *pbrms) { - pbr_map_delete_nexthops(pbrms); + struct pbr_map *pbrm = pbrms->parent; + + /* The idea here is to send a delete command to zebra only once, + * and set 'valid' and 'installed' to false only when the last + * rule is being deleted. In other words, the pbr common should be + * updated only when the last rule is being updated or deleted. + */ + if (pbrm->seqnumbers->count == 1) + pbr_map_delete_nexthops(pbrms); pbr_nht_release_individual_nexthop(pbrms); } diff --git a/pceplib/pcep_socket_comm_mock.c b/pceplib/pcep_socket_comm_mock.c index 24755efee940..bda9b1ffdca9 100644 --- a/pceplib/pcep_socket_comm_mock.c +++ b/pceplib/pcep_socket_comm_mock.c @@ -115,7 +115,7 @@ bool initialize_socket_comm_external_infra( return true; } -bool destroy_socket_comm_loop() +bool destroy_socket_comm_loop(void) { mock_socket_metadata.destroy_socket_comm_loop_times_called++; diff --git a/pceplib/test/pcep_msg_messages_test.c b/pceplib/test/pcep_msg_messages_test.c index c4eaeaab2449..e1f524921f2e 100644 --- a/pceplib/test/pcep_msg_messages_test.c +++ b/pceplib/test/pcep_msg_messages_test.c @@ -48,17 +48,17 @@ int pcep_messages_test_suite_teardown(void) return 0; } -void pcep_messages_test_setup() +void pcep_messages_test_setup(void) { versioning = create_default_pcep_versioning(); } -void pcep_messages_test_teardown() +void pcep_messages_test_teardown(void) { destroy_pcep_versioning(versioning); } -void test_pcep_msg_create_open() +void test_pcep_msg_create_open(void) { uint8_t keepalive = 30; uint8_t deadtimer = 60; @@ -96,8 +96,7 @@ void test_pcep_msg_create_open() pcep_msg_free_message(message); } - -void test_pcep_msg_create_request() +void test_pcep_msg_create_request(void) { /* First test with NULL objects */ struct pcep_message *message = @@ -185,13 +184,11 @@ void test_pcep_msg_create_request() pcep_msg_free_message(message); } - -void test_pcep_msg_create_request_svec() +void test_pcep_msg_create_request_svec(void) { } - -void test_pcep_msg_create_reply_nopath() +void test_pcep_msg_create_reply_nopath(void) { struct pcep_object_rp *rp_obj = pcep_obj_create_rp(0, false, false, false, false, 10, NULL); @@ -219,8 +216,7 @@ void test_pcep_msg_create_reply_nopath() pcep_msg_free_message(message); } - -void test_pcep_msg_create_reply() +void test_pcep_msg_create_reply(void) { /* First test with NULL ero and rp objects */ struct pcep_message *message = pcep_msg_create_reply(NULL, NULL); @@ -268,8 +264,7 @@ void test_pcep_msg_create_reply() pcep_msg_free_message(message); } - -void test_pcep_msg_create_close() +void test_pcep_msg_create_close(void) { uint8_t reason = PCEP_CLOSE_REASON_UNREC_MSG; @@ -301,8 +296,7 @@ void test_pcep_msg_create_close() pcep_msg_free_message(message); } - -void test_pcep_msg_create_error() +void test_pcep_msg_create_error(void) { uint8_t error_type = PCEP_ERRT_RECEPTION_OF_INV_OBJECT; uint8_t error_value = PCEP_ERRV_KEEPALIVEWAIT_TIMED_OUT; @@ -337,8 +331,7 @@ void test_pcep_msg_create_error() pcep_msg_free_message(message); } - -void test_pcep_msg_create_keepalive() +void test_pcep_msg_create_keepalive(void) { struct pcep_message *message = pcep_msg_create_keepalive(); CU_ASSERT_PTR_NOT_NULL(message); @@ -356,7 +349,7 @@ void test_pcep_msg_create_keepalive() pcep_msg_free_message(message); } -void test_pcep_msg_create_report() +void test_pcep_msg_create_report(void) { double_linked_list *obj_list = dll_initialize(); @@ -387,7 +380,7 @@ void test_pcep_msg_create_report() pcep_msg_free_message(message); } -void test_pcep_msg_create_update() +void test_pcep_msg_create_update(void) { double_linked_list *obj_list = dll_initialize(); double_linked_list *ero_subobj_list = dll_initialize(); @@ -398,10 +391,8 @@ void test_pcep_msg_create_update() /* Should return NULL if obj_list is empty */ message = pcep_msg_create_update(obj_list); CU_ASSERT_PTR_NULL(message); - if (message != NULL) { + if (message != NULL) pcep_msg_free_message(message); - message = NULL; - } struct pcep_object_srp *srp = pcep_obj_create_srp(false, 100, NULL); struct pcep_object_lsp *lsp = @@ -417,10 +408,9 @@ void test_pcep_msg_create_update() CU_ASSERT_PTR_NULL(message); dll_append(obj_list, ero); - if (message != NULL) { + if (message != NULL) pcep_msg_free_message(message); - message = NULL; - } + message = pcep_msg_create_update(obj_list); CU_ASSERT_PTR_NOT_NULL(message); pcep_encode_message(message, versioning); @@ -442,7 +432,7 @@ void test_pcep_msg_create_update() pcep_msg_free_message(message); } -void test_pcep_msg_create_initiate() +void test_pcep_msg_create_initiate(void) { double_linked_list *obj_list = dll_initialize(); double_linked_list *ero_subobj_list = dll_initialize(); @@ -450,10 +440,8 @@ void test_pcep_msg_create_initiate() /* Should return NULL if obj_list is empty */ struct pcep_message *message = pcep_msg_create_initiate(NULL); CU_ASSERT_PTR_NULL(message); - if (message != NULL) { + if (message != NULL) pcep_msg_free_message(message); - message = NULL; - } struct pcep_object_srp *srp = pcep_obj_create_srp(false, 100, NULL); struct pcep_object_lsp *lsp = @@ -466,10 +454,8 @@ void test_pcep_msg_create_initiate() dll_append(obj_list, srp); message = pcep_msg_create_initiate(obj_list); CU_ASSERT_PTR_NULL(message); - if (message != NULL) { + if (message != NULL) pcep_msg_free_message(message); - message = NULL; - } dll_append(obj_list, lsp); dll_append(obj_list, ero); diff --git a/pceplib/test/pcep_msg_object_error_types_test.c b/pceplib/test/pcep_msg_object_error_types_test.c index 3237fecb1f93..b7198fbe6906 100644 --- a/pceplib/test/pcep_msg_object_error_types_test.c +++ b/pceplib/test/pcep_msg_object_error_types_test.c @@ -44,7 +44,7 @@ void pcep_object_error_types_test_teardown(void) { } -void test_get_error_type_str() +void test_get_error_type_str(void) { const char *error_type_str; int i = 0; @@ -57,7 +57,7 @@ void test_get_error_type_str() CU_ASSERT_PTR_NULL(get_error_type_str(MAX_ERROR_TYPE)); } -void test_get_error_value_str() +void test_get_error_value_str(void) { const char *error_value_str; int i = 0, j = 0; diff --git a/pceplib/test/pcep_msg_objects_test.c b/pceplib/test/pcep_msg_objects_test.c index 1315fe3f34c2..0a1d34d55756 100644 --- a/pceplib/test/pcep_msg_objects_test.c +++ b/pceplib/test/pcep_msg_objects_test.c @@ -49,18 +49,18 @@ int pcep_objects_test_suite_teardown(void) return 0; } -void reset_objects_buffer() +void reset_objects_buffer(void) { memset(object_buf, 0, 2000); } -void pcep_objects_test_setup() +void pcep_objects_test_setup(void) { versioning = create_default_pcep_versioning(); reset_objects_buffer(); } -void pcep_objects_test_teardown() +void pcep_objects_test_teardown(void) { destroy_pcep_versioning(versioning); } @@ -123,7 +123,7 @@ static void verify_pcep_obj_header(uint8_t obj_class, uint8_t obj_type, obj_hdr->encoded_object); } -void test_pcep_obj_create_open() +void test_pcep_obj_create_open(void) { uint8_t deadtimer = 60; uint8_t keepalive = 30; @@ -147,7 +147,7 @@ void test_pcep_obj_create_open() pcep_obj_free_object((struct pcep_object_header *)open); } -void test_pcep_obj_create_open_with_tlvs() +void test_pcep_obj_create_open_with_tlvs(void) { uint8_t deadtimer = 60; uint8_t keepalive = 30; @@ -182,7 +182,7 @@ void test_pcep_obj_create_open_with_tlvs() pcep_obj_free_object((struct pcep_object_header *)open); } -void test_pcep_obj_create_rp() +void test_pcep_obj_create_rp(void) { uint32_t reqid = 15; uint8_t invalid_priority = 100; @@ -213,7 +213,7 @@ void test_pcep_obj_create_rp() pcep_obj_free_object((struct pcep_object_header *)rp); } -void test_pcep_obj_create_nopath() +void test_pcep_obj_create_nopath(void) { uint8_t ni = 8; uint32_t errorcode = 42; @@ -251,7 +251,8 @@ void test_pcep_obj_create_nopath() pcep_obj_free_object((struct pcep_object_header *)nopath); } -void test_pcep_obj_create_association_ipv4() + +void test_pcep_obj_create_association_ipv4(void) { uint16_t all_assoc_groups = 0xffff; @@ -275,7 +276,7 @@ void test_pcep_obj_create_association_ipv4() pcep_obj_free_object((struct pcep_object_header *)assoc); } -void test_pcep_obj_create_association_ipv6() +void test_pcep_obj_create_association_ipv6(void) { uint32_t all_assoc_groups = 0xffff; struct in6_addr src; @@ -305,7 +306,7 @@ void test_pcep_obj_create_association_ipv6() pcep_obj_free_object((struct pcep_object_header *)assoc); } -void test_pcep_obj_create_endpoint_ipv4() +void test_pcep_obj_create_endpoint_ipv4(void) { struct in_addr src_ipv4, dst_ipv4; inet_pton(AF_INET, "192.168.1.2", &src_ipv4); @@ -334,7 +335,7 @@ void test_pcep_obj_create_endpoint_ipv4() pcep_obj_free_object((struct pcep_object_header *)ipv4); } -void test_pcep_obj_create_endpoint_ipv6() +void test_pcep_obj_create_endpoint_ipv6(void) { struct in6_addr src_ipv6, dst_ipv6; inet_pton(AF_INET6, "2001:db8::8a2e:370:7334", &src_ipv6); @@ -368,7 +369,7 @@ void test_pcep_obj_create_endpoint_ipv6() pcep_obj_free_object((struct pcep_object_header *)ipv6); } -void test_pcep_obj_create_bandwidth() +void test_pcep_obj_create_bandwidth(void) { /* 1.8 => binary 1.11001101 * exponent = 127 => 0111 1111 @@ -389,7 +390,7 @@ void test_pcep_obj_create_bandwidth() pcep_obj_free_object((struct pcep_object_header *)bw); } -void test_pcep_obj_create_metric() +void test_pcep_obj_create_metric(void) { uint8_t type = PCEP_METRIC_BORDER_NODE_COUNT; /* https://en.wikipedia.org/wiki/IEEE_754-1985 @@ -421,7 +422,7 @@ void test_pcep_obj_create_metric() pcep_obj_free_object((struct pcep_object_header *)metric); } -void test_pcep_obj_create_lspa() +void test_pcep_obj_create_lspa(void) { uint32_t exclude_any = 10; uint32_t include_any = 20; @@ -448,7 +449,7 @@ void test_pcep_obj_create_lspa() pcep_obj_free_object((struct pcep_object_header *)lspa); } -void test_pcep_obj_create_svec() +void test_pcep_obj_create_svec(void) { struct pcep_object_svec *svec = pcep_obj_create_svec(true, true, true, NULL); @@ -479,7 +480,7 @@ void test_pcep_obj_create_svec() pcep_obj_free_object((struct pcep_object_header *)svec); } -void test_pcep_obj_create_error() +void test_pcep_obj_create_error(void) { uint8_t error_type = PCEP_ERRT_SESSION_FAILURE; uint8_t error_value = PCEP_ERRV_RECVD_INVALID_OPEN_MSG; @@ -499,7 +500,7 @@ void test_pcep_obj_create_error() pcep_obj_free_object((struct pcep_object_header *)error); } -void test_pcep_obj_create_close() +void test_pcep_obj_create_close(void) { uint8_t reason = PCEP_CLOSE_REASON_DEADTIMER; @@ -517,7 +518,7 @@ void test_pcep_obj_create_close() pcep_obj_free_object((struct pcep_object_header *)close); } -void test_pcep_obj_create_srp() +void test_pcep_obj_create_srp(void) { bool lsp_remove = true; uint32_t srp_id_number = 0x89674523; @@ -538,7 +539,7 @@ void test_pcep_obj_create_srp() pcep_obj_free_object((struct pcep_object_header *)srp); } -void test_pcep_obj_create_lsp() +void test_pcep_obj_create_lsp(void) { uint32_t plsp_id = 0x000fffff; enum pcep_lsp_operational_status status = PCEP_LSP_OPERATIONAL_ACTIVE; @@ -579,7 +580,7 @@ void test_pcep_obj_create_lsp() pcep_obj_free_object((struct pcep_object_header *)lsp); } -void test_pcep_obj_create_vendor_info() +void test_pcep_obj_create_vendor_info(void) { uint32_t enterprise_number = 0x01020304; uint32_t enterprise_specific_info = 0x05060708; @@ -645,19 +646,19 @@ static void test_pcep_obj_create_object_common(ro_func func_to_test, pcep_obj_free_object((struct pcep_object_header *)ero); } -void test_pcep_obj_create_ero() +void test_pcep_obj_create_ero(void) { test_pcep_obj_create_object_common( pcep_obj_create_ero, PCEP_OBJ_CLASS_ERO, PCEP_OBJ_TYPE_ERO); } -void test_pcep_obj_create_rro() +void test_pcep_obj_create_rro(void) { test_pcep_obj_create_object_common( pcep_obj_create_rro, PCEP_OBJ_CLASS_RRO, PCEP_OBJ_TYPE_RRO); } -void test_pcep_obj_create_iro() +void test_pcep_obj_create_iro(void) { test_pcep_obj_create_object_common( pcep_obj_create_iro, PCEP_OBJ_CLASS_IRO, PCEP_OBJ_TYPE_IRO); @@ -731,7 +732,7 @@ verify_pcep_obj_ro_sr_header(struct pcep_object_ro *ro, } } -void test_pcep_obj_create_ro_subobj_ipv4() +void test_pcep_obj_create_ro_subobj_ipv4(void) { struct in_addr ro_ipv4; inet_pton(AF_INET, "192.168.1.2", &ro_ipv4); @@ -768,7 +769,7 @@ void test_pcep_obj_create_ro_subobj_ipv4() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_ipv6() +void test_pcep_obj_create_ro_subobj_ipv6(void) { struct in6_addr ro_ipv6; uint8_t prefix_len = 16; @@ -811,7 +812,7 @@ void test_pcep_obj_create_ro_subobj_ipv6() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_unnum() +void test_pcep_obj_create_ro_subobj_unnum(void) { struct in_addr router_id; uint32_t if_id = 123; @@ -836,7 +837,7 @@ void test_pcep_obj_create_ro_subobj_unnum() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_32label() +void test_pcep_obj_create_ro_subobj_32label(void) { uint8_t class_type = 1; uint32_t label = 0xeeffaabb; @@ -856,7 +857,7 @@ void test_pcep_obj_create_ro_subobj_32label() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_asn() +void test_pcep_obj_create_ro_subobj_asn(void) { uint16_t asn = 0x0102; @@ -871,7 +872,7 @@ void test_pcep_obj_create_ro_subobj_asn() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_sr_nonai() +void test_pcep_obj_create_ro_subobj_sr_nonai(void) { uint32_t sid = 0x01020304; @@ -902,7 +903,7 @@ void test_pcep_obj_create_ro_subobj_sr_nonai() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_sr_ipv4_node() +void test_pcep_obj_create_ro_subobj_sr_ipv4_node(void) { uint32_t sid = 0x01020304; struct in_addr ipv4_node_id; @@ -954,7 +955,7 @@ void test_pcep_obj_create_ro_subobj_sr_ipv4_node() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_sr_ipv6_node() +void test_pcep_obj_create_ro_subobj_sr_ipv6_node(void) { uint32_t sid = 0x01020304; struct in6_addr ipv6_node_id; @@ -1007,7 +1008,7 @@ void test_pcep_obj_create_ro_subobj_sr_ipv6_node() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_sr_ipv4_adj() +void test_pcep_obj_create_ro_subobj_sr_ipv4_adj(void) { struct in_addr local_ipv4; struct in_addr remote_ipv4; @@ -1072,7 +1073,7 @@ void test_pcep_obj_create_ro_subobj_sr_ipv4_adj() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_sr_ipv6_adj() +void test_pcep_obj_create_ro_subobj_sr_ipv6_adj(void) { uint32_t sid = 0x01020304; struct in6_addr local_ipv6; @@ -1147,7 +1148,7 @@ void test_pcep_obj_create_ro_subobj_sr_ipv6_adj() pcep_obj_free_object((struct pcep_object_header *)ro); } -void test_pcep_obj_create_ro_subobj_sr_unnumbered_ipv4_adj() +void test_pcep_obj_create_ro_subobj_sr_unnumbered_ipv4_adj(void) { uint32_t sid = 0x01020304; uint32_t local_node_id = 0x11223344; @@ -1208,7 +1209,7 @@ void test_pcep_obj_create_ro_subobj_sr_unnumbered_ipv4_adj() /* TODO Test draft07 types */ } -void test_pcep_obj_create_ro_subobj_sr_linklocal_ipv6_adj() +void test_pcep_obj_create_ro_subobj_sr_linklocal_ipv6_adj(void) { uint32_t sid = 0x01020304; uint32_t local_if_id = 0x11002200; diff --git a/pceplib/test/pcep_msg_tlvs_test.c b/pceplib/test/pcep_msg_tlvs_test.c index 3ead269a6f6f..fc11205f2dfe 100644 --- a/pceplib/test/pcep_msg_tlvs_test.c +++ b/pceplib/test/pcep_msg_tlvs_test.c @@ -55,23 +55,23 @@ int pcep_tlvs_test_suite_teardown(void) return 0; } -void reset_tlv_buffer() +void reset_tlv_buffer(void) { memset(tlv_buf, 0, 2000); } -void pcep_tlvs_test_setup() +void pcep_tlvs_test_setup(void) { versioning = create_default_pcep_versioning(); reset_tlv_buffer(); } -void pcep_tlvs_test_teardown() +void pcep_tlvs_test_teardown(void) { destroy_pcep_versioning(versioning); } -void test_pcep_tlv_create_stateful_pce_capability() +void test_pcep_tlv_create_stateful_pce_capability(void) { struct pcep_object_tlv_stateful_pce_capability *tlv = pcep_tlv_create_stateful_pce_capability(true, true, true, true, @@ -96,7 +96,7 @@ void test_pcep_tlv_create_stateful_pce_capability() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_speaker_entity_id() +void test_pcep_tlv_create_speaker_entity_id(void) { struct pcep_object_tlv_speaker_entity_identifier *tlv = pcep_tlv_create_speaker_entity_id(NULL); @@ -105,10 +105,8 @@ void test_pcep_tlv_create_speaker_entity_id() double_linked_list *list = dll_initialize(); tlv = pcep_tlv_create_speaker_entity_id(list); CU_ASSERT_PTR_NULL(tlv); - if (tlv != NULL) { + if (tlv != NULL) pceplib_free(PCEPLIB_INFRA, tlv); - tlv = NULL; - } uint32_t *speaker_entity = pceplib_malloc(PCEPLIB_MESSAGES, sizeof(uint32_t)); @@ -130,7 +128,7 @@ void test_pcep_tlv_create_speaker_entity_id() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_lsp_db_version() +void test_pcep_tlv_create_lsp_db_version(void) { uint64_t lsp_db_version = 0xf005ba11ba5eba11; struct pcep_object_tlv_lsp_db_version *tlv = @@ -148,7 +146,7 @@ void test_pcep_tlv_create_lsp_db_version() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_path_setup_type() +void test_pcep_tlv_create_path_setup_type(void) { uint8_t pst = 0x89; @@ -166,7 +164,7 @@ void test_pcep_tlv_create_path_setup_type() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_path_setup_type_capability() +void test_pcep_tlv_create_path_setup_type_capability(void) { /* The sub_tlv list is optional */ @@ -179,28 +177,22 @@ void test_pcep_tlv_create_path_setup_type_capability() double_linked_list *pst_list = dll_initialize(); tlv = pcep_tlv_create_path_setup_type_capability(pst_list, NULL); CU_ASSERT_PTR_NULL(tlv); - if (tlv != NULL) { + if (tlv != NULL) pcep_obj_free_tlv(&tlv->header); - tlv = NULL; - } /* Should still return NULL if pst_list is NULL */ double_linked_list *sub_tlv_list = dll_initialize(); tlv = pcep_tlv_create_path_setup_type_capability(NULL, sub_tlv_list); CU_ASSERT_PTR_NULL(tlv); - if (tlv != NULL) { + if (tlv != NULL) pcep_obj_free_tlv(&tlv->header); - tlv = NULL; - } /* Should still return NULL if pst_list is empty */ tlv = pcep_tlv_create_path_setup_type_capability(pst_list, sub_tlv_list); CU_ASSERT_PTR_NULL(tlv); - if (tlv != NULL) { + if (tlv != NULL) pcep_obj_free_tlv(&tlv->header); - tlv = NULL; - } /* Test only populating the pst list */ uint8_t *pst1 = pceplib_malloc(PCEPLIB_MESSAGES, 1); @@ -274,7 +266,7 @@ void test_pcep_tlv_create_path_setup_type_capability() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_sr_pce_capability() +void test_pcep_tlv_create_sr_pce_capability(void) { struct pcep_object_tlv_sr_pce_capability *tlv = pcep_tlv_create_sr_pce_capability(true, true, 8); @@ -294,7 +286,7 @@ void test_pcep_tlv_create_sr_pce_capability() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_symbolic_path_name() +void test_pcep_tlv_create_symbolic_path_name(void) { /* char *symbolic_path_name, uint16_t symbolic_path_name_length); */ char path_name[16] = "Some Path Name"; @@ -336,7 +328,7 @@ void test_pcep_tlv_create_symbolic_path_name() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_ipv4_lsp_identifiers() +void test_pcep_tlv_create_ipv4_lsp_identifiers(void) { struct in_addr sender_ip, endpoint_ip; uint16_t lsp_id = 7; @@ -397,7 +389,7 @@ void test_pcep_tlv_create_ipv4_lsp_identifiers() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_ipv6_lsp_identifiers() +void test_pcep_tlv_create_ipv6_lsp_identifiers(void) { struct in6_addr sender_ip, endpoint_ip; uint16_t lsp_id = 3; @@ -444,7 +436,8 @@ void test_pcep_tlv_create_ipv6_lsp_identifiers() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_srpag_pol_id_ipv4() + +void test_pcep_tlv_create_srpag_pol_id_ipv4(void) { uint32_t color = 1; struct in_addr src; @@ -474,7 +467,8 @@ void test_pcep_tlv_create_srpag_pol_id_ipv4() pceplib_free(PCEPLIB_MESSAGES, dec_hdr); pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_srpag_pol_id_ipv6() + +void test_pcep_tlv_create_srpag_pol_id_ipv6(void) { uint32_t color = 1; @@ -504,7 +498,7 @@ void test_pcep_tlv_create_srpag_pol_id_ipv6() pceplib_free(PCEPLIB_MESSAGES, dec_hdr); pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_srpag_pol_name() +void test_pcep_tlv_create_srpag_pol_name(void) { const char *pol_name = "Some Pol Name"; @@ -524,7 +518,7 @@ void test_pcep_tlv_create_srpag_pol_name() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_srpag_cp_id() +void test_pcep_tlv_create_srpag_cp_id(void) { // draft-ietf-spring-segment-routing-policy-06.pdf#2.3 // 10 PCEP, 20 BGP SR Policy, 30 Via Configuration @@ -558,7 +552,7 @@ void test_pcep_tlv_create_srpag_cp_id() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_srpag_cp_pref() +void test_pcep_tlv_create_srpag_cp_pref(void) { uint32_t preference_default = 100; @@ -587,7 +581,8 @@ void test_pcep_tlv_create_srpag_cp_pref() pceplib_free(PCEPLIB_MESSAGES, dec_hdr); pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_lsp_error_code() + +void test_pcep_tlv_create_lsp_error_code(void) { struct pcep_object_tlv_lsp_error_code *tlv = pcep_tlv_create_lsp_error_code( @@ -605,7 +600,7 @@ void test_pcep_tlv_create_lsp_error_code() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_rsvp_ipv4_error_spec() +void test_pcep_tlv_create_rsvp_ipv4_error_spec(void) { struct in_addr error_node_ip; inet_pton(AF_INET, "192.168.1.1", &error_node_ip); @@ -629,7 +624,7 @@ void test_pcep_tlv_create_rsvp_ipv4_error_spec() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_rsvp_ipv6_error_spec() +void test_pcep_tlv_create_rsvp_ipv6_error_spec(void) { struct in6_addr error_node_ip; inet_pton(AF_INET6, "2001:db8::8a2e:370:7334", &error_node_ip); @@ -653,7 +648,7 @@ void test_pcep_tlv_create_rsvp_ipv6_error_spec() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_nopath_vector() +void test_pcep_tlv_create_nopath_vector(void) { uint32_t enterprise_number = 0x01020304; uint32_t enterprise_specific_info = 0x05060708; @@ -673,7 +668,7 @@ void test_pcep_tlv_create_nopath_vector() pcep_obj_free_tlv(&tlv->header); } -void test_pcep_tlv_create_arbitrary() +void test_pcep_tlv_create_arbitrary(void) { char data[16] = "Some Data"; uint16_t data_length = 9; diff --git a/pceplib/test/pcep_msg_tools_test.c b/pceplib/test/pcep_msg_tools_test.c index 858650ec8f2d..440cccdadcee 100644 --- a/pceplib/test/pcep_msg_tools_test.c +++ b/pceplib/test/pcep_msg_tools_test.c @@ -199,7 +199,7 @@ static bool pcep_obj_has_tlv(struct pcep_object_header *obj_hdr) return (obj_hdr->tlv_list->num_entries > 0); } -void test_pcep_msg_read_pcep_initiate() +void test_pcep_msg_read_pcep_initiate(void) { char filename[BASE_TMPFILE_SIZE]; @@ -303,7 +303,7 @@ void test_pcep_msg_read_pcep_initiate() } -void test_pcep_msg_read_pcep_initiate2() +void test_pcep_msg_read_pcep_initiate2(void) { char filename[BASE_TMPFILE_SIZE]; @@ -396,7 +396,7 @@ void test_pcep_msg_read_pcep_initiate2() unlink(filename); } -void test_pcep_msg_read_pcep_open() +void test_pcep_msg_read_pcep_open(void) { char filename[BASE_TMPFILE_SIZE]; @@ -444,7 +444,7 @@ void test_pcep_msg_read_pcep_open() unlink(filename); } -void test_pcep_msg_read_pcep_update() +void test_pcep_msg_read_pcep_update(void) { char filename[BASE_TMPFILE_SIZE]; @@ -530,7 +530,7 @@ void test_pcep_msg_read_pcep_update() unlink(filename); } -void test_pcep_msg_read_pcep_open_initiate() +void test_pcep_msg_read_pcep_open_initiate(void) { char filename[BASE_TMPFILE_SIZE]; @@ -563,7 +563,7 @@ void test_pcep_msg_read_pcep_open_initiate() unlink(filename); } -void test_pcep_msg_read_pcep_open_cisco_pce() +void test_pcep_msg_read_pcep_open_cisco_pce(void) { char filename[BASE_TMPFILE_SIZE]; @@ -630,7 +630,7 @@ void test_pcep_msg_read_pcep_open_cisco_pce() unlink(filename); } -void test_pcep_msg_read_pcep_update_cisco_pce() +void test_pcep_msg_read_pcep_update_cisco_pce(void) { char filename[BASE_TMPFILE_SIZE]; @@ -778,7 +778,7 @@ void test_pcep_msg_read_pcep_update_cisco_pce() unlink(filename); } -void test_pcep_msg_read_pcep_report_cisco_pcc() +void test_pcep_msg_read_pcep_report_cisco_pcc(void) { char filename[BASE_TMPFILE_SIZE]; @@ -943,7 +943,7 @@ void test_pcep_msg_read_pcep_report_cisco_pcc() unlink(filename); } -void test_pcep_msg_read_pcep_initiate_cisco_pcc() +void test_pcep_msg_read_pcep_initiate_cisco_pcc(void) { char filename[BASE_TMPFILE_SIZE]; @@ -1055,7 +1055,7 @@ void test_pcep_msg_read_pcep_initiate_cisco_pcc() unlink(filename); } -void test_validate_message_header() +void test_validate_message_header(void) { uint8_t pcep_message_invalid_version[] = {0x40, 0x01, 0x04, 0x00}; uint8_t pcep_message_invalid_flags[] = {0x22, 0x01, 0x04, 0x00}; @@ -1141,7 +1141,7 @@ struct pcep_message *create_message(uint8_t msg_type, uint8_t obj1_class, return msg; } -void test_validate_message_objects() +void test_validate_message_objects(void) { /* Valid Open message */ struct pcep_message *msg = @@ -1203,7 +1203,7 @@ void test_validate_message_objects() pcep_msg_free_message(msg); } -void test_validate_message_objects_invalid() +void test_validate_message_objects_invalid(void) { /* unsupported message ID = 0 * {NO_OBJECT, NO_OBJECT, NO_OBJECT, NO_OBJECT} */ diff --git a/pceplib/test/pcep_pcc_api_test.c b/pceplib/test/pcep_pcc_api_test.c index 904308fdfd3a..768325a5a2e7 100644 --- a/pceplib/test/pcep_pcc_api_test.c +++ b/pceplib/test/pcep_pcc_api_test.c @@ -34,13 +34,13 @@ extern const char UNKNOWN_EVENT_STR[]; * Test suite setup and teardown called before AND after the test suite. */ -int pcep_pcc_api_test_suite_setup() +int pcep_pcc_api_test_suite_setup(void) { pceplib_memory_reset(); return 0; } -int pcep_pcc_api_test_suite_teardown() +int pcep_pcc_api_test_suite_teardown(void) { printf("\n"); pceplib_memory_dump(); @@ -51,13 +51,13 @@ int pcep_pcc_api_test_suite_teardown() * Test case setup and teardown called before AND after each test. */ -void pcep_pcc_api_test_setup() +void pcep_pcc_api_test_setup(void) { setup_mock_socket_comm_info(); } -void pcep_pcc_api_test_teardown() +void pcep_pcc_api_test_teardown(void) { teardown_mock_socket_comm_info(); } @@ -66,7 +66,7 @@ void pcep_pcc_api_test_teardown() * Unit test cases */ -void test_initialize_pcc() +void test_initialize_pcc(void) { CU_ASSERT_TRUE(initialize_pcc()); /* Give the PCC time to initialize */ @@ -74,7 +74,7 @@ void test_initialize_pcc() CU_ASSERT_TRUE(destroy_pcc()); } -void test_connect_pce() +void test_connect_pce(void) { pcep_configuration *config = create_default_pcep_configuration(); struct hostent *host_info = gethostbyname("localhost"); @@ -109,7 +109,7 @@ void test_connect_pce() destroy_pcc(); } -void test_connect_pce_ipv6() +void test_connect_pce_ipv6(void) { pcep_configuration *config = create_default_pcep_configuration(); struct in6_addr dest_address; @@ -147,7 +147,7 @@ void test_connect_pce_ipv6() destroy_pcc(); } -void test_connect_pce_with_src_ip() +void test_connect_pce_with_src_ip(void) { pcep_configuration *config = create_default_pcep_configuration(); struct hostent *host_info = gethostbyname("localhost"); @@ -180,7 +180,7 @@ void test_connect_pce_with_src_ip() destroy_pcc(); } -void test_disconnect_pce() +void test_disconnect_pce(void) { pcep_configuration *config = create_default_pcep_configuration(); struct hostent *host_info = gethostbyname("localhost"); @@ -225,7 +225,7 @@ void test_disconnect_pce() } -void test_send_message() +void test_send_message(void) { pcep_configuration *config = create_default_pcep_configuration(); struct hostent *host_info = gethostbyname("localhost"); @@ -249,7 +249,7 @@ void test_send_message() destroy_pcc(); } -void test_event_queue() +void test_event_queue(void) { /* This initializes the event_queue */ CU_ASSERT_TRUE(initialize_pcc()); @@ -278,7 +278,7 @@ void test_event_queue() CU_ASSERT_TRUE(destroy_pcc()); } -void test_get_event_type_str() +void test_get_event_type_str(void) { CU_ASSERT_EQUAL(strcmp(get_event_type_str(MESSAGE_RECEIVED), MESSAGE_RECEIVED_STR), diff --git a/pceplib/test/pcep_utils_counters_test.c b/pceplib/test/pcep_utils_counters_test.c index d3d5197b5308..7fa2f3ce62fb 100644 --- a/pceplib/test/pcep_utils_counters_test.c +++ b/pceplib/test/pcep_utils_counters_test.c @@ -22,7 +22,7 @@ #include "pcep_utils_counters_test.h" -void test_create_counters_group() +void test_create_counters_group(void) { const char group_name[] = "group"; uint16_t num_subgroups = 10; @@ -45,7 +45,7 @@ void test_create_counters_group() delete_counters_group(group); } -void test_create_counters_subgroup() +void test_create_counters_subgroup(void) { const char subgroup_name[] = "subgroup"; uint16_t subgroup_id = 10; @@ -77,7 +77,7 @@ void test_create_counters_subgroup() delete_counters_subgroup(subgroup); } -void test_add_counters_subgroup() +void test_add_counters_subgroup(void) { struct counters_group *group = create_counters_group("group", 1); struct counters_subgroup *subgroup1 = @@ -102,7 +102,7 @@ void test_add_counters_subgroup() delete_counters_subgroup(subgroup2); } -void test_create_subgroup_counter() +void test_create_subgroup_counter(void) { uint16_t counter_id = 1; char counter_name[] = "my counter"; @@ -113,7 +113,7 @@ void test_create_subgroup_counter() CU_ASSERT_FALSE(create_subgroup_counter(NULL, counter_id, counter_name, counter_name_json)); CU_ASSERT_FALSE(create_subgroup_counter(subgroup, counter_id + 1, - counter_name)); + counter_name, counter_name_json)); CU_ASSERT_FALSE( create_subgroup_counter(subgroup, counter_id, NULL, NULL)); CU_ASSERT_EQUAL(subgroup->num_counters, 0); @@ -124,7 +124,7 @@ void test_create_subgroup_counter() delete_counters_subgroup(subgroup); } -void test_delete_counters_group() +void test_delete_counters_group(void) { struct counters_group *group = create_counters_group("group", 1); @@ -132,7 +132,7 @@ void test_delete_counters_group() CU_ASSERT_TRUE(delete_counters_group(group)); } -void test_delete_counters_subgroup() +void test_delete_counters_subgroup(void) { struct counters_subgroup *subgroup = create_counters_subgroup("subgroup", 1, 1); @@ -141,7 +141,7 @@ void test_delete_counters_subgroup() CU_ASSERT_TRUE(delete_counters_subgroup(subgroup)); } -void test_reset_group_counters() +void test_reset_group_counters(void) { uint16_t subgroup_id = 1; uint16_t counter_id = 1; @@ -161,7 +161,7 @@ void test_reset_group_counters() delete_counters_group(group); } -void test_reset_subgroup_counters() +void test_reset_subgroup_counters(void) { uint16_t counter_id = 1; struct counters_subgroup *subgroup = @@ -178,7 +178,7 @@ void test_reset_subgroup_counters() delete_counters_subgroup(subgroup); } -void test_increment_counter() +void test_increment_counter(void) { uint16_t subgroup_id = 1; uint16_t counter_id = 1; @@ -201,7 +201,7 @@ void test_increment_counter() delete_counters_group(group); } -void test_increment_subgroup_counter() +void test_increment_subgroup_counter(void) { int counter_id = 1; uint32_t counter_value = 100; @@ -220,7 +220,7 @@ void test_increment_subgroup_counter() delete_counters_subgroup(subgroup); } -void test_dump_counters_group_to_log() +void test_dump_counters_group_to_log(void) { uint16_t subgroup_id = 1; uint16_t counter_id = 1; @@ -236,7 +236,7 @@ void test_dump_counters_group_to_log() delete_counters_group(group); } -void test_dump_counters_subgroup_to_log() +void test_dump_counters_subgroup_to_log(void) { uint16_t subgroup_id = 1; uint16_t counter_id = 1; diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 59addd48c0b8..ee318d45e3d4 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -525,7 +525,9 @@ int pim_process_rp_cmd(struct vty *vty, const char *rp_str, const char *group_str) { const char *vrfname; - char rp_group_xpath[XPATH_MAXLEN]; + char group_xpath[XPATH_MAXLEN]; + char rp_xpath[XPATH_MAXLEN]; + int printed; int result = 0; struct prefix group; pim_addr rp_addr; @@ -570,12 +572,18 @@ int pim_process_rp_cmd(struct vty *vty, const char *rp_str, if (vrfname == NULL) return CMD_WARNING_CONFIG_FAILED; - snprintf(rp_group_xpath, sizeof(rp_group_xpath), - FRR_PIM_STATIC_RP_XPATH, "frr-pim:pimd", "pim", vrfname, - FRR_PIM_AF_XPATH_VAL, rp_str); - strlcat(rp_group_xpath, "/group-list", sizeof(rp_group_xpath)); + snprintf(rp_xpath, sizeof(rp_xpath), FRR_PIM_STATIC_RP_XPATH, + "frr-pim:pimd", "pim", vrfname, FRR_PIM_AF_XPATH_VAL, rp_str); + printed = snprintf(group_xpath, sizeof(group_xpath), + "%s/group-list[.='%s']", rp_xpath, group_str); + + if (printed >= (int)(sizeof(group_xpath))) { + vty_out(vty, "Xpath too long (%d > %u)", printed + 1, + XPATH_MAXLEN); + return CMD_WARNING_CONFIG_FAILED; + } - nb_cli_enqueue_change(vty, rp_group_xpath, NB_OP_CREATE, group_str); + nb_cli_enqueue_change(vty, group_xpath, NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -583,7 +591,6 @@ int pim_process_rp_cmd(struct vty *vty, const char *rp_str, int pim_process_no_rp_cmd(struct vty *vty, const char *rp_str, const char *group_str) { - char group_list_xpath[XPATH_MAXLEN]; char group_xpath[XPATH_MAXLEN]; char rp_xpath[XPATH_MAXLEN]; int printed; @@ -596,18 +603,8 @@ int pim_process_no_rp_cmd(struct vty *vty, const char *rp_str, snprintf(rp_xpath, sizeof(rp_xpath), FRR_PIM_STATIC_RP_XPATH, "frr-pim:pimd", "pim", vrfname, FRR_PIM_AF_XPATH_VAL, rp_str); - - printed = snprintf(group_list_xpath, sizeof(group_list_xpath), - "%s/group-list", rp_xpath); - - if (printed >= (int)(sizeof(group_list_xpath))) { - vty_out(vty, "Xpath too long (%d > %u)", printed + 1, - XPATH_MAXLEN); - return CMD_WARNING_CONFIG_FAILED; - } - - printed = snprintf(group_xpath, sizeof(group_xpath), "%s[.='%s']", - group_list_xpath, group_str); + printed = snprintf(group_xpath, sizeof(group_xpath), + "%s/group-list[.='%s']", rp_xpath, group_str); if (printed >= (int)(sizeof(group_xpath))) { vty_out(vty, "Xpath too long (%d > %u)", printed + 1, @@ -624,8 +621,7 @@ int pim_process_no_rp_cmd(struct vty *vty, const char *rp_str, if (yang_is_last_list_dnode(group_dnode)) nb_cli_enqueue_change(vty, rp_xpath, NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, group_list_xpath, NB_OP_DESTROY, - group_str); + nb_cli_enqueue_change(vty, group_xpath, NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -3407,6 +3403,8 @@ int pim_process_ssmpingd_cmd(struct vty *vty, enum nb_operation operation, { const char *vrfname; char ssmpingd_ip_xpath[XPATH_MAXLEN]; + char ssmpingd_src_ip_xpath[XPATH_MAXLEN]; + int printed; vrfname = pim_cli_get_vrf_name(vty); if (vrfname == NULL) @@ -3415,10 +3413,16 @@ int pim_process_ssmpingd_cmd(struct vty *vty, enum nb_operation operation, snprintf(ssmpingd_ip_xpath, sizeof(ssmpingd_ip_xpath), FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname, FRR_PIM_AF_XPATH_VAL); - strlcat(ssmpingd_ip_xpath, "/ssm-pingd-source-ip", - sizeof(ssmpingd_ip_xpath)); + printed = snprintf(ssmpingd_src_ip_xpath, sizeof(ssmpingd_src_ip_xpath), + "%s/ssm-pingd-source-ip[.='%s']", ssmpingd_ip_xpath, + src_str); + if (printed >= (int)sizeof(ssmpingd_src_ip_xpath)) { + vty_out(vty, "Xpath too long (%d > %u)", printed + 1, + XPATH_MAXLEN); + return CMD_WARNING_CONFIG_FAILED; + } - nb_cli_enqueue_change(vty, ssmpingd_ip_xpath, operation, src_str); + nb_cli_enqueue_change(vty, ssmpingd_src_ip_xpath, operation, NULL); return nb_cli_apply_changes(vty, NULL); } diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index daa83dd0550a..fbe647c5cafa 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -273,8 +273,13 @@ DEFPY_YANG (rip_neighbor, "Specify a neighbor router\n" "Neighbor address\n") { - nb_cli_enqueue_change(vty, "./explicit-neighbor", - no ? NB_OP_DESTROY : NB_OP_CREATE, neighbor_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./explicit-neighbor[.='%s']", + neighbor_str); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -295,8 +300,12 @@ DEFPY_YANG (rip_network_prefix, "Enable routing on an IP network\n" "IP prefix /, e.g., 35.0.0.0/8\n") { - nb_cli_enqueue_change(vty, "./network", - no ? NB_OP_DESTROY : NB_OP_CREATE, network_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./network[.='%s']", network_str); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -317,8 +326,12 @@ DEFPY_YANG (rip_network_if, "Enable routing on an IP network\n" "Interface name\n") { - nb_cli_enqueue_change(vty, "./interface", - no ? NB_OP_DESTROY : NB_OP_CREATE, network); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./interface[.='%s']", network); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -412,17 +425,21 @@ DEFPY_YANG (rip_passive_interface, bool passive_default = yang_dnode_get_bool(vty->candidate_config->dnode, "%s%s", VTY_CURR_XPATH, "/passive-default"); + char xpath[XPATH_MAXLEN]; + enum nb_operation op; if (passive_default) { - nb_cli_enqueue_change(vty, "./non-passive-interface", - no ? NB_OP_CREATE : NB_OP_DESTROY, - ifname); + snprintf(xpath, sizeof(xpath), + "./non-passive-interface[.='%s']", ifname); + op = no ? NB_OP_CREATE : NB_OP_DESTROY; } else { - nb_cli_enqueue_change(vty, "./passive-interface", - no ? NB_OP_DESTROY : NB_OP_CREATE, - ifname); + snprintf(xpath, sizeof(xpath), "./passive-interface[.='%s']", + ifname); + op = no ? NB_OP_DESTROY : NB_OP_CREATE; } + nb_cli_enqueue_change(vty, xpath, op, NULL); + return nb_cli_apply_changes(vty, NULL); } @@ -495,8 +512,12 @@ DEFPY_YANG (rip_route, "RIP static route configuration\n" "IP prefix /\n") { - nb_cli_enqueue_change(vty, "./static-route", - no ? NB_OP_DESTROY : NB_OP_CREATE, route_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./static-route[.='%s']", route_str); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c index aa9f3cc0375b..ee561087c9ee 100644 --- a/ripngd/ripng_cli.c +++ b/ripngd/ripng_cli.c @@ -199,8 +199,12 @@ DEFPY_YANG (ripng_network_prefix, "RIPng enable on specified interface or network.\n" "IPv6 network\n") { - nb_cli_enqueue_change(vty, "./network", - no ? NB_OP_DESTROY : NB_OP_CREATE, network_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./network[.='%s']", network_str); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -222,8 +226,12 @@ DEFPY_YANG (ripng_network_if, "RIPng enable on specified interface or network.\n" "Interface name\n") { - nb_cli_enqueue_change(vty, "./interface", - no ? NB_OP_DESTROY : NB_OP_CREATE, network); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./interface[.='%s']", network); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -288,8 +296,12 @@ DEFPY_YANG (ripng_passive_interface, "Suppress routing updates on an interface\n" "Interface name\n") { - nb_cli_enqueue_change(vty, "./passive-interface", - no ? NB_OP_DESTROY : NB_OP_CREATE, ifname); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./passive-interface[.='%s']", ifname); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + ifname); return nb_cli_apply_changes(vty, NULL); } @@ -355,8 +367,12 @@ DEFPY_YANG (ripng_route, "Static route setup\n" "Set static RIPng route announcement\n") { - nb_cli_enqueue_change(vty, "./static-route", - no ? NB_OP_DESTROY : NB_OP_CREATE, route_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./static-route[.='%s']", route_str); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -377,9 +393,13 @@ DEFPY_YANG (ripng_aggregate_address, "Set aggregate RIPng route announcement\n" "Aggregate network\n") { - nb_cli_enqueue_change(vty, "./aggregate-address", - no ? NB_OP_DESTROY : NB_OP_CREATE, - aggregate_address_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./aggregate-address[.='%s']", + aggregate_address_str); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } diff --git a/tests/topotests/nhrp_topo/test_nhrp_topo.py b/tests/topotests/nhrp_topo/test_nhrp_topo.py index 78b82eda79b2..26115de2b866 100644 --- a/tests/topotests/nhrp_topo/test_nhrp_topo.py +++ b/tests/topotests/nhrp_topo/test_nhrp_topo.py @@ -182,6 +182,27 @@ def test_protocols_convergence(): assertmsg = '"{}" JSON output mismatches'.format(router.name) assert result is None, assertmsg + # check that the NOARP flag is removed from rX-gre0 interfaces + for rname, router in router_list.items(): + if rname == "r3": + continue + + expected = { + "{}-gre0".format(rname): { + "flags": "", + } + } + test_func = partial( + topotest.router_json_cmp, + router, + "show interface {}-gre0 json".format(rname), + expected, + ) + _, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5) + + assertmsg = '"{}-gre0 interface flags incorrect'.format(router.name) + assert result is None, assertmsg + for rname, router in router_list.items(): if rname == "r3": continue diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c index bbdf48b32627..fd6cbc8b6740 100644 --- a/vrrpd/vrrp_vty.c +++ b/vrrpd/vrrp_vty.c @@ -200,7 +200,11 @@ DEFPY_YANG(vrrp_ip, VRRP_IP_STR) { int op = no ? NB_OP_DESTROY : NB_OP_CREATE; - nb_cli_enqueue_change(vty, "./v4/virtual-address", op, ip_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./v4/virtual-address[.='%s']", ip_str); + + nb_cli_enqueue_change(vty, xpath, op, NULL); return nb_cli_apply_changes(vty, VRRP_XPATH_ENTRY, vrid); } @@ -228,7 +232,11 @@ DEFPY_YANG(vrrp_ip6, VRRP_IP_STR) { int op = no ? NB_OP_DESTROY : NB_OP_CREATE; - nb_cli_enqueue_change(vty, "./v6/virtual-address", op, ipv6_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./v6/virtual-address[.='%s']", ipv6_str); + + nb_cli_enqueue_change(vty, xpath, op, NULL); return nb_cli_apply_changes(vty, VRRP_XPATH_ENTRY, vrid); } diff --git a/zebra/interface.c b/zebra/interface.c index 4c6fc8c36aee..f864b9182253 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -3662,6 +3662,27 @@ DEFUN (show_interface_desc_vrf_all, return CMD_SUCCESS; } +void if_arp(struct interface *ifp, bool enable) +{ + int ret; + + if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) + return; + + if (enable) + ret = if_unset_flags(ifp, IFF_NOARP); + else + ret = if_set_flags(ifp, IFF_NOARP); + + if (ret < 0) { + zlog_debug("Can't %sset noarp flag on interface %s", + enable ? "" : "un", ifp->name); + return; + } + + if_refresh(ifp); +} + int if_multicast_set(struct interface *ifp) { struct zebra_if *if_data; @@ -4701,12 +4722,16 @@ DEFUN (no_link_params_use_bw, } static int ag_change(struct vty *vty, int argc, struct cmd_token **argv, - const char *xpath, bool no, int start_idx) + const char *xpath_base, bool no, int start_idx) { - for (int i = start_idx; i < argc; i++) + char xpath[XPATH_MAXLEN]; + + for (int i = start_idx; i < argc; i++) { + snprintf(xpath, XPATH_MAXLEN, "%s[.='%s']", xpath_base, + argv[i]->arg); nb_cli_enqueue_change(vty, xpath, - no ? NB_OP_DESTROY : NB_OP_CREATE, - argv[i]->arg); + no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); + } return nb_cli_apply_changes(vty, NULL); } diff --git a/zebra/interface.h b/zebra/interface.h index 62de2abc8031..a96f2ec7188d 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -314,6 +314,7 @@ extern int if_ipv6_address_install(struct interface *ifp, struct prefix *prefix, extern int if_ip_address_uinstall(struct interface *ifp, struct prefix *prefix); extern int if_shutdown(struct interface *ifp); extern int if_no_shutdown(struct interface *ifp); +extern void if_arp(struct interface *ifp, bool enable); extern int if_multicast_set(struct interface *ifp); extern int if_multicast_unset(struct interface *ifp); extern int if_linkdetect(struct interface *ifp, bool detect); diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 296bf12bb5c5..76cabd1bf09b 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -3124,6 +3124,28 @@ static void zread_interface_set_master(ZAPI_HANDLER_ARGS) } +static void zread_interface_set_arp(ZAPI_HANDLER_ARGS) +{ + struct stream *s = msg; + struct interface *ifp; + bool arp_enable; + vrf_id_t vrf_id = zvrf->vrf->vrf_id; + int ifindex; + + STREAM_GETL(s, ifindex); + STREAM_GETC(s, arp_enable); + ifp = if_lookup_by_index(ifindex, vrf_id); + + if (!ifp) + return; + + if_arp(ifp, arp_enable); + +stream_failure: + return; +} + + static void zread_vrf_label(ZAPI_HANDLER_ARGS) { struct interface *ifp; @@ -3905,6 +3927,7 @@ void (*const zserv_handlers[])(ZAPI_HANDLER_ARGS) = { [ZEBRA_REMOTE_MACIP_DEL] = zebra_vxlan_remote_macip_del, [ZEBRA_DUPLICATE_ADDR_DETECTION] = zebra_vxlan_dup_addr_detection, [ZEBRA_INTERFACE_SET_MASTER] = zread_interface_set_master, + [ZEBRA_INTERFACE_SET_ARP] = zread_interface_set_arp, [ZEBRA_PW_ADD] = zread_pseudowire, [ZEBRA_PW_DELETE] = zread_pseudowire, [ZEBRA_PW_SET] = zread_pseudowire, diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 9e3aa8bc5c8e..dc403b811124 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -72,25 +72,13 @@ static uint32_t nhg_get_next_id(void) while (1) { id_counter++; - if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: ID %u checking", __func__, id_counter); - if (id_counter == ZEBRA_NHG_PROTO_LOWER) { - if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: ID counter wrapped", __func__); - id_counter = 0; continue; } - if (zebra_nhg_lookup_id(id_counter)) { - if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: ID already exists", __func__); - - continue; - } - - break; + if (!zebra_nhg_lookup_id(id_counter)) + break; } return id_counter; @@ -690,12 +678,6 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */ struct nhg_hash_entry *newnhe, *backup_nhe; struct nexthop *nh = NULL; - if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug( - "%s: id %u, lookup %p, vrf %d, type %d, depends %p%s", - __func__, lookup->id, lookup, lookup->vrf_id, - lookup->type, nhg_depends, - (from_dplane ? " (from dplane)" : "")); if (lookup->id) (*nhe) = zebra_nhg_lookup_id(lookup->id); @@ -703,7 +685,10 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */ (*nhe) = hash_lookup(zrouter.nhgs, lookup); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: lookup => %p (%pNG)", __func__, *nhe, *nhe); + zlog_debug("%s: id %u, lookup %p, vrf %d, type %d, depends %p%s => Found %p(%pNG)", + __func__, lookup->id, lookup, lookup->vrf_id, + lookup->type, nhg_depends, + (from_dplane ? " (from dplane)" : ""), *nhe, *nhe); /* If we found an existing object, we're done */ if (*nhe) @@ -1537,13 +1522,11 @@ zebra_nhg_rib_find_nhe(struct nhg_hash_entry *rt_nhe, afi_t rt_afi) return NULL; } - if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: rt_nhe %p (%pNG)", __func__, rt_nhe, rt_nhe); - zebra_nhe_find(&nhe, rt_nhe, NULL, rt_afi, false); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: => nhe %p (%pNG)", __func__, nhe, nhe); + zlog_debug("%s: rt_nhe %p(%pNG) => nhe %p(%pNG)", __func__, + rt_nhe, rt_nhe, nhe, nhe); return nhe; } diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 4b5f81a3df51..9e89e32d5d55 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2874,11 +2874,10 @@ static void process_subq_early_route_add(struct zebra_early_route *ere) SET_FLAG(re->status, ROUTE_ENTRY_CHANGED); rib_addnode(rn, re, 1); + dest = rib_dest_from_rnode(rn); /* Free implicit route.*/ if (same) { - rib_dest_t *dest = rn->info; - - if (same == dest->selected_fib) + if (dest && same == dest->selected_fib) SET_FLAG(same->status, ROUTE_ENTRY_ROUTE_REPLACING); rib_delnode(rn, same); } @@ -2886,7 +2885,6 @@ static void process_subq_early_route_add(struct zebra_early_route *ere) /* See if we can remove some RE entries that are queued for * removal, but won't be considered in rib processing. */ - dest = rib_dest_from_rnode(rn); RNODE_FOREACH_RE_SAFE (rn, re, same) { if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED)) { /* If the route was used earlier, must retain it. */