Merge pull request #14811 from donaldsharp/zebra_final_shutdown_finally

Zebra final shutdown finally
This commit is contained in:
Christian Hopps 2023-11-28 20:14:42 +01:00 committed by GitHub
commit bb6fe6beb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 185 additions and 70 deletions

View file

@ -782,6 +782,7 @@ void bfdd_cli_init(void);
*/ */
void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv); void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv);
void bfdd_zclient_stop(void); void bfdd_zclient_stop(void);
void bfdd_zclient_terminate(void);
void bfdd_zclient_unregister(vrf_id_t vrf_id); void bfdd_zclient_unregister(vrf_id_t vrf_id);
void bfdd_zclient_register(vrf_id_t vrf_id); void bfdd_zclient_register(vrf_id_t vrf_id);
void bfdd_sessions_enable_vrf(struct vrf *vrf); void bfdd_sessions_enable_vrf(struct vrf *vrf);

View file

@ -75,6 +75,8 @@ static void sigterm_handler(void)
bfd_vrf_terminate(); bfd_vrf_terminate();
bfdd_zclient_terminate();
/* Terminate and free() FRR related memory. */ /* Terminate and free() FRR related memory. */
frr_fini(); frr_fini();

View file

@ -859,6 +859,11 @@ void bfdd_zclient_stop(void)
pc_free_all(); pc_free_all();
} }
void bfdd_zclient_terminate(void)
{
zclient_free(zclient);
}
/* /*
* Client handling. * Client handling.

View file

@ -6097,7 +6097,7 @@ void bgp_evpn_derive_auto_rd(struct bgp *bgp, struct bgpevpn *vpn)
snprintfrr(buf, sizeof(buf), "%pI4:%hu", &bgp->router_id, vpn->rd_id); snprintfrr(buf, sizeof(buf), "%pI4:%hu", &bgp->router_id, vpn->rd_id);
(void)str2prefix_rd(buf, &vpn->prd); (void)str2prefix_rd(buf, &vpn->prd);
if (vpn->prd_pretty) if (vpn->prd_pretty)
XFREE(MTYPE_BGP, vpn->prd_pretty); XFREE(MTYPE_BGP_NAME, vpn->prd_pretty);
UNSET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD); UNSET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD);
} }
@ -6203,7 +6203,7 @@ void bgp_evpn_free(struct bgp *bgp, struct bgpevpn *vpn)
hash_release(bgp->vni_svi_hash, vpn); hash_release(bgp->vni_svi_hash, vpn);
hash_release(bgp->vnihash, vpn); hash_release(bgp->vnihash, vpn);
if (vpn->prd_pretty) if (vpn->prd_pretty)
XFREE(MTYPE_BGP, vpn->prd_pretty); XFREE(MTYPE_BGP_NAME, vpn->prd_pretty);
QOBJ_UNREG(vpn); QOBJ_UNREG(vpn);
XFREE(MTYPE_BGP_EVPN, vpn); XFREE(MTYPE_BGP_EVPN, vpn);
} }
@ -7080,7 +7080,7 @@ void bgp_evpn_cleanup(struct bgp *bgp)
} }
if (bgp->vrf_prd_pretty) if (bgp->vrf_prd_pretty)
XFREE(MTYPE_BGP, bgp->vrf_prd_pretty); XFREE(MTYPE_BGP_NAME, bgp->vrf_prd_pretty);
} }
/* /*

View file

@ -2294,11 +2294,11 @@ static void evpn_configure_vrf_rd(struct bgp *bgp_vrf, struct prefix_rd *rd,
bgp_evpn_handle_vrf_rd_change(bgp_vrf, 1); bgp_evpn_handle_vrf_rd_change(bgp_vrf, 1);
if (bgp_vrf->vrf_prd_pretty) if (bgp_vrf->vrf_prd_pretty)
XFREE(MTYPE_BGP, bgp_vrf->vrf_prd_pretty); XFREE(MTYPE_BGP_NAME, bgp_vrf->vrf_prd_pretty);
/* update RD */ /* update RD */
memcpy(&bgp_vrf->vrf_prd, rd, sizeof(struct prefix_rd)); memcpy(&bgp_vrf->vrf_prd, rd, sizeof(struct prefix_rd));
bgp_vrf->vrf_prd_pretty = XSTRDUP(MTYPE_BGP, rd_pretty); bgp_vrf->vrf_prd_pretty = XSTRDUP(MTYPE_BGP_NAME, rd_pretty);
SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_RD_CFGD); SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_RD_CFGD);
/* We have a new RD for VRF. /* We have a new RD for VRF.
@ -2321,7 +2321,7 @@ static void evpn_unconfigure_vrf_rd(struct bgp *bgp_vrf)
bgp_evpn_derive_auto_rd_for_vrf(bgp_vrf); bgp_evpn_derive_auto_rd_for_vrf(bgp_vrf);
UNSET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_RD_CFGD); UNSET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_RD_CFGD);
if (bgp_vrf->vrf_prd_pretty) if (bgp_vrf->vrf_prd_pretty)
XFREE(MTYPE_BGP, bgp_vrf->vrf_prd_pretty); XFREE(MTYPE_BGP_NAME, bgp_vrf->vrf_prd_pretty);
/* We have a new RD for VRF. /* We have a new RD for VRF.
* Advertise all type-5 routes again with the new RD * Advertise all type-5 routes again with the new RD
*/ */
@ -2343,7 +2343,7 @@ static void evpn_configure_rd(struct bgp *bgp, struct bgpevpn *vpn,
/* update RD */ /* update RD */
memcpy(&vpn->prd, rd, sizeof(struct prefix_rd)); memcpy(&vpn->prd, rd, sizeof(struct prefix_rd));
vpn->prd_pretty = XSTRDUP(MTYPE_BGP, rd_pretty); vpn->prd_pretty = XSTRDUP(MTYPE_BGP_NAME, rd_pretty);
SET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD); SET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD);
if (is_vni_live(vpn)) if (is_vni_live(vpn))

