]> git.puffer.fish Git - mirror/frr.git/commitdiff
Revert "bgpd: fix crash in bgp instance creation"
authorIgor Ryzhov <iryzhov@nfware.com>
Thu, 13 May 2021 23:12:29 +0000 (02:12 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 3 Aug 2021 20:36:31 +0000 (23:36 +0300)
This reverts commit a5ab756f2483594a19837e0c30f6184cd966940f.

bgpd/bgp_nb_config.c
bgpd/bgp_vty.c

index 218772dec50f8b7468362017eb20aab0cd1e0027..deecbfe8428906886af6335756350c2d86262805 100644 (file)
@@ -48,33 +48,6 @@ FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE,
         { .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)
 {
@@ -138,8 +111,8 @@ int bgp_router_create(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;
                }
@@ -171,9 +144,6 @@ int bgp_router_destroy(struct nb_cb_destroy_args *args)
        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);
@@ -219,42 +189,16 @@ int bgp_global_local_as_modify(struct nb_cb_modify_args *args)
 {
        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;
                }
 
index 29ca0eca0550c940d1131769fa3d451274af56bb..cfa63a292481c9b5700e5107e9a8cc54d83f5240 100644 (file)
@@ -1318,6 +1318,9 @@ DEFUN_YANG_NOSH(router_bgp,
                        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);
@@ -1332,7 +1335,6 @@ DEFUN_YANG_NOSH(router_bgp,
                                              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);