Commit 33d4b3014e for frr
commit 33d4b3014e4ebc62e6b8c370621e94af38152975
Author: Vic Lan <vic.lan@pica8.com>
Date: Mon Sep 14 20:30:18 2026 +0800
bgpd: use a dedicated sentinel for an unspecified instance ASN
AS_UNSPECIFIED belongs to enum peer_asn_type and has the numeric value 1.
It was incorrectly used as an as_t sentinel while auto-creating a hidden
default BGP instance for VPN-leaking configuration.
As a result, a configured local ASN of 1 was treated as unspecified by
`bgp_lookup_by_as_name_type()`, preventing hidden-instance revival from
following the normal configured-ASN path.
Just use BGP_AS_ZERO for BGP instance ASN handling and use it for the
hidden-instance check.
Signed-off-by: Vic Lan <vic.lan@pica8.com>
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 593aa5c8f0..dab4f53d6d 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -11468,9 +11468,9 @@ DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd,
bgp_default = bgp_get_default();
if (!bgp_default) {
int32_t ret;
- as_t as = AS_UNSPECIFIED;
+ as_t as = BGP_AS_ZERO;
- /* Auto-create with AS_UNSPECIFIED, to be filled in later */
+ /* Auto-create with an unspecified ASN, to be filled in later. */
ret = bgp_get_vty(&bgp_default, &as, NULL,
BGP_INSTANCE_TYPE_DEFAULT, NULL,
ASNOTATION_UNDEFINED);
@@ -11584,9 +11584,9 @@ DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd,
bgp_default = bgp_get_default();
if (!bgp_default) {
- as = AS_UNSPECIFIED;
+ as = BGP_AS_ZERO;
- /* Auto-create with AS_UNSPECIFIED, to be filled in later */
+ /* Auto-create with an unspecified ASN, to be filled in later. */
ret = bgp_get_vty(&bgp_default, &as, NULL,
BGP_INSTANCE_TYPE_DEFAULT, NULL,
ASNOTATION_UNDEFINED);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 6ca0108af0..4f2154c12d 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -4366,7 +4366,7 @@ int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as, const char *as_pr
bgp = bgp_get_default();
if (bgp) {
- if (IS_BGP_INSTANCE_HIDDEN(bgp) && *as != AS_UNSPECIFIED)
+ if (IS_BGP_INSTANCE_HIDDEN(bgp) && *as != BGP_AS_ZERO)
hidden = true;
/* Handle AS number change */
if (bgp->as != *as) {