summaryrefslogtreecommitdiffstats
path: root/bgpd/bgpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgpd.c')
-rw-r--r--bgpd/bgpd.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index c2254ae79..d5463f3d0 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -3634,13 +3634,13 @@ struct bgp *bgp_lookup(as_t as, const char *name)
}
/* Lookup BGP structure by view name. */
-struct bgp *bgp_lookup_by_name(const char *name)
+struct bgp *bgp_lookup_by_name_filter(const char *name, bool filter_auto)
{
struct bgp *bgp;
struct listnode *node, *nnode;
for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) {
- if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO))
+ if (filter_auto && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO))
continue;
if ((bgp->name == NULL && name == NULL)
|| (bgp->name && name && strcmp(bgp->name, name) == 0))
@@ -3649,6 +3649,11 @@ struct bgp *bgp_lookup_by_name(const char *name)
return NULL;
}
+struct bgp *bgp_lookup_by_name(const char *name)
+{
+ return bgp_lookup_by_name_filter(name, true);
+}
+
/* Lookup BGP instance based on VRF id. */
/* Note: Only to be used for incoming messages from Zebra. */
struct bgp *bgp_lookup_by_vrf_id(vrf_id_t vrf_id)
@@ -3734,10 +3739,9 @@ int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf, vrf_id_t old_vrf_id,
return bgp_check_main_socket(create, bgp);
}
-int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as,
- const char *as_pretty,
+int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as, const char *as_pretty,
enum asnotation_mode asnotation, const char *name,
- enum bgp_instance_type inst_type)
+ enum bgp_instance_type inst_type, bool force_config)
{
struct bgp *bgp;
struct peer *peer = NULL;
@@ -3746,7 +3750,7 @@ int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as,
/* Multiple instance check. */
if (name)
- bgp = bgp_lookup_by_name(name);
+ bgp = bgp_lookup_by_name_filter(name, !force_config);
else
bgp = bgp_get_default();
@@ -3756,7 +3760,7 @@ int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as,
/* Handle AS number change */
if (bgp->as != *as) {
if (hidden || CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) {
- if (hidden) {
+ if (force_config == false && hidden) {
bgp_create(as, name, inst_type,
as_pretty, asnotation, bgp,
hidden);
@@ -3764,7 +3768,8 @@ int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as,
BGP_FLAG_INSTANCE_HIDDEN);
} else {
bgp->as = *as;
- UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO);
+ if (force_config == false)
+ UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO);
}
/* Set all peer's local AS with this ASN */
@@ -3801,8 +3806,7 @@ int bgp_get(struct bgp **bgp_val, as_t *as, const char *name,
struct vrf *vrf = NULL;
int ret = 0;
- ret = bgp_lookup_by_as_name_type(bgp_val, as, as_pretty, asnotation,
- name, inst_type);
+ ret = bgp_lookup_by_as_name_type(bgp_val, as, as_pretty, asnotation, name, inst_type, false);
if (ret || *bgp_val)
return ret;