View file

@ -1236,7 +1236,7 @@ void bgp_fsm_change_status(struct peer_connection *connection,
/* Transition into Clearing or Deleted must /always/ clear all routes.. /* Transition into Clearing or Deleted must /always/ clear all routes..
* (and must do so before actually changing into Deleted.. * (and must do so before actually changing into Deleted..
*/ */
if (status >= Clearing) { if (status >= Clearing && peer != bgp->peer_self) {
bgp_clear_route_all(peer); bgp_clear_route_all(peer);
/* If no route was queued for the clear-node processing, /* If no route was queued for the clear-node processing,

View file

@ -15,6 +15,7 @@
DEFINE_MGROUP(BGPD, "bgpd"); DEFINE_MGROUP(BGPD, "bgpd");
DEFINE_MTYPE(BGPD, BGP, "BGP instance"); DEFINE_MTYPE(BGPD, BGP, "BGP instance");
DEFINE_MTYPE(BGPD, BGP_NAME, "BGP Name data");
DEFINE_MTYPE(BGPD, BGP_LISTENER, "BGP listen socket details"); DEFINE_MTYPE(BGPD, BGP_LISTENER, "BGP listen socket details");
DEFINE_MTYPE(BGPD, BGP_PEER, "BGP peer"); DEFINE_MTYPE(BGPD, BGP_PEER, "BGP peer");
DEFINE_MTYPE(BGPD, BGP_PEER_CONNECTION, "BGP peer connection"); DEFINE_MTYPE(BGPD, BGP_PEER_CONNECTION, "BGP peer connection");

View file

@ -11,6 +11,7 @@
DECLARE_MGROUP(BGPD); DECLARE_MGROUP(BGPD);
DECLARE_MTYPE(BGP); DECLARE_MTYPE(BGP);
DECLARE_MTYPE(BGP_NAME);
DECLARE_MTYPE(BGP_LISTENER); DECLARE_MTYPE(BGP_LISTENER);
DECLARE_MTYPE(BGP_PEER); DECLARE_MTYPE(BGP_PEER);
DECLARE_MTYPE(BGP_PEER_CONNECTION); DECLARE_MTYPE(BGP_PEER_CONNECTION);

View file

@ -511,8 +511,8 @@ static int bgp_init_snmp_stats(struct bgp *bgp)
{ {
if (is_bgp_vrf_mplsvpn(bgp)) { if (is_bgp_vrf_mplsvpn(bgp)) {
if (bgp->snmp_stats == NULL) { if (bgp->snmp_stats == NULL) {
bgp->snmp_stats = XCALLOC( bgp->snmp_stats = XCALLOC(MTYPE_BGP_NAME,
MTYPE_BGP, sizeof(struct bgp_snmp_stats)); sizeof(struct bgp_snmp_stats));
/* fix up added routes */ /* fix up added routes */
if (bgp->snmp_stats) { if (bgp->snmp_stats) {
bgp->snmp_stats->routes_added = bgp->snmp_stats->routes_added =
@ -523,7 +523,7 @@ static int bgp_init_snmp_stats(struct bgp *bgp)
} }
} else { } else {
if (bgp->snmp_stats) { if (bgp->snmp_stats) {
XFREE(MTYPE_BGP, bgp->snmp_stats); XFREE(MTYPE_BGP_NAME, bgp->snmp_stats);
bgp->snmp_stats = NULL; bgp->snmp_stats = NULL;
} }
} }

View file

@ -6301,7 +6301,7 @@ static void bgp_static_free(struct bgp_static *bgp_static)
route_map_counter_decrement(bgp_static->rmap.map); route_map_counter_decrement(bgp_static->rmap.map);
if (bgp_static->prd_pretty) if (bgp_static->prd_pretty)
XFREE(MTYPE_BGP, bgp_static->prd_pretty); XFREE(MTYPE_BGP_NAME, bgp_static->prd_pretty);
XFREE(MTYPE_ATTR, bgp_static->eth_s_id); XFREE(MTYPE_ATTR, bgp_static->eth_s_id);
XFREE(MTYPE_BGP_STATIC, bgp_static); XFREE(MTYPE_BGP_STATIC, bgp_static);
} }

View file

