summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2025-02-19 08:08:58 -0500
committerGitHub <noreply@github.com>2025-02-19 08:08:58 -0500
commit211df1f6491a76a6449755a3983242e669967796 (patch)
tree042bf091702444003e394f25e46916255ef64691 /bgpd
parent9a729a2fa3262e7d9718c40e43da56e75afea29e (diff)
parent85c5598bb95aa2eb17e8f617965affa7de627c69 (diff)
Merge pull request #18162 from louis-6wind/bgp-hidden-10.3
bgpd: fix default instance when leaving the hidden state (backport 10.3)
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgpd.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index e3911de28a..d90875b78c 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -3404,12 +3404,28 @@ static struct bgp *bgp_create(as_t *as, const char *name,
afi_t afi;
safi_t safi;
- if (hidden) {
+ if (hidden)
bgp = bgp_old;
- goto peer_init;
- }
+ 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));
- bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp));
+ 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;
if (BGP_DEBUG(zebra, ZEBRA)) {
if (inst_type == BGP_INSTANCE_TYPE_DEFAULT)
@@ -3453,18 +3469,6 @@ 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");
@@ -3561,7 +3565,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 {
+ } else if (!hidden) {
const char *n;
int len;
@@ -4257,12 +4261,11 @@ int bgp_delete(struct bgp *bgp)
bgp_set_evpn(bgp_get_default());
}
- if (bgp->process_queue)
- work_queue_free_and_null(&bgp->process_queue);
-
- if (!IS_BGP_INSTANCE_HIDDEN(bgp))
+ if (!IS_BGP_INSTANCE_HIDDEN(bgp)) {
+ if (bgp->process_queue)
+ work_queue_free_and_null(&bgp->process_queue);
bgp_unlock(bgp); /* initial reference */
- else {
+ } else {
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
enum vpn_policy_direction dir;