summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorAlexander Skorichenko <askorichenko@netgate.com>2025-02-01 01:52:17 +0100
committerLouis Scalbert <louis.scalbert@6wind.com>2025-02-27 09:43:56 +0100
commita634290dc1912c378bc0beb8a4ff70892788304c (patch)
tree2fa982fd6b2b4b678cb2253c392734d20854ad17 /bgpd
parente044fb747cecf979f8e2fae42b592365074c0922 (diff)
bgpd: update AS value of a hidden bgp instance
'import vrf VRF' could define a hidden bgp instance with the default AS_UNSPECIFIED (i.e. = 1) value. When a router bgp AS vrf VRF gets configured later on, replace this AS_UNSPECIFIED setting with a requested value. Fixes: 9680831518 ("bgpd: fix as_pretty mem leaks when un-hiding") Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com> (cherry picked from commit 1515a59202280933936b41c4cb2cb11c7889b279) Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgpd.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 8a3ae538dc..d90875b78c 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -3404,13 +3404,15 @@ 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 = 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
@@ -3422,6 +3424,9 @@ static struct bgp *bgp_create(as_t *as, const char *name,
} 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)
zlog_debug("Creating Default VRF, AS %s",