mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 14:17:20 +00:00
Revert "bgpd: simplify bgp_global_local_as_modify code"
This reverts commit debb7b1931
.
This commit is contained in:
parent
cfb37710bc
commit
30aaf9820d
@ -258,26 +258,64 @@ int bgp_router_destroy(struct nb_cb_destroy_args *args)
|
|||||||
int bgp_global_local_as_modify(struct nb_cb_modify_args *args)
|
int bgp_global_local_as_modify(struct nb_cb_modify_args *args)
|
||||||
{
|
{
|
||||||
struct bgp *bgp;
|
struct bgp *bgp;
|
||||||
|
as_t as;
|
||||||
|
const struct lyd_node *vrf_dnode;
|
||||||
|
const char *vrf_name;
|
||||||
|
const char *name = NULL;
|
||||||
|
enum bgp_instance_type inst_type;
|
||||||
|
int ret;
|
||||||
|
bool is_view_inst = false;
|
||||||
|
|
||||||
switch (args->event) {
|
switch (args->event) {
|
||||||
case NB_EV_VALIDATE:
|
case NB_EV_VALIDATE:
|
||||||
/*
|
as = yang_dnode_get_uint32(args->dnode, NULL);
|
||||||
* Changing AS number is not allowed, but we must allow it
|
|
||||||
* once, when the BGP instance is created the first time.
|
inst_type = BGP_INSTANCE_TYPE_DEFAULT;
|
||||||
* If the instance already exists - return the validation
|
|
||||||
* error.
|
vrf_dnode = yang_dnode_get_parent(args->dnode,
|
||||||
*/
|
"control-plane-protocol");
|
||||||
bgp = nb_running_get_entry_non_rec(
|
vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf");
|
||||||
lyd_parent(lyd_parent(args->dnode)), NULL, false);
|
|
||||||
if (bgp) {
|
if (strmatch(vrf_name, VRF_DEFAULT_NAME)) {
|
||||||
|
name = NULL;
|
||||||
|
} else {
|
||||||
|
name = vrf_name;
|
||||||
|
inst_type = BGP_INSTANCE_TYPE_VRF;
|
||||||
|
}
|
||||||
|
|
||||||
|
is_view_inst = yang_dnode_get_bool(args->dnode,
|
||||||
|
"../instance-type-view");
|
||||||
|
if (is_view_inst)
|
||||||
|
inst_type = BGP_INSTANCE_TYPE_VIEW;
|
||||||
|
|
||||||
|
ret = bgp_lookup_by_as_name_type(&bgp, &as, name, inst_type);
|
||||||
|
switch (ret) {
|
||||||
|
case BGP_ERR_AS_MISMATCH:
|
||||||
snprintf(args->errmsg, args->errmsg_len,
|
snprintf(args->errmsg, args->errmsg_len,
|
||||||
"Changing AS number is not allowed");
|
"BGP instance is already running; AS is %u",
|
||||||
|
as);
|
||||||
|
return NB_ERR_VALIDATION;
|
||||||
|
case BGP_ERR_INSTANCE_MISMATCH:
|
||||||
|
snprintf(args->errmsg, args->errmsg_len,
|
||||||
|
"BGP instance type mismatch");
|
||||||
return NB_ERR_VALIDATION;
|
return NB_ERR_VALIDATION;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NB_EV_PREPARE:
|
case NB_EV_PREPARE:
|
||||||
case NB_EV_ABORT:
|
case NB_EV_ABORT:
|
||||||
|
return NB_OK;
|
||||||
case NB_EV_APPLY:
|
case NB_EV_APPLY:
|
||||||
|
/* NOTE: handled in bgp_global_create callback, the as change
|
||||||
|
* will be rejected in validate phase.
|
||||||
|
*/
|
||||||
|
as = yang_dnode_get_uint32(args->dnode, NULL);
|
||||||
|
bgp = nb_running_get_entry(args->dnode, NULL, true);
|
||||||
|
if (bgp->as != as) {
|
||||||
|
snprintf(args->errmsg, args->errmsg_len,
|
||||||
|
"BGP instance is already running; AS is %u",
|
||||||
|
bgp->as);
|
||||||
|
return NB_ERR_INCONSISTENCY;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user