@ -1602,8 +1602,9 @@ DEFUN_NOSH (router_bgp,
* - update asnotation if explicitly mentioned * - update asnotation if explicitly mentioned
*/ */
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) { if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) {
XFREE(MTYPE_BGP, bgp->as_pretty); XFREE(MTYPE_BGP_NAME, bgp->as_pretty);
bgp->as_pretty = XSTRDUP(MTYPE_BGP, argv[idx_asn]->arg); bgp->as_pretty = XSTRDUP(MTYPE_BGP_NAME,
argv[idx_asn]->arg);
if (!CHECK_FLAG(bgp->config, BGP_CONFIG_ASNOTATION) && if (!CHECK_FLAG(bgp->config, BGP_CONFIG_ASNOTATION) &&
asnotation != ASNOTATION_UNDEFINED) { asnotation != ASNOTATION_UNDEFINED) {
SET_FLAG(bgp->config, BGP_CONFIG_ASNOTATION); SET_FLAG(bgp->config, BGP_CONFIG_ASNOTATION);
@ -9392,13 +9393,13 @@ DEFPY (af_rd_vpn_export,
bgp_get_default(), bgp); bgp_get_default(), bgp);
if (yes) { if (yes) {
bgp->vpn_policy[afi].tovpn_rd_pretty = bgp->vpn_policy[afi].tovpn_rd_pretty = XSTRDUP(MTYPE_BGP_NAME,
XSTRDUP(MTYPE_BGP, rd_str); rd_str);
bgp->vpn_policy[afi].tovpn_rd = prd; bgp->vpn_policy[afi].tovpn_rd = prd;
SET_FLAG(bgp->vpn_policy[afi].flags, SET_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_RD_SET); BGP_VPN_POLICY_TOVPN_RD_SET);
} else { } else {
XFREE(MTYPE_BGP, bgp->vpn_policy[afi].tovpn_rd_pretty); XFREE(MTYPE_BGP_NAME, bgp->vpn_policy[afi].tovpn_rd_pretty);
UNSET_FLAG(bgp->vpn_policy[afi].flags, UNSET_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_RD_SET); BGP_VPN_POLICY_TOVPN_RD_SET);
} }

View file

