diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c index 307fa4e9bc..1939e78e73 100644 --- a/bgpd/bgp_nb_config.c +++ b/bgpd/bgp_nb_config.c @@ -109,15 +109,24 @@ int bgp_router_create(struct nb_cb_create_args *args) is_new_bgp = (bgp_lookup_by_name(name) == NULL); ret = bgp_get_vty(&bgp, &as, name, inst_type); - switch (ret) { - case BGP_ERR_AS_MISMATCH: - snprintf(args->errmsg, args->errmsg_len, - "BGP instance is already running; AS is %u", - as); - return NB_ERR_INCONSISTENCY; - case BGP_ERR_INSTANCE_MISMATCH: - snprintf(args->errmsg, args->errmsg_len, - "BGP instance type mismatch"); + if (ret) { + switch (ret) { + case BGP_ERR_AS_MISMATCH: + snprintf( + args->errmsg, args->errmsg_len, + "BGP instance is already running; AS is %u", + as); + break; + case BGP_ERR_INSTANCE_MISMATCH: + snprintf(args->errmsg, args->errmsg_len, + "BGP instance type mismatch"); + break; + } + + UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); + + nb_running_set_entry(args->dnode, bgp); + return NB_ERR_INCONSISTENCY; } diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 20bb5e5320..dcc29f4188 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3374,13 +3374,13 @@ int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as, const char *name, bgp = bgp_get_default(); if (bgp) { + *bgp_val = bgp; if (bgp->as != *as) { *as = bgp->as; return BGP_ERR_AS_MISMATCH; } if (bgp->inst_type != inst_type) return BGP_ERR_INSTANCE_MISMATCH; - *bgp_val = bgp; return BGP_SUCCESS; } *bgp_val = NULL;