]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: move router bgp nb callback
authorChirag Shah <chirag@nvidia.com>
Sun, 20 Sep 2020 15:13:53 +0000 (08:13 -0700)
committerChirag Shah <chirag@nvidia.com>
Sat, 3 Oct 2020 18:25:38 +0000 (11:25 -0700)
move `router bgp` nb callback at `bgp` node level
to have access to bgp context at neighbor and peer-group
level and align create/destroy callbacks call during
no router bgp.

Earlier `no router bgp` is performed first global destroy
callback is called which essentially removes `bgp context`
then it calls to remove (parallel nodes) neighbor and peer-group
which does not have access to bgp context.
Moving router bgp at bgp solves this destroy callback ordering issue.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
bgpd/bgp_nb.c
bgpd/bgp_nb.h
bgpd/bgp_nb_config.c
bgpd/bgp_vty.c
yang/frr-bgp.yang

index ac4720735140c3b685b200699aa4417f8b3ab722..b9fff124dfb7163974e04a34edb94981d86ba553 100644 (file)
@@ -27,11 +27,11 @@ const struct frr_yang_module_info frr_bgp_info = {
        .name = "frr-bgp",
        .nodes = {
                {
-                       .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/global",
+                       .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp",
                        .cbs = {
                                .cli_show = cli_show_router_bgp,
-                               .create = bgp_global_create,
-                               .destroy = bgp_global_destroy,
+                               .create = bgp_create,
+                               .destroy = bgp_destroy,
                        }
                },
                {
index 95803a460e1caf8dca43137cbf4b68b518361541..097b40d7b7777608d9fb2d22fc1d5627fb3ffb55 100644 (file)
@@ -26,8 +26,8 @@
 extern const struct frr_yang_module_info frr_bgp_info;
 
 /* prototypes */
-int bgp_global_create(struct nb_cb_create_args *args);
-int bgp_global_destroy(struct nb_cb_destroy_args *args);
+int bgp_create(struct nb_cb_create_args *args);
+int bgp_destroy(struct nb_cb_destroy_args *args);
 int bgp_global_local_as_modify(struct nb_cb_modify_args *args);
 int bgp_global_router_id_modify(struct nb_cb_modify_args *args);
 int bgp_global_router_id_destroy(struct nb_cb_destroy_args *args);
index 87962febdfe126a0803d275e42faeb052b4234eb..8330ff57c4114eaf1b23f12f09a722759dbf6494 100644 (file)
@@ -60,13 +60,11 @@ int routing_control_plane_protocols_name_validate(
 
 /*
  * XPath:
- * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/global
+ * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp
  */
-int bgp_global_create(struct nb_cb_create_args *args)
+int bgp_create(struct nb_cb_create_args *args)
 {
-
        const struct lyd_node *vrf_dnode;
-       const struct lyd_node *bgp_dnode;
        struct bgp *bgp;
        struct vrf *vrf;
        const char *name = NULL;
@@ -95,10 +93,10 @@ int bgp_global_create(struct nb_cb_create_args *args)
                        inst_type = BGP_INSTANCE_TYPE_VRF;
                }
 
-               as = yang_dnode_get_uint32(args->dnode, "./local-as");
+               as = yang_dnode_get_uint32(args->dnode, "./global/local-as");
 
-               is_view_inst = yang_dnode_get_bool(args->dnode,
-                                                  "./instance-type-view");
+               is_view_inst = yang_dnode_get_bool(
+                       args->dnode, "./global/instance-type-view");
                if (is_view_inst)
                        inst_type = BGP_INSTANCE_TYPE_VIEW;
 
@@ -127,18 +125,16 @@ int bgp_global_create(struct nb_cb_create_args *args)
 
                UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO);
 
-               bgp_dnode = yang_dnode_get_parent(args->dnode, "bgp");
-               nb_running_set_entry(bgp_dnode, bgp);
+               nb_running_set_entry(args->dnode, bgp);
                break;
        }
 
        return NB_OK;
 }
 
-int bgp_global_destroy(struct nb_cb_destroy_args *args)
+int bgp_destroy(struct nb_cb_destroy_args *args)
 {
        struct bgp *bgp;
-       const struct lyd_node *bgp_dnode;
 
        switch (args->event) {
        case NB_EV_VALIDATE:
@@ -171,8 +167,7 @@ int bgp_global_destroy(struct nb_cb_destroy_args *args)
        case NB_EV_ABORT:
                return NB_OK;
        case NB_EV_APPLY:
-               bgp_dnode = yang_dnode_get_parent(args->dnode, "bgp");
-               bgp = nb_running_unset_entry(bgp_dnode);
+               bgp = nb_running_unset_entry(args->dnode);
 
                bgp_vpn_leak_unimport(bgp);
                bgp_delete(bgp);
index 8a83b0320727fad98fb66e81a05ffe325bcf56be..2a5ef34d09bc7e12895042c3a6552e167be02d16 100644 (file)
@@ -1384,7 +1384,7 @@ void cli_show_router_bgp(struct vty *vty, struct lyd_node *dnode,
 
        vrf_dnode = yang_dnode_get_parent(dnode, "control-plane-protocol");
        vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf");
-       as = yang_dnode_get_uint32(dnode, "./local-as");
+       as = yang_dnode_get_uint32(dnode, "./global/local-as");
 
        vty_out(vty, "!\n");
        vty_out(vty, "router bgp %u", as);
index 3e5b1da7d3dc2a99ed6564b9c73830d3059e4dda..e10b5e7848b68768e100b999e0f24f97ad4bbc7b 100644 (file)
@@ -90,10 +90,10 @@ module frr-bgp {
           "BGP protocol augmentation of ietf-routing module
            control-plane-protocol.";
       }
+      presence "Enables configuration of BGP";
       description
         "Top-level configuration for the BGP router.";
       container global {
-        presence "Enables global configuration of BGP";
         description
           "Global configuration for the BGP router.";
         leaf local-as {