@ -576,8 +576,8 @@ void bgp_confederation_id_set(struct bgp *bgp, as_t as, const char *as_str)
already_confed = bgp_config_check(bgp, BGP_CONFIG_CONFEDERATION); already_confed = bgp_config_check(bgp, BGP_CONFIG_CONFEDERATION);
bgp->confed_id = as; bgp->confed_id = as;
if (bgp->confed_id_pretty) if (bgp->confed_id_pretty)
XFREE(MTYPE_BGP, bgp->confed_id_pretty); XFREE(MTYPE_BGP_NAME, bgp->confed_id_pretty);
bgp->confed_id_pretty = XSTRDUP(MTYPE_BGP, as_str); bgp->confed_id_pretty = XSTRDUP(MTYPE_BGP_NAME, as_str);
bgp_config_set(bgp, BGP_CONFIG_CONFEDERATION); bgp_config_set(bgp, BGP_CONFIG_CONFEDERATION);
/* If we were doing confederation already, this is just an external /* If we were doing confederation already, this is just an external
@ -630,7 +630,7 @@ void bgp_confederation_id_unset(struct bgp *bgp)
struct listnode *node, *nnode; struct listnode *node, *nnode;
bgp->confed_id = 0; bgp->confed_id = 0;
XFREE(MTYPE_BGP, bgp->confed_id_pretty); XFREE(MTYPE_BGP_NAME, bgp->confed_id_pretty);
bgp_config_unset(bgp, BGP_CONFIG_CONFEDERATION); bgp_config_unset(bgp, BGP_CONFIG_CONFEDERATION);
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
@ -684,7 +684,7 @@ void bgp_confederation_peers_add(struct bgp *bgp, as_t as, const char *as_str)
bgp->confed_peers[bgp->confed_peers_cnt].as = as; bgp->confed_peers[bgp->confed_peers_cnt].as = as;
bgp->confed_peers[bgp->confed_peers_cnt].as_pretty = bgp->confed_peers[bgp->confed_peers_cnt].as_pretty =
XSTRDUP(MTYPE_BGP, as_str); XSTRDUP(MTYPE_BGP_NAME, as_str);
bgp->confed_peers_cnt++; bgp->confed_peers_cnt++;
if (bgp_config_check(bgp, BGP_CONFIG_CONFEDERATION)) { if (bgp_config_check(bgp, BGP_CONFIG_CONFEDERATION)) {
@ -722,7 +722,7 @@ void bgp_confederation_peers_remove(struct bgp *bgp, as_t as)
for (i = 0; i < bgp->confed_peers_cnt; i++) for (i = 0; i < bgp->confed_peers_cnt; i++)
if (bgp->confed_peers[i].as == as) { if (bgp->confed_peers[i].as == as) {
XFREE(MTYPE_BGP, bgp->confed_peers[i].as_pretty); XFREE(MTYPE_BGP_NAME, bgp->confed_peers[i].as_pretty);
for (j = i + 1; j < bgp->confed_peers_cnt; j++) { for (j = i + 1; j < bgp->confed_peers_cnt; j++) {
bgp->confed_peers[j - 1].as = bgp->confed_peers[j - 1].as =
bgp->confed_peers[j].as; bgp->confed_peers[j].as;
@ -1265,9 +1265,9 @@ static void peer_free(struct peer *peer)
bgp_addpath_set_peer_type(peer, afi, safi, BGP_ADDPATH_NONE, 0); bgp_addpath_set_peer_type(peer, afi, safi, BGP_ADDPATH_NONE, 0);
if (peer->change_local_as_pretty) if (peer->change_local_as_pretty)
XFREE(MTYPE_BGP, peer->change_local_as_pretty); XFREE(MTYPE_BGP_NAME, peer->change_local_as_pretty);
if (peer->as_pretty) if (peer->as_pretty)
XFREE(MTYPE_BGP, peer->as_pretty); XFREE(MTYPE_BGP_NAME, peer->as_pretty);
bgp_peer_connection_free(&peer->connection); bgp_peer_connection_free(&peer->connection);
@ -1861,7 +1861,7 @@ struct peer *peer_create(union sockunion *su, const char *conf_if,
peer->as = remote_as; peer->as = remote_as;
/* internal and external values do not use as_pretty */ /* internal and external values do not use as_pretty */
if (as_str && asn_str2asn(as_str, NULL)) if (as_str && asn_str2asn(as_str, NULL))
peer->as_pretty = XSTRDUP(MTYPE_BGP, as_str); peer->as_pretty = XSTRDUP(MTYPE_BGP_NAME, as_str);
peer->as_type = as_type; peer->as_type = as_type;
peer->local_id = bgp->router_id; peer->local_id = bgp->router_id;
peer->v_holdtime = bgp->default_holdtime; peer->v_holdtime = bgp->default_holdtime;
@ -1986,10 +1986,10 @@ void peer_as_change(struct peer *peer, as_t as, int as_specified,
peer->as = as; peer->as = as;
if (as_specified == AS_SPECIFIED && as_str) { if (as_specified == AS_SPECIFIED && as_str) {
if (peer->as_pretty) if (peer->as_pretty)
XFREE(MTYPE_BGP, peer->as_pretty); XFREE(MTYPE_BGP_NAME, peer->as_pretty);
peer->as_pretty = XSTRDUP(MTYPE_BGP, as_str); peer->as_pretty = XSTRDUP(MTYPE_BGP_NAME, as_str);
} else if (peer->as_type == AS_UNSPECIFIED && peer->as_pretty) } else if (peer->as_type == AS_UNSPECIFIED && peer->as_pretty)
XFREE(MTYPE_BGP, peer->as_pretty); XFREE(MTYPE_BGP_NAME, peer->as_pretty);
peer->as_type = as_specified; peer->as_type = as_specified;
if (bgp_config_check(peer->bgp, BGP_CONFIG_CONFEDERATION) if (bgp_config_check(peer->bgp, BGP_CONFIG_CONFEDERATION)
@ -3289,9 +3289,9 @@ static struct bgp *bgp_create(as_t *as, const char *name,
bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp)); bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp));
bgp->as = *as; bgp->as = *as;
if (as_pretty) if (as_pretty)
bgp->as_pretty = XSTRDUP(MTYPE_BGP, as_pretty); bgp->as_pretty = XSTRDUP(MTYPE_BGP_NAME, as_pretty);
else else
bgp->as_pretty = XSTRDUP(MTYPE_BGP, asn_asn2asplain(*as)); bgp->as_pretty = XSTRDUP(MTYPE_BGP_NAME, asn_asn2asplain(*as));
if (asnotation != ASNOTATION_UNDEFINED) { if (asnotation != ASNOTATION_UNDEFINED) {
bgp->asnotation = asnotation; bgp->asnotation = asnotation;
@ -3420,14 +3420,14 @@ static struct bgp *bgp_create(as_t *as, const char *name,
bgp_mplsvpn_nh_label_bind_cache_init(&bgp->mplsvpn_nh_label_bind); bgp_mplsvpn_nh_label_bind_cache_init(&bgp->mplsvpn_nh_label_bind);
if (name) if (name)
bgp->name = XSTRDUP(MTYPE_BGP, name); bgp->name = XSTRDUP(MTYPE_BGP_NAME, name);
event_add_timer(bm->master, bgp_startup_timer_expire, bgp, event_add_timer(bm->master, bgp_startup_timer_expire, bgp,
bgp->restart_time, &bgp->t_startup); bgp->restart_time, &bgp->t_startup);
/* printable name we can use in debug messages */ /* printable name we can use in debug messages */
if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) { if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) {
bgp->name_pretty = XSTRDUP(MTYPE_BGP, "VRF default"); bgp->name_pretty = XSTRDUP(MTYPE_BGP_NAME, "VRF default");
} else { } else {
const char *n; const char *n;
int len; int len;
@ -3439,7 +3439,7 @@ static struct bgp *bgp_create(as_t *as, const char *name,
len = 4 + 1 + strlen(n) + 1; /* "view foo\0" */ len = 4 + 1 + strlen(n) + 1; /* "view foo\0" */
bgp->name_pretty = XCALLOC(MTYPE_BGP, len); bgp->name_pretty = XCALLOC(MTYPE_BGP_NAME, len);
snprintf(bgp->name_pretty, len, "%s %s", snprintf(bgp->name_pretty, len, "%s %s",
(bgp->inst_type == BGP_INSTANCE_TYPE_VRF) (bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
? "VRF" ? "VRF"
@ -4042,7 +4042,8 @@ void bgp_free(struct bgp *bgp)
if (bgp->vpn_policy[afi].rtlist[dir]) if (bgp->vpn_policy[afi].rtlist[dir])
ecommunity_free(&bgp->vpn_policy[afi].rtlist[dir]); ecommunity_free(&bgp->vpn_policy[afi].rtlist[dir]);
if (bgp->vpn_policy[afi].tovpn_rd_pretty) if (bgp->vpn_policy[afi].tovpn_rd_pretty)
XFREE(MTYPE_BGP, bgp->vpn_policy[afi].tovpn_rd_pretty); XFREE(MTYPE_BGP_NAME,
bgp->vpn_policy[afi].tovpn_rd_pretty);
if (bgp->vpn_policy[afi].tovpn_sid_locator != NULL) if (bgp->vpn_policy[afi].tovpn_sid_locator != NULL)
srv6_locator_chunk_free( srv6_locator_chunk_free(
&bgp->vpn_policy[afi].tovpn_sid_locator); &bgp->vpn_policy[afi].tovpn_sid_locator);
@ -4059,10 +4060,10 @@ void bgp_free(struct bgp *bgp)
bgp_srv6_cleanup(bgp); bgp_srv6_cleanup(bgp);
bgp_confederation_id_unset(bgp); bgp_confederation_id_unset(bgp);
XFREE(MTYPE_BGP, bgp->as_pretty); XFREE(MTYPE_BGP_NAME, bgp->as_pretty);
XFREE(MTYPE_BGP, bgp->name); XFREE(MTYPE_BGP_NAME, bgp->name);
XFREE(MTYPE_BGP, bgp->name_pretty); XFREE(MTYPE_BGP_NAME, bgp->name_pretty);
XFREE(MTYPE_BGP, bgp->snmp_stats); XFREE(MTYPE_BGP_NAME, bgp->snmp_stats);
XFREE(MTYPE_BGP, bgp); XFREE(MTYPE_BGP, bgp);
} }
@ -6464,8 +6465,8 @@ int peer_local_as_set(struct peer *peer, as_t as, bool no_prepend,
peer->change_local_as = as; peer->change_local_as = as;
if (as_str) { if (as_str) {
if (peer->change_local_as_pretty) if (peer->change_local_as_pretty)
XFREE(MTYPE_BGP, peer->change_local_as_pretty); XFREE(MTYPE_BGP_NAME, peer->change_local_as_pretty);
peer->change_local_as_pretty = XSTRDUP(MTYPE_BGP, as_str); peer->change_local_as_pretty = XSTRDUP(MTYPE_BGP_NAME, as_str);
} }
(void)peer_sort(peer); (void)peer_sort(peer);
@ -6502,8 +6503,8 @@ int peer_local_as_set(struct peer *peer, as_t as, bool no_prepend,
replace_as); replace_as);
member->change_local_as = as; member->change_local_as = as;
if (as_str) if (as_str)
member->change_local_as_pretty = member->change_local_as_pretty = XSTRDUP(MTYPE_BGP_NAME,
XSTRDUP(MTYPE_BGP, as_str); as_str);
} }
return 0; return 0;
@ -6529,7 +6530,7 @@ int peer_local_as_unset(struct peer *peer)
peer_flag_unset(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND); peer_flag_unset(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND);
peer_flag_unset(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS); peer_flag_unset(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS);
peer->change_local_as = 0; peer->change_local_as = 0;
XFREE(MTYPE_BGP, peer->change_local_as_pretty); XFREE(MTYPE_BGP_NAME, peer->change_local_as_pretty);
} }
/* Check if handling a regular peer. */ /* Check if handling a regular peer. */
@ -6560,7 +6561,7 @@ int peer_local_as_unset(struct peer *peer)
UNSET_FLAG(member->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); UNSET_FLAG(member->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
UNSET_FLAG(member->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS); UNSET_FLAG(member->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS);
member->change_local_as = 0; member->change_local_as = 0;
XFREE(MTYPE_BGP, member->change_local_as_pretty); XFREE(MTYPE_BGP_NAME, member->change_local_as_pretty);
/* Send notification or stop peer depending on state. */ /* Send notification or stop peer depending on state. */
if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status)) { if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status)) {

View file

@ -96,6 +96,8 @@ static void sigint(void)
zlog_notice("Terminating on signal"); zlog_notice("Terminating on signal");
eigrp_terminate(); eigrp_terminate();
keychain_terminate();
exit(0); exit(0);
} }

