lib, mgmtd, zebra: cleanup of zebra conversion to mgmtd

- use `apply_finish` callback when possible to avoid multiple applies per commit
- move table range working to the CLI handler
- remove unnecessary conditional compilation
- remove unnecessary boolean conversion

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2024-01-28 23:23:57 +02:00
parent 3900813298
commit 15514b6d28
7 changed files with 104 additions and 128 deletions

View file

@ -630,6 +630,7 @@ struct frr_yang_module_info {
/* /*
* The NULL-terminated list of supported features. * The NULL-terminated list of supported features.
* Features are defined with "feature" statements in the YANG model.
* Use ["*", NULL] to enable all features. * Use ["*", NULL] to enable all features.
* Use NULL to disable all features. * Use NULL to disable all features.
*/ */

View file

@ -3792,27 +3792,16 @@ void link_param_cmd_set_uint32(struct interface *ifp, uint32_t *field,
if (IS_PARAM_UNSET(ifp->link_params, type) || *field != value) { if (IS_PARAM_UNSET(ifp->link_params, type) || *field != value) {
*field = value; *field = value;
SET_PARAM(ifp->link_params, type); SET_PARAM(ifp->link_params, type);
/* force protocols to update LINK STATE due to parameters change
*/
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
} }
} }
void link_param_cmd_set_float(struct interface *ifp, float *field, void link_param_cmd_set_float(struct interface *ifp, float *field,
uint32_t type, float value) uint32_t type, float value)
{ {
/* Update field as needed */ /* Update field as needed */
if (IS_PARAM_UNSET(ifp->link_params, type) || *field != value) { if (IS_PARAM_UNSET(ifp->link_params, type) || *field != value) {
*field = value; *field = value;
SET_PARAM(ifp->link_params, type); SET_PARAM(ifp->link_params, type);
/* force protocols to update LINK STATE due to parameters change
*/
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
} }
} }
@ -3823,10 +3812,6 @@ void link_param_cmd_unset(struct interface *ifp, uint32_t type)
/* Unset field */ /* Unset field */
UNSET_PARAM(ifp->link_params, type); UNSET_PARAM(ifp->link_params, type);
/* force protocols to update LINK STATE due to parameters change */
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
} }
void if_ip_address_install(struct interface *ifp, struct prefix *prefix, void if_ip_address_install(struct interface *ifp, struct prefix *prefix,

View file

@ -267,14 +267,8 @@ void table_manager_disable(struct zebra_vrf *zvrf)
void table_manager_range(bool add, struct zebra_vrf *zvrf, uint32_t start, void table_manager_range(bool add, struct zebra_vrf *zvrf, uint32_t start,
uint32_t end) uint32_t end)
{ {
if (add) { if (add)
if (zvrf->tbl_mgr &&
((zvrf->tbl_mgr->start && zvrf->tbl_mgr->start != start) ||
(zvrf->tbl_mgr->end && zvrf->tbl_mgr->end != end)))
zlog_info(
"%% New range will be taken into account at restart");
table_range_add(zvrf, start, end); table_range_add(zvrf, start, end);
} else else
table_range_add(zvrf, 0, 0); table_range_add(zvrf, 0, 0);
} }

View file

@ -2212,7 +2212,10 @@ DEFPY_YANG (vrf_netns,
"Attach VRF to a Namespace\n" "Attach VRF to a Namespace\n"
"The file name in " NS_RUN_DIR ", or a full pathname\n") "The file name in " NS_RUN_DIR ", or a full pathname\n")
{ {
return CMD_SUCCESS; vty_out(vty, "%% This command doesn't do anything.\n");
vty_out(vty,
"%% VRF is linked to a netns automatically based on its name.\n");
return CMD_WARNING;
} }
DEFPY_YANG (ip_table_range, ip_table_range_cmd, DEFPY_YANG (ip_table_range, ip_table_range_cmd,
@ -2224,6 +2227,41 @@ DEFPY_YANG (ip_table_range, ip_table_range_cmd,
"End Routing Table\n") "End Routing Table\n")
{ {
if (!no) { if (!no) {
const struct lyd_node *start_node;
const struct lyd_node *end_node;
if (vty->node == CONFIG_NODE) {
start_node =
yang_dnode_getf(vty->candidate_config->dnode,
"/frr-vrf:lib/vrf[name='%s']/frr-zebra:zebra/netns/table-range/start",
VRF_DEFAULT_NAME);
end_node =
yang_dnode_getf(vty->candidate_config->dnode,
"/frr-vrf:lib/vrf[name='%s']/frr-zebra:zebra/netns/table-range/end",
VRF_DEFAULT_NAME);
} else {
start_node =
yang_dnode_getf(vty->candidate_config->dnode,
"%s/frr-zebra:zebra/netns/table-range/start",
VTY_CURR_XPATH);
end_node =
yang_dnode_getf(vty->candidate_config->dnode,
"%s/frr-zebra:zebra/netns/table-range/end",
VTY_CURR_XPATH);
}
if (start_node && end_node) {
if (yang_dnode_get_uint32(start_node, NULL) !=
(uint32_t)start ||
yang_dnode_get_uint32(end_node, NULL) !=
(uint32_t)end) {
vty_out(vty,
"%% New range will be taken into account at restart.\n");
vty_out(vty,
"%% Don't forget to save your configuration.\n");
}
}
nb_cli_enqueue_change(vty, "./frr-zebra:zebra/netns/table-range", nb_cli_enqueue_change(vty, "./frr-zebra:zebra/netns/table-range",
NB_OP_CREATE, NULL); NB_OP_CREATE, NULL);
nb_cli_enqueue_change(vty, nb_cli_enqueue_change(vty,
@ -2546,7 +2584,6 @@ DEFPY_YANG(
return nb_cli_apply_changes(vty, NULL); return nb_cli_apply_changes(vty, NULL);
} }
#if HAVE_BFDD == 0 || defined(HAVE_RTADV)
const char *features[] = { const char *features[] = {
#if HAVE_BFDD == 0 #if HAVE_BFDD == 0
"ptm-bfd", "ptm-bfd",
@ -2556,15 +2593,12 @@ const char *features[] = {
#endif #endif
NULL NULL
}; };
#endif
/* clang-format off */ /* clang-format off */
const struct frr_yang_module_info frr_zebra_cli_info = { const struct frr_yang_module_info frr_zebra_cli_info = {
.name = "frr-zebra", .name = "frr-zebra",
.ignore_cfg_cbs = true, .ignore_cfg_cbs = true,
#if HAVE_BFDD == 0 || defined(HAVE_RTADV)
.features = features, .features = features,
#endif
.nodes = { .nodes = {
#if HAVE_BFDD == 0 #if HAVE_BFDD == 0
{ {

View file

@ -10,7 +10,6 @@
#include "libfrr.h" #include "libfrr.h"
#include "zebra_nb.h" #include "zebra_nb.h"
#if HAVE_BFDD == 0 || defined(HAVE_RTADV)
const char *features[] = { const char *features[] = {
#if HAVE_BFDD == 0 #if HAVE_BFDD == 0
"ptm-bfd", "ptm-bfd",
@ -20,14 +19,11 @@ const char *features[] = {
#endif #endif
NULL NULL
}; };
#endif
/* clang-format off */ /* clang-format off */
const struct frr_yang_module_info frr_zebra_info = { const struct frr_yang_module_info frr_zebra_info = {
.name = "frr-zebra", .name = "frr-zebra",
#if HAVE_BFDD == 0 || defined(HAVE_RTADV)
.features = features, .features = features,
#endif
.nodes = { .nodes = {
{ {
.xpath = "/frr-zebra:zebra/mcast-rpf-lookup", .xpath = "/frr-zebra:zebra/mcast-rpf-lookup",
@ -392,6 +388,7 @@ const struct frr_yang_module_info frr_zebra_info = {
.cbs = { .cbs = {
.create = lib_interface_zebra_link_params_create, .create = lib_interface_zebra_link_params_create,
.destroy = lib_interface_zebra_link_params_destroy, .destroy = lib_interface_zebra_link_params_destroy,
.apply_finish = lib_interface_zebra_link_params_apply_finish,
} }
}, },
{ {
@ -808,6 +805,7 @@ const struct frr_yang_module_info frr_zebra_info = {
.cbs = { .cbs = {
.create = lib_vrf_zebra_filter_protocol_create, .create = lib_vrf_zebra_filter_protocol_create,
.destroy = lib_vrf_zebra_filter_protocol_destroy, .destroy = lib_vrf_zebra_filter_protocol_destroy,
.apply_finish = lib_vrf_zebra_filter_protocol_apply_finish,
} }
}, },
{ {
@ -821,6 +819,7 @@ const struct frr_yang_module_info frr_zebra_info = {
.cbs = { .cbs = {
.create = lib_vrf_zebra_filter_nht_create, .create = lib_vrf_zebra_filter_nht_create,
.destroy = lib_vrf_zebra_filter_nht_destroy, .destroy = lib_vrf_zebra_filter_nht_destroy,
.apply_finish = lib_vrf_zebra_filter_nht_apply_finish,
} }
}, },
{ {

View file

@ -107,6 +107,8 @@ int lib_interface_zebra_mpls_modify(struct nb_cb_modify_args *args);
int lib_interface_zebra_mpls_destroy(struct nb_cb_destroy_args *args); int lib_interface_zebra_mpls_destroy(struct nb_cb_destroy_args *args);
int lib_interface_zebra_link_params_create(struct nb_cb_create_args *args); int lib_interface_zebra_link_params_create(struct nb_cb_create_args *args);
int lib_interface_zebra_link_params_destroy(struct nb_cb_destroy_args *args); int lib_interface_zebra_link_params_destroy(struct nb_cb_destroy_args *args);
void lib_interface_zebra_link_params_apply_finish(
struct nb_cb_apply_finish_args *args);
int lib_interface_zebra_link_params_metric_modify(struct nb_cb_modify_args *args); int lib_interface_zebra_link_params_metric_modify(struct nb_cb_modify_args *args);
int lib_interface_zebra_link_params_metric_destroy( int lib_interface_zebra_link_params_metric_destroy(
struct nb_cb_destroy_args *args); struct nb_cb_destroy_args *args);
@ -283,10 +285,13 @@ int lib_vrf_zebra_ipv6_router_id_modify(struct nb_cb_modify_args *args);
int lib_vrf_zebra_ipv6_router_id_destroy(struct nb_cb_destroy_args *args); int lib_vrf_zebra_ipv6_router_id_destroy(struct nb_cb_destroy_args *args);
int lib_vrf_zebra_filter_protocol_create(struct nb_cb_create_args *args); int lib_vrf_zebra_filter_protocol_create(struct nb_cb_create_args *args);
int lib_vrf_zebra_filter_protocol_destroy(struct nb_cb_destroy_args *args); int lib_vrf_zebra_filter_protocol_destroy(struct nb_cb_destroy_args *args);
void lib_vrf_zebra_filter_protocol_apply_finish(
struct nb_cb_apply_finish_args *args);
int lib_vrf_zebra_filter_protocol_route_map_modify( int lib_vrf_zebra_filter_protocol_route_map_modify(
struct nb_cb_modify_args *args); struct nb_cb_modify_args *args);
int lib_vrf_zebra_filter_nht_create(struct nb_cb_create_args *args); int lib_vrf_zebra_filter_nht_create(struct nb_cb_create_args *args);
int lib_vrf_zebra_filter_nht_destroy(struct nb_cb_destroy_args *args); int lib_vrf_zebra_filter_nht_destroy(struct nb_cb_destroy_args *args);
void lib_vrf_zebra_filter_nht_apply_finish(struct nb_cb_apply_finish_args *args);
int lib_vrf_zebra_filter_nht_route_map_modify(struct nb_cb_modify_args *args); int lib_vrf_zebra_filter_nht_route_map_modify(struct nb_cb_modify_args *args);
int lib_vrf_zebra_resolve_via_default_modify(struct nb_cb_modify_args *args); int lib_vrf_zebra_resolve_via_default_modify(struct nb_cb_modify_args *args);
int lib_vrf_zebra_resolve_via_default_destroy(struct nb_cb_destroy_args *args); int lib_vrf_zebra_resolve_via_default_destroy(struct nb_cb_destroy_args *args);

View file

@ -1326,8 +1326,11 @@ int lib_interface_zebra_link_params_create(struct nb_cb_create_args *args)
ifp = nb_running_get_entry(args->dnode, NULL, true); ifp = nb_running_get_entry(args->dnode, NULL, true);
if_link_params_enable(ifp); if_link_params_enable(ifp);
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp); /*
* The interface is updated in the apply_finish callback after all
* parameters are set in the corresponding callbacks.
*/
return NB_OK; return NB_OK;
} }
@ -1347,6 +1350,16 @@ int lib_interface_zebra_link_params_destroy(struct nb_cb_destroy_args *args)
return NB_OK; return NB_OK;
} }
void lib_interface_zebra_link_params_apply_finish(
struct nb_cb_apply_finish_args *args)
{
struct interface *ifp;
ifp = nb_running_get_entry(args->dnode, NULL, true);
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
}
/* /*
* XPath: /frr-interface:lib/interface/frr-zebra:zebra/link-params/metric * XPath: /frr-interface:lib/interface/frr-zebra:zebra/link-params/metric
*/ */
@ -1736,9 +1749,6 @@ int lib_interface_zebra_legacy_admin_group_modify(
admin_group_clear(&iflp->ext_admin_grp); admin_group_clear(&iflp->ext_admin_grp);
UNSET_PARAM(iflp, LP_EXTEND_ADM_GRP); UNSET_PARAM(iflp, LP_EXTEND_ADM_GRP);
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
break; break;
} }
return NB_OK; return NB_OK;
@ -1761,9 +1771,6 @@ int lib_interface_zebra_legacy_admin_group_destroy(
iflp->admin_grp = 0; iflp->admin_grp = 0;
UNSET_PARAM(iflp, LP_ADM_GRP); UNSET_PARAM(iflp, LP_ADM_GRP);
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
break; break;
} }
return NB_OK; return NB_OK;
@ -1806,9 +1813,6 @@ int lib_interface_zebra_affinity_create(struct nb_cb_create_args *args)
affmap->bit_position); affmap->bit_position);
SET_PARAM(iflp, LP_EXTEND_ADM_GRP); SET_PARAM(iflp, LP_EXTEND_ADM_GRP);
} }
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
break; break;
} }
return NB_OK; return NB_OK;
@ -1849,9 +1853,6 @@ int lib_interface_zebra_affinity_destroy(struct nb_cb_destroy_args *args)
if (admin_group_zero(&iflp->ext_admin_grp)) if (admin_group_zero(&iflp->ext_admin_grp))
UNSET_PARAM(iflp, LP_EXTEND_ADM_GRP); UNSET_PARAM(iflp, LP_EXTEND_ADM_GRP);
} }
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
break; break;
} }
return NB_OK; return NB_OK;
@ -1911,9 +1912,6 @@ int lib_interface_zebra_affinity_mode_modify(struct nb_cb_modify_args *args)
SET_PARAM(iflp, LP_ADM_GRP); SET_PARAM(iflp, LP_ADM_GRP);
} }
} }
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
break; break;
} }
return NB_OK; return NB_OK;
@ -1942,9 +1940,6 @@ int lib_interface_zebra_link_params_neighbor_create(struct nb_cb_create_args *ar
iflp->rmt_ip = ip; iflp->rmt_ip = ip;
SET_PARAM(iflp, LP_RMT_AS); SET_PARAM(iflp, LP_RMT_AS);
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
return NB_OK; return NB_OK;
} }
@ -1964,9 +1959,6 @@ int lib_interface_zebra_link_params_neighbor_destroy(
iflp->rmt_ip.s_addr = 0; iflp->rmt_ip.s_addr = 0;
UNSET_PARAM(iflp, LP_RMT_AS); UNSET_PARAM(iflp, LP_RMT_AS);
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
return NB_OK; return NB_OK;
} }
@ -1990,9 +1982,6 @@ int lib_interface_zebra_link_params_neighbor_remote_as_modify(
iflp->rmt_as = as; iflp->rmt_as = as;
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
return NB_OK; return NB_OK;
} }
@ -2016,9 +2005,6 @@ int lib_interface_zebra_link_params_neighbor_ipv4_remote_id_modify(
iflp->rmt_ip = ip; iflp->rmt_ip = ip;
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
return NB_OK; return NB_OK;
} }
@ -2084,9 +2070,6 @@ int lib_interface_zebra_link_params_min_max_delay_create(
iflp->max_delay = delay_max; iflp->max_delay = delay_max;
SET_PARAM(iflp, LP_MM_DELAY); SET_PARAM(iflp, LP_MM_DELAY);
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
return NB_OK; return NB_OK;
} }
@ -2106,9 +2089,6 @@ int lib_interface_zebra_link_params_min_max_delay_destroy(
iflp->max_delay = 0; iflp->max_delay = 0;
UNSET_PARAM(iflp, LP_MM_DELAY); UNSET_PARAM(iflp, LP_MM_DELAY);
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
return NB_OK; return NB_OK;
} }
@ -2132,9 +2112,6 @@ int lib_interface_zebra_link_params_min_max_delay_delay_min_modify(
iflp->min_delay = delay_min; iflp->min_delay = delay_min;
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
return NB_OK; return NB_OK;
} }
@ -2158,9 +2135,6 @@ int lib_interface_zebra_link_params_min_max_delay_delay_max_modify(
iflp->max_delay = delay_max; iflp->max_delay = delay_max;
if (if_is_operative(ifp))
zebra_interface_parameters_update(ifp);
return NB_OK; return NB_OK;
} }
@ -2566,7 +2540,7 @@ int lib_interface_zebra_ipv6_router_advertisements_managed_flag_modify(
managed_flag = yang_dnode_get_bool(args->dnode, NULL); managed_flag = yang_dnode_get_bool(args->dnode, NULL);
zif->rtadv.AdvManagedFlag = !!managed_flag; zif->rtadv.AdvManagedFlag = managed_flag;
return NB_OK; return NB_OK;
} }
@ -2589,7 +2563,7 @@ int lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify(
other_config_flag = yang_dnode_get_bool(args->dnode, NULL); other_config_flag = yang_dnode_get_bool(args->dnode, NULL);
zif->rtadv.AdvOtherConfigFlag = !!other_config_flag; zif->rtadv.AdvOtherConfigFlag = other_config_flag;
return NB_OK; return NB_OK;
} }
@ -2612,7 +2586,7 @@ int lib_interface_zebra_ipv6_router_advertisements_home_agent_flag_modify(
home_agent_flag = yang_dnode_get_bool(args->dnode, NULL); home_agent_flag = yang_dnode_get_bool(args->dnode, NULL);
zif->rtadv.AdvHomeAgentFlag = !!home_agent_flag; zif->rtadv.AdvHomeAgentFlag = home_agent_flag;
return NB_OK; return NB_OK;
} }
@ -2804,7 +2778,7 @@ int lib_interface_zebra_ipv6_router_advertisements_advertisement_interval_option
option = yang_dnode_get_bool(args->dnode, NULL); option = yang_dnode_get_bool(args->dnode, NULL);
zif->rtadv.AdvIntervalOption = !!option; zif->rtadv.AdvIntervalOption = option;
return NB_OK; return NB_OK;
} }
@ -2927,11 +2901,11 @@ int lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_create(
ifp = nb_running_get_entry(args->dnode, NULL, true); ifp = nb_running_get_entry(args->dnode, NULL, true);
yang_dnode_get_ipv6p(&rp.prefix, args->dnode, "prefix-spec"); yang_dnode_get_ipv6p(&rp.prefix, args->dnode, "prefix-spec");
rp.AdvOnLinkFlag = !!yang_dnode_get_bool(args->dnode, "on-link-flag"); rp.AdvOnLinkFlag = yang_dnode_get_bool(args->dnode, "on-link-flag");
rp.AdvAutonomousFlag = !!yang_dnode_get_bool(args->dnode, rp.AdvAutonomousFlag = yang_dnode_get_bool(args->dnode,
"autonomous-flag"); "autonomous-flag");
rp.AdvRouterAddressFlag = !!yang_dnode_get_bool(args->dnode, rp.AdvRouterAddressFlag = yang_dnode_get_bool(args->dnode,
"router-address-flag"); "router-address-flag");
rp.AdvValidLifetime = yang_dnode_get_uint32(args->dnode, rp.AdvValidLifetime = yang_dnode_get_uint32(args->dnode,
"valid-lifetime"); "valid-lifetime");
rp.AdvPreferredLifetime = yang_dnode_get_uint32(args->dnode, rp.AdvPreferredLifetime = yang_dnode_get_uint32(args->dnode,
@ -2991,7 +2965,7 @@ int lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_on_link_fl
prefix = nb_running_get_entry(args->dnode, NULL, true); prefix = nb_running_get_entry(args->dnode, NULL, true);
prefix->AdvOnLinkFlag = !!yang_dnode_get_bool(args->dnode, NULL); prefix->AdvOnLinkFlag = yang_dnode_get_bool(args->dnode, NULL);
return NB_OK; return NB_OK;
} }
@ -3027,7 +3001,7 @@ int lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_autonomous
prefix = nb_running_get_entry(args->dnode, NULL, true); prefix = nb_running_get_entry(args->dnode, NULL, true);
prefix->AdvAutonomousFlag = !!yang_dnode_get_bool(args->dnode, NULL); prefix->AdvAutonomousFlag = yang_dnode_get_bool(args->dnode, NULL);
return NB_OK; return NB_OK;
} }
@ -3045,7 +3019,7 @@ int lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_router_add
prefix = nb_running_get_entry(args->dnode, NULL, true); prefix = nb_running_get_entry(args->dnode, NULL, true);
prefix->AdvRouterAddressFlag = !!yang_dnode_get_bool(args->dnode, NULL); prefix->AdvRouterAddressFlag = yang_dnode_get_bool(args->dnode, NULL);
return NB_OK; return NB_OK;
} }
@ -3326,16 +3300,9 @@ int lib_vrf_zebra_ipv6_router_id_destroy(struct nb_cb_destroy_args *args)
*/ */
int lib_vrf_zebra_filter_protocol_create(struct nb_cb_create_args *args) int lib_vrf_zebra_filter_protocol_create(struct nb_cb_create_args *args)
{ {
struct vrf *vrf;
const char *afi_safi = yang_dnode_get_string(args->dnode, "afi-safi");
const char *proto = yang_dnode_get_string(args->dnode, "protocol"); const char *proto = yang_dnode_get_string(args->dnode, "protocol");
const char *rmap = yang_dnode_get_string(args->dnode, "route-map");
afi_t afi;
safi_t safi;
int rtype; int rtype;
yang_afi_safi_identity2value(afi_safi, &afi, &safi);
if (strcasecmp(proto, "any") == 0) if (strcasecmp(proto, "any") == 0)
rtype = ZEBRA_ROUTE_MAX; rtype = ZEBRA_ROUTE_MAX;
else else
@ -3348,12 +3315,7 @@ int lib_vrf_zebra_filter_protocol_create(struct nb_cb_create_args *args)
return NB_ERR_VALIDATION; return NB_ERR_VALIDATION;
} }
if (args->event != NB_EV_APPLY) /* the creation finishes in the apply_finish callback */
return NB_OK;
vrf = nb_running_get_entry(args->dnode, NULL, true);
ip_protocol_rm_add(vrf->info, rmap, rtype, afi, safi);
return NB_OK; return NB_OK;
} }
@ -3388,15 +3350,13 @@ int lib_vrf_zebra_filter_protocol_destroy(struct nb_cb_destroy_args *args)
return NB_OK; return NB_OK;
} }
/* void lib_vrf_zebra_filter_protocol_apply_finish(
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/filter-protocol/route-map struct nb_cb_apply_finish_args *args)
*/
int lib_vrf_zebra_filter_protocol_route_map_modify(struct nb_cb_modify_args *args)
{ {
struct vrf *vrf; struct vrf *vrf;
const char *afi_safi = yang_dnode_get_string(args->dnode, "../afi-safi"); const char *afi_safi = yang_dnode_get_string(args->dnode, "afi-safi");
const char *proto = yang_dnode_get_string(args->dnode, "../protocol"); const char *proto = yang_dnode_get_string(args->dnode, "protocol");
const char *rmap = yang_dnode_get_string(args->dnode, NULL); const char *rmap = yang_dnode_get_string(args->dnode, "route-map");
afi_t afi; afi_t afi;
safi_t safi; safi_t safi;
int rtype; int rtype;
@ -3408,16 +3368,20 @@ int lib_vrf_zebra_filter_protocol_route_map_modify(struct nb_cb_modify_args *arg
else else
rtype = proto_name2num(proto); rtype = proto_name2num(proto);
/* editing an existing entry, it can't be invalid */ /* finishing apply for a validated entry, it can't be invalid */
assert(rtype >= 0); assert(rtype >= 0);
if (args->event != NB_EV_APPLY)
return NB_OK;
vrf = nb_running_get_entry(args->dnode, NULL, true); vrf = nb_running_get_entry(args->dnode, NULL, true);
ip_protocol_rm_add(vrf->info, rmap, rtype, afi, safi); ip_protocol_rm_add(vrf->info, rmap, rtype, afi, safi);
}
/*
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/filter-protocol/route-map
*/
int lib_vrf_zebra_filter_protocol_route_map_modify(struct nb_cb_modify_args *args)
{
/* the update is done in the apply_finish callback */
return NB_OK; return NB_OK;
} }
@ -3426,10 +3390,8 @@ int lib_vrf_zebra_filter_protocol_route_map_modify(struct nb_cb_modify_args *arg
*/ */
int lib_vrf_zebra_filter_nht_create(struct nb_cb_create_args *args) int lib_vrf_zebra_filter_nht_create(struct nb_cb_create_args *args)
{ {
struct vrf *vrf;
const char *afi_safi = yang_dnode_get_string(args->dnode, "afi-safi"); const char *afi_safi = yang_dnode_get_string(args->dnode, "afi-safi");
const char *proto = yang_dnode_get_string(args->dnode, "protocol"); const char *proto = yang_dnode_get_string(args->dnode, "protocol");
const char *rmap = yang_dnode_get_string(args->dnode, "route-map");
afi_t afi; afi_t afi;
safi_t safi; safi_t safi;
int rtype; int rtype;
@ -3454,12 +3416,7 @@ int lib_vrf_zebra_filter_nht_create(struct nb_cb_create_args *args)
} }
} }
if (args->event != NB_EV_APPLY) /* the creation finishes in the apply_finish callback */
return NB_OK;
vrf = nb_running_get_entry(args->dnode, NULL, true);
ip_nht_rm_add(vrf->info, rmap, rtype, afi);
return NB_OK; return NB_OK;
} }
@ -3495,15 +3452,12 @@ int lib_vrf_zebra_filter_nht_destroy(struct nb_cb_destroy_args *args)
return NB_OK; return NB_OK;
} }
/* void lib_vrf_zebra_filter_nht_apply_finish(struct nb_cb_apply_finish_args *args)
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/filter-nht/route-map
*/
int lib_vrf_zebra_filter_nht_route_map_modify(struct nb_cb_modify_args *args)
{ {
struct vrf *vrf; struct vrf *vrf;
const char *afi_safi = yang_dnode_get_string(args->dnode, "../afi-safi"); const char *afi_safi = yang_dnode_get_string(args->dnode, "afi-safi");
const char *proto = yang_dnode_get_string(args->dnode, "../protocol"); const char *proto = yang_dnode_get_string(args->dnode, "protocol");
const char *rmap = yang_dnode_get_string(args->dnode, NULL); const char *rmap = yang_dnode_get_string(args->dnode, "route-map");
afi_t afi; afi_t afi;
safi_t safi; safi_t safi;
int rtype; int rtype;
@ -3515,17 +3469,21 @@ int lib_vrf_zebra_filter_nht_route_map_modify(struct nb_cb_modify_args *args)
else else
rtype = proto_name2num(proto); rtype = proto_name2num(proto);
/* editing an existing entry, it can't be invalid */ /* finishing apply for an existing entry, it can't be invalid */
assert(rtype >= 0); assert(rtype >= 0);
assert(safi == SAFI_UNICAST); assert(safi == SAFI_UNICAST);
if (args->event != NB_EV_APPLY)
return NB_OK;
vrf = nb_running_get_entry(args->dnode, NULL, true); vrf = nb_running_get_entry(args->dnode, NULL, true);
ip_nht_rm_add(vrf->info, rmap, rtype, afi); ip_nht_rm_add(vrf->info, rmap, rtype, afi);
}
/*
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/filter-nht/route-map
*/
int lib_vrf_zebra_filter_nht_route_map_modify(struct nb_cb_modify_args *args)
{
/* the update is done in the apply_finish callback */
return NB_OK; return NB_OK;
} }