{ .val_ulong = 60 },
);
-
-static int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as,
- const char *name,
- enum bgp_instance_type inst_type)
-{
- struct bgp *bgp;
-
- if (name)
- bgp = bgp_lookup_by_name(name);
- else
- bgp = bgp_get_default();
-
- if (bgp) {
- if (bgp->as != *as) {
- *as = bgp->as;
- return BGP_ERR_INSTANCE_MISMATCH;
- }
- if (bgp->inst_type != inst_type)
- return BGP_ERR_INSTANCE_MISMATCH;
- *bgp_val = bgp;
- } else {
- *bgp_val = NULL;
- }
-
- return BGP_SUCCESS;
-}
-
int routing_control_plane_protocols_name_validate(
struct nb_cb_create_args *args)
{
if (ret == BGP_ERR_INSTANCE_MISMATCH) {
snprintf(
args->errmsg, args->errmsg_len,
- "BGP instance name and AS number mismatch\nBGP instance is already running; AS is %u, input-as %u",
- bgp->as, as);
+ "BGP instance name and AS number mismatch\nBGP instance is already running; AS is %u",
+ as);
return NB_ERR_INCONSISTENCY;
}
case NB_EV_VALIDATE:
bgp = nb_running_get_entry(args->dnode, NULL, false);
- if (!bgp)
- return NB_OK;
-
if (bgp->l3vni) {
snprintf(args->errmsg, args->errmsg_len,
"Please unconfigure l3vni %u", bgp->l3vni);
{
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) {
case NB_EV_VALIDATE:
as = yang_dnode_get_uint32(args->dnode, NULL);
- inst_type = BGP_INSTANCE_TYPE_DEFAULT;
-
- vrf_dnode = yang_dnode_get_parent(args->dnode,
- "control-plane-protocol");
- vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf");
-
- 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);
- if (ret == BGP_ERR_INSTANCE_MISMATCH) {
- snprintf(
- args->errmsg, args->errmsg_len,
- "BGP instance name and AS number mismatch\nBGP instance is already running; input-as %u",
- as);
-
+ bgp = nb_running_get_entry_non_rec(args->dnode, NULL, false);
+ if (bgp && bgp->as != as) {
+ snprintf(args->errmsg, args->errmsg_len,
+ "BGP instance is already running; AS is %u",
+ bgp->as);
return NB_ERR_VALIDATION;
}
vty_out(vty, "%% Please specify ASN and VRF\n");
return CMD_WARNING_CONFIG_FAILED;
}
+ /* unset the auto created flag as the user config is now present
+ */
+ UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO);
snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH,
"frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME);
NB_OP_MODIFY, "true");
}
- nb_cli_pending_commit_check(vty);
ret = nb_cli_apply_changes(vty, base_xpath);
if (ret == CMD_SUCCESS) {
VTY_PUSH_XPATH(BGP_NODE, base_xpath);