View file

@ -1187,6 +1187,20 @@ static const struct cmd_variable_handler keychain_var_handlers[] = {
{.completions = NULL} {.completions = NULL}
}; };
void keychain_terminate(void)
{
struct keychain *keychain;
while (listcount(keychain_list)) {
keychain = listgetdata(listhead(keychain_list));
listnode_delete(keychain_list, keychain);
keychain_delete(keychain);
}
list_delete(&keychain_list);
}
void keychain_init(void) void keychain_init(void)
{ {
keychain_list = list_new(); keychain_list = list_new();

View file

@ -82,6 +82,7 @@ struct key {
DECLARE_QOBJ_TYPE(key); DECLARE_QOBJ_TYPE(key);
extern void keychain_init(void); extern void keychain_init(void);
extern void keychain_terminate(void);
extern struct keychain *keychain_lookup(const char *); extern struct keychain *keychain_lookup(const char *);
extern struct key *key_lookup_for_accept(const struct keychain *, uint32_t); extern struct key *key_lookup_for_accept(const struct keychain *, uint32_t);
extern struct key *key_match_for_accept(const struct keychain *, const char *); extern struct key *key_match_for_accept(const struct keychain *, const char *);

View file

@ -104,7 +104,10 @@ static void __attribute__((noreturn)) ospf6_exit(int status)
} }
ospf6_master_delete(); ospf6_master_delete();
frr_fini(); frr_fini();
keychain_terminate();
exit(status); exit(status);
} }

View file

@ -680,6 +680,8 @@ void ospf_terminate(void)
ospf_vrf_terminate(); ospf_vrf_terminate();
route_map_finish(); route_map_finish();
keychain_terminate();
/* Deliberately go back up, hopefully to thread scheduler, as /* Deliberately go back up, hopefully to thread scheduler, as
* One or more ospf_finish()'s may have deferred shutdown to a timer * One or more ospf_finish()'s may have deferred shutdown to a timer
* thread * thread

View file

@ -85,6 +85,8 @@ static void sigint(void)
rip_zclient_stop(); rip_zclient_stop();
route_map_finish(); route_map_finish();
keychain_terminate();
frr_fini(); frr_fini();
exit(0); exit(0);

View file

@ -196,6 +196,7 @@ static void sigint(void)
rib_update_finish(); rib_update_finish();
list_delete(&zrouter.client_list); list_delete(&zrouter.client_list);
list_delete(&zrouter.stale_client_list);
/* Indicate that all new dplane work has been enqueued. When that /* Indicate that all new dplane work has been enqueued. When that
* work is complete, the dataplane will enqueue an event * work is complete, the dataplane will enqueue an event
@ -228,8 +229,11 @@ void zebra_finalize(struct event *dummy)
/* Final shutdown of ns resources */ /* Final shutdown of ns resources */
ns_walk_func(zebra_ns_final_shutdown, NULL, NULL); ns_walk_func(zebra_ns_final_shutdown, NULL, NULL);
zebra_rib_terminate();
zebra_router_terminate(); zebra_router_terminate();
zebra_mpls_terminate();
ns_terminate(); ns_terminate();
frr_fini(); frr_fini();
exit(0); exit(0);
@ -410,7 +414,7 @@ int main(int argc, char **argv)
/* Zebra related initialize. */ /* Zebra related initialize. */
zebra_router_init(asic_offload, notify_on_ack, v6_with_v4_nexthop); zebra_router_init(asic_offload, notify_on_ack, v6_with_v4_nexthop);
zserv_init(); zserv_init();
rib_init(); zebra_rib_init();
zebra_if_init(); zebra_if_init();
zebra_debug_init(); zebra_debug_init();

View file

