From: Chirag Shah Date: Sun, 20 Sep 2020 15:13:53 +0000 (-0700) Subject: bgpd: move router bgp nb callback X-Git-Tag: base_7.6~459^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=5e42cb2fb088a28202e60ec57a4116f3d1f0afd5;p=matthieu%2Ffrr.git bgpd: move router bgp nb callback 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 --- diff --git a/bgpd/bgp_nb.c b/bgpd/bgp_nb.c index ac47207351..b9fff124df 100644 --- a/bgpd/bgp_nb.c +++ b/bgpd/bgp_nb.c @@ -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, } }, { diff --git a/bgpd/bgp_nb.h b/bgpd/bgp_nb.h index 95803a460e..097b40d7b7 100644 --- a/bgpd/bgp_nb.h +++ b/bgpd/bgp_nb.h @@ -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); diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c index 87962febdf..8330ff57c4 100644 --- a/bgpd/bgp_nb_config.c +++ b/bgpd/bgp_nb_config.c @@ -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); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 8a83b03207..2a5ef34d09 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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); diff --git a/yang/frr-bgp.yang b/yang/frr-bgp.yang index 3e5b1da7d3..e10b5e7848 100644 --- a/yang/frr-bgp.yang +++ b/yang/frr-bgp.yang @@ -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 {