mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 02:53:55 +00:00
bgpd: fix crash when as/type mismatches in config
When we're trying to create the config for already existing router and the AS number or instance type mismatches, we're returning the inconsistency error and don't set the NB entry. Any subsequent command that configures this router will crash because every command relies on the existence of the NB entry. Let's store the entry even when there's a mismatch to prevent the crash. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
d8c3daca19
commit
0d6d0208a5
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user