diff options
Diffstat (limited to 'bgpd/bgpd.c')
| -rw-r--r-- | bgpd/bgpd.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index d90875b78c..e3911de28a 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3404,28 +3404,12 @@ static struct bgp *bgp_create(as_t *as, const char *name, afi_t afi; safi_t safi; - if (hidden) + if (hidden) { bgp = bgp_old; - else - bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp)); - - bgp->as = *as; - - if (bgp->as_pretty) - XFREE(MTYPE_BGP_NAME, bgp->as_pretty); - if (as_pretty) - bgp->as_pretty = XSTRDUP(MTYPE_BGP_NAME, as_pretty); - else - bgp->as_pretty = XSTRDUP(MTYPE_BGP_NAME, asn_asn2asplain(*as)); - - if (asnotation != ASNOTATION_UNDEFINED) { - bgp->asnotation = asnotation; - SET_FLAG(bgp->config, BGP_CONFIG_ASNOTATION); - } else - asn_str2asn_notation(bgp->as_pretty, NULL, &bgp->asnotation); - - if (hidden) goto peer_init; + } + + bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp)); if (BGP_DEBUG(zebra, ZEBRA)) { if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) @@ -3469,6 +3453,18 @@ static struct bgp *bgp_create(as_t *as, const char *name, bgp->peer = list_new(); peer_init: + bgp->as = *as; + if (as_pretty) + bgp->as_pretty = XSTRDUP(MTYPE_BGP_NAME, as_pretty); + else + bgp->as_pretty = XSTRDUP(MTYPE_BGP_NAME, asn_asn2asplain(*as)); + + if (asnotation != ASNOTATION_UNDEFINED) { + bgp->asnotation = asnotation; + SET_FLAG(bgp->config, BGP_CONFIG_ASNOTATION); + } else + asn_str2asn_notation(bgp->as_pretty, NULL, &bgp->asnotation); + bgp->peer->cmp = (int (*)(void *, void *))peer_cmp; bgp->peerhash = hash_create(peer_hash_key_make, peer_hash_same, "BGP Peer Hash"); @@ -3565,7 +3561,7 @@ peer_init: /* printable name we can use in debug messages */ if (inst_type == BGP_INSTANCE_TYPE_DEFAULT && !hidden) { bgp->name_pretty = XSTRDUP(MTYPE_BGP_NAME, "VRF default"); - } else if (!hidden) { + } else { const char *n; int len; @@ -4261,11 +4257,12 @@ int bgp_delete(struct bgp *bgp) bgp_set_evpn(bgp_get_default()); } - if (!IS_BGP_INSTANCE_HIDDEN(bgp)) { - if (bgp->process_queue) - work_queue_free_and_null(&bgp->process_queue); + if (bgp->process_queue) + work_queue_free_and_null(&bgp->process_queue); + + if (!IS_BGP_INSTANCE_HIDDEN(bgp)) bgp_unlock(bgp); /* initial reference */ - } else { + else { for (afi = AFI_IP; afi < AFI_MAX; afi++) { enum vpn_policy_direction dir; |