@ -414,7 +414,8 @@ extern void rib_update_table(struct route_table *table,
extern void rib_sweep_route(struct event *t); extern void rib_sweep_route(struct event *t);
extern void rib_sweep_table(struct route_table *table); extern void rib_sweep_table(struct route_table *table);
extern void rib_close_table(struct route_table *table); extern void rib_close_table(struct route_table *table);
extern void rib_init(void); extern void zebra_rib_init(void);
extern void zebra_rib_terminate(void);
extern unsigned long rib_score_proto(uint8_t proto, unsigned short instance); extern unsigned long rib_score_proto(uint8_t proto, unsigned short instance);
extern unsigned long rib_score_proto_table(uint8_t proto, extern unsigned long rib_score_proto_table(uint8_t proto,
unsigned short instance, unsigned short instance,

View file

@ -6860,6 +6860,31 @@ static int kernel_dplane_process_func(struct zebra_dplane_provider *prov)
return 0; return 0;
} }
static int kernel_dplane_shutdown_func(struct zebra_dplane_provider *prov,
bool early)
{
struct zebra_dplane_ctx *ctx;
if (early)
return 1;
ctx = dplane_provider_dequeue_in_ctx(prov);
while (ctx) {
dplane_ctx_free(&ctx);
ctx = dplane_provider_dequeue_in_ctx(prov);
}
ctx = dplane_provider_dequeue_out_ctx(prov);
while (ctx) {
dplane_ctx_free(&ctx);
ctx = dplane_provider_dequeue_out_ctx(prov);
}
return 1;
}
#ifdef DPLANE_TEST_PROVIDER #ifdef DPLANE_TEST_PROVIDER
/* /*
@ -6932,12 +6957,10 @@ static void dplane_provider_init(void)
{ {
int ret; int ret;
ret = dplane_provider_register("Kernel", ret = dplane_provider_register("Kernel", DPLANE_PRIO_KERNEL,
DPLANE_PRIO_KERNEL,
DPLANE_PROV_FLAGS_DEFAULT, NULL, DPLANE_PROV_FLAGS_DEFAULT, NULL,
kernel_dplane_process_func, kernel_dplane_process_func,
NULL, kernel_dplane_shutdown_func, NULL, NULL);
NULL, NULL);
if (ret != AOK) if (ret != AOK)
zlog_err("Unable to register kernel dplane provider: %d", zlog_err("Unable to register kernel dplane provider: %d",
@ -7338,6 +7361,7 @@ static void dplane_thread_loop(struct event *event)
void zebra_dplane_shutdown(void) void zebra_dplane_shutdown(void)
{ {
struct zebra_dplane_provider *dp; struct zebra_dplane_provider *dp;
struct zebra_dplane_ctx *ctx;
if (IS_ZEBRA_DEBUG_DPLANE) if (IS_ZEBRA_DEBUG_DPLANE)
zlog_debug("Zebra dataplane shutdown called"); zlog_debug("Zebra dataplane shutdown called");
@ -7365,8 +7389,25 @@ void zebra_dplane_shutdown(void)
} }
/* TODO -- Clean-up provider objects */ /* TODO -- Clean-up provider objects */
dp = dplane_prov_list_first(&zdplane_info.dg_providers);
while (dp) {
dplane_prov_list_del(&zdplane_info.dg_providers, dp);
XFREE(MTYPE_DP_PROV, dp);
dp = dplane_prov_list_first(&zdplane_info.dg_providers);
}
/* TODO -- Clean queue(s), free memory */ /* TODO -- Clean queue(s), free memory */
DPLANE_LOCK();
{
ctx = dplane_ctx_list_pop(&zdplane_info.dg_update_list);
while (ctx) {
dplane_ctx_free(&ctx);
ctx = dplane_ctx_list_pop(&zdplane_info.dg_update_list);
}
}
DPLANE_UNLOCK();
} }
/* /*

View file

@ -4034,10 +4034,12 @@ void zebra_mpls_turned_on(void)
if (!mpls_enabled) { if (!mpls_enabled) {
mpls_processq_init(); mpls_processq_init();
mpls_enabled = true; mpls_enabled = true;
}
hook_register(zserv_client_close, zebra_mpls_cleanup_fecs_for_client); hook_register(zserv_client_close,
hook_register(zserv_client_close, zebra_mpls_cleanup_zclient_labels); zebra_mpls_cleanup_fecs_for_client);
hook_register(zserv_client_close,
zebra_mpls_cleanup_zclient_labels);
}
} }
/* /*
@ -4056,3 +4058,9 @@ void zebra_mpls_init(void)
zebra_mpls_turned_on(); zebra_mpls_turned_on();
} }
void zebra_mpls_terminate(void)
{
hook_unregister(zserv_client_close, zebra_mpls_cleanup_fecs_for_client);
hook_unregister(zserv_client_close, zebra_mpls_cleanup_zclient_labels);
}

View file

@ -400,9 +400,10 @@ void zebra_mpls_init_tables(struct zebra_vrf *zvrf);
void zebra_mpls_turned_on(void); void zebra_mpls_turned_on(void);
/* /*
* Global MPLS initialization. * Global MPLS initialization/termination.
*/ */
void zebra_mpls_init(void); void zebra_mpls_init(void);
void zebra_mpls_terminate(void);
/* /*
* MPLS VTY. * MPLS VTY.

View file

@ -42,11 +42,6 @@ struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id)
return (info == NULL) ? dzns : info; return (info == NULL) ? dzns : info;
} }
static struct zebra_ns *zebra_ns_alloc(void)
{
return XCALLOC(MTYPE_ZEBRA_NS, sizeof(struct zebra_ns));
}
static int zebra_ns_new(struct ns *ns) static int zebra_ns_new(struct ns *ns)
{ {
struct zebra_ns *zns; struct zebra_ns *zns;
@ -57,7 +52,7 @@ static int zebra_ns_new(struct ns *ns)
if (IS_ZEBRA_DEBUG_EVENT) if (IS_ZEBRA_DEBUG_EVENT)
zlog_info("ZNS %s with id %u (created)", ns->name, ns->ns_id); zlog_info("ZNS %s with id %u (created)", ns->name, ns->ns_id);
zns = zebra_ns_alloc(); zns = XCALLOC(MTYPE_ZEBRA_NS, sizeof(struct zebra_ns));
ns->info = zns; ns->info = zns;
zns->ns = ns; zns->ns = ns;
zns->ns_id = ns->ns_id; zns->ns_id = ns->ns_id;
@ -194,6 +189,8 @@ int zebra_ns_final_shutdown(struct ns *ns,
kernel_terminate(zns, true); kernel_terminate(zns, true);
zebra_ns_delete(ns);
return NS_WALK_CONTINUE; return NS_WALK_CONTINUE;
} }

View file

@ -4926,7 +4926,7 @@ static void check_route_info(void)
} }
/* Routing information base initialize. */ /* Routing information base initialize. */
void rib_init(void) void zebra_rib_init(void)
{ {
check_route_info(); check_route_info();
@ -4938,6 +4938,20 @@ void rib_init(void)
zebra_dplane_init(rib_dplane_results); zebra_dplane_init(rib_dplane_results);
} }
void zebra_rib_terminate(void)
{
struct zebra_dplane_ctx *ctx;
EVENT_OFF(t_dplane);
ctx = dplane_ctx_dequeue(&rib_dplane_q);
while (ctx) {
dplane_ctx_fini(&ctx);
ctx = dplane_ctx_dequeue(&rib_dplane_q);
}
}
/* /*
* vrf_id_get_next * vrf_id_get_next
* *

View file

@ -241,11 +241,15 @@ void zebra_router_terminate(void)
zebra_pbr_ipset_entry_free); zebra_pbr_ipset_entry_free);
hash_clean_and_free(&zrouter.ipset_hash, zebra_pbr_ipset_free); hash_clean_and_free(&zrouter.ipset_hash, zebra_pbr_ipset_free);
hash_clean_and_free(&zrouter.iptable_hash, zebra_pbr_iptable_free); hash_clean_and_free(&zrouter.iptable_hash, zebra_pbr_iptable_free);
hash_clean_and_free(&zrouter.filter_hash, NULL);
hash_clean_and_free(&zrouter.qdisc_hash, NULL);
hash_clean_and_free(&zrouter.class_hash, NULL);
#ifdef HAVE_SCRIPTING #ifdef HAVE_SCRIPTING
zebra_script_destroy(); zebra_script_destroy();
#endif #endif
zebra_vxlan_terminate();
/* OS-specific deinit */ /* OS-specific deinit */
kernel_router_terminate(); kernel_router_terminate();
} }
@ -295,10 +299,6 @@ void zebra_router_init(bool asic_offload, bool notify_on_ack,
hash_create_size(8, zebra_nhg_id_key, zebra_nhg_hash_id_equal, hash_create_size(8, zebra_nhg_id_key, zebra_nhg_hash_id_equal,
"Zebra Router Nexthop Groups ID index"); "Zebra Router Nexthop Groups ID index");
zrouter.rules_hash =
hash_create_size(8, zebra_pbr_rules_hash_key,
zebra_pbr_rules_hash_equal, "Rules Hash");
zrouter.qdisc_hash = zrouter.qdisc_hash =
hash_create_size(8, zebra_tc_qdisc_hash_key, hash_create_size(8, zebra_tc_qdisc_hash_key,
zebra_tc_qdisc_hash_equal, "TC (qdisc) Hash"); zebra_tc_qdisc_hash_equal, "TC (qdisc) Hash");

View file

@ -82,7 +82,7 @@ static int zl3vni_nh_uninstall(struct zebra_l3vni *zl3vni,
struct zebra_neigh *n); struct zebra_neigh *n);
static struct zebra_neigh *svd_nh_add(const struct ipaddr *vtep_ip, static struct zebra_neigh *svd_nh_add(const struct ipaddr *vtep_ip,
const struct ethaddr *rmac); const struct ethaddr *rmac);
static int svd_nh_del(struct zebra_neigh *n); static void svd_nh_del(struct zebra_neigh *n);
static int svd_nh_install(struct zebra_l3vni *zl3vni, struct zebra_neigh *n); static int svd_nh_install(struct zebra_l3vni *zl3vni, struct zebra_neigh *n);
static int svd_nh_uninstall(struct zebra_l3vni *zl3vni, struct zebra_neigh *n); static int svd_nh_uninstall(struct zebra_l3vni *zl3vni, struct zebra_neigh *n);
@ -1590,17 +1590,24 @@ static struct zebra_neigh *svd_nh_add(const struct ipaddr *ip,
/* /*
* Del Single VXlan Device neighbor entry. * Del Single VXlan Device neighbor entry.
*/ */
static int svd_nh_del(struct zebra_neigh *n) static void svd_nh_del(struct zebra_neigh *n)
{ {
if (n->refcnt > 0) if (n->refcnt > 0)
return -1; return;
hash_release(svd_nh_table, n); hash_release(svd_nh_table, n);
XFREE(MTYPE_L3NEIGH, n); XFREE(MTYPE_L3NEIGH, n);
return 0;
} }
static void svd_nh_del_terminate(void *ptr)
{
struct zebra_neigh *n = ptr;
n->refcnt = 0;
svd_nh_del(n);
}
/* /*
* Common code to install remote nh as neigh into the kernel. * Common code to install remote nh as neigh into the kernel.
*/ */
@ -5813,6 +5820,11 @@ void zebra_vxlan_init(void)
zebra_evpn_mh_init(); zebra_evpn_mh_init();
} }
void zebra_vxlan_terminate(void)
{
hash_clean_and_free(&svd_nh_table, svd_nh_del_terminate);
}
/* free l3vni table */ /* free l3vni table */
void zebra_vxlan_disable(void) void zebra_vxlan_disable(void)
{ {

View file

@ -185,6 +185,7 @@ extern void zebra_vxlan_init_tables(struct zebra_vrf *zvrf);
extern void zebra_vxlan_close_tables(struct zebra_vrf *); extern void zebra_vxlan_close_tables(struct zebra_vrf *);
extern void zebra_vxlan_cleanup_tables(struct zebra_vrf *); extern void zebra_vxlan_cleanup_tables(struct zebra_vrf *);
extern void zebra_vxlan_init(void); extern void zebra_vxlan_init(void);
extern void zebra_vxlan_terminate(void);
extern void zebra_vxlan_disable(void); extern void zebra_vxlan_disable(void);
extern void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, extern void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id,
const struct ethaddr *rmac, const struct ethaddr *rmac,