diff options
author | Christian Hopps <chopps@labn.net> | 2023-04-10 12:32:35 +0200 |
---|---|---|
committer | Christian Hopps <chopps@labn.net> | 2023-04-11 21:27:17 +0200 |
commit | e40c42081d09bc4b601f496593ef2b9a573e7a90 (patch) | |
tree | dc6699dcc390c8e0c5d70f8faaf0a047e884a1e5 /ripngd | |
parent | ripd: adapt to new YANG NB if_rmap conversion (diff) | |
download | frr-e40c42081d09bc4b601f496593ef2b9a573e7a90.tar.xz frr-e40c42081d09bc4b601f496593ef2b9a573e7a90.zip |
ripngd: adapt to new YANG NB if_rmap conversion
- uses YANG grouping and calls if_rmap library code to implement.
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'ripngd')
-rw-r--r-- | ripngd/ripng_nb.c | 21 | ||||
-rw-r--r-- | ripngd/ripng_nb.h | 12 | ||||
-rw-r--r-- | ripngd/ripng_nb_config.c | 89 |
3 files changed, 122 insertions, 0 deletions
diff --git a/ripngd/ripng_nb.c b/ripngd/ripng_nb.c index 63144d866..2f412e519 100644 --- a/ripngd/ripng_nb.c +++ b/ripngd/ripng_nb.c @@ -115,6 +115,27 @@ const struct frr_yang_module_info frr_ripngd_info = { }, }, { + .xpath = "/frr-ripngd:ripngd/instance/if-route-maps/if-route-map", + .cbs = { + .create = ripngd_instance_if_route_maps_if_route_map_create, + .destroy = ripngd_instance_if_route_maps_if_route_map_destroy, + } + }, + { + .xpath = "/frr-ripngd:ripngd/instance/if-route-maps/if-route-map/in-route-map", + .cbs = { + .modify = ripngd_instance_if_route_maps_if_route_map_in_route_map_modify, + .destroy = ripngd_instance_if_route_maps_if_route_map_in_route_map_destroy, + } + }, + { + .xpath = "/frr-ripngd:ripngd/instance/if-route-maps/if-route-map/out-route-map", + .cbs = { + .modify = ripngd_instance_if_route_maps_if_route_map_out_route_map_modify, + .destroy = ripngd_instance_if_route_maps_if_route_map_out_route_map_destroy, + } + }, + { .xpath = "/frr-ripngd:ripngd/instance/static-route", .cbs = { .cli_show = cli_show_ripng_route, diff --git a/ripngd/ripng_nb.h b/ripngd/ripng_nb.h index 675cef7c9..1c0e63c24 100644 --- a/ripngd/ripng_nb.h +++ b/ripngd/ripng_nb.h @@ -39,6 +39,18 @@ int ripngd_instance_redistribute_route_map_destroy( int ripngd_instance_redistribute_metric_modify(struct nb_cb_modify_args *args); int ripngd_instance_redistribute_metric_destroy( struct nb_cb_destroy_args *args); +int ripngd_instance_if_route_maps_if_route_map_create( + struct nb_cb_create_args *args); +int ripngd_instance_if_route_maps_if_route_map_destroy( + struct nb_cb_destroy_args *args); +int ripngd_instance_if_route_maps_if_route_map_in_route_map_modify( + struct nb_cb_modify_args *args); +int ripngd_instance_if_route_maps_if_route_map_in_route_map_destroy( + struct nb_cb_destroy_args *args); +int ripngd_instance_if_route_maps_if_route_map_out_route_map_modify( + struct nb_cb_modify_args *args); +int ripngd_instance_if_route_maps_if_route_map_out_route_map_destroy( + struct nb_cb_destroy_args *args); int ripngd_instance_static_route_create(struct nb_cb_create_args *args); int ripngd_instance_static_route_destroy(struct nb_cb_destroy_args *args); int ripngd_instance_aggregate_address_create(struct nb_cb_create_args *args); diff --git a/ripngd/ripng_nb_config.c b/ripngd/ripng_nb_config.c index 006bf79ce..30f707e06 100644 --- a/ripngd/ripng_nb_config.c +++ b/ripngd/ripng_nb_config.c @@ -3,6 +3,7 @@ * Copyright (C) 1998 Kunihiro Ishiguro * Copyright (C) 2018 NetDEF, Inc. * Renato Westphal + * Copyright (C) 2023 LabN Consulting, L.L.C. */ #include <zebra.h> @@ -13,6 +14,7 @@ #include "prefix.h" #include "table.h" #include "command.h" +#include "if_rmap.h" #include "routemap.h" #include "agg_table.h" #include "northbound.h" @@ -503,6 +505,93 @@ int ripngd_instance_redistribute_metric_destroy(struct nb_cb_destroy_args *args) } /* + * XPath: /frr-ripngd:ripngd/instance/if-route-maps/if-route-map + */ +int ripngd_instance_if_route_maps_if_route_map_create( + struct nb_cb_create_args *args) +{ + /* if_rmap is created when first routemap is added */ + return NB_OK; +} + +int ripngd_instance_if_route_maps_if_route_map_destroy( + struct nb_cb_destroy_args *args) +{ + struct ripng *ripng; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + /* + * YANG will prune edit deletes up to the most general deleted node so + * we need to handle deleting any existing state underneath and not + * count on those more specific callbacks being called individually. + */ + + ripng = nb_running_get_entry(args->dnode, NULL, true); + if_rmap_yang_destroy_cb(ripng->if_rmap_ctx, args->dnode); + + return NB_OK; +} + +static void if_route_map_modify(const struct lyd_node *dnode, + enum if_rmap_type type, bool delete) +{ + struct ripng *ripng = nb_running_get_entry(dnode, NULL, true); + + if_rmap_yang_modify_cb(ripng->if_rmap_ctx, dnode, type, delete); +} +/* + * XPath: /frr-ripng:ripng/instance/if-route-maps/if-route-map/in-route-map + */ +int ripngd_instance_if_route_maps_if_route_map_in_route_map_modify( + struct nb_cb_modify_args *args) +{ + if (args->event != NB_EV_APPLY) + return NB_OK; + + if_route_map_modify(args->dnode, IF_RMAP_IN, false); + + return NB_OK; +} + +int ripngd_instance_if_route_maps_if_route_map_in_route_map_destroy( + struct nb_cb_destroy_args *args) +{ + if (args->event != NB_EV_APPLY) + return NB_OK; + + if_route_map_modify(args->dnode, IF_RMAP_IN, true); + + return NB_OK; +} + +/* + * XPath: /frr-ripngd:ripngd/instance/if-route-maps/if-route-map/out-route-map + */ +int ripngd_instance_if_route_maps_if_route_map_out_route_map_modify( + struct nb_cb_modify_args *args) +{ + if (args->event != NB_EV_APPLY) + return NB_OK; + + if_route_map_modify(args->dnode, IF_RMAP_OUT, false); + + return NB_OK; +} + +int ripngd_instance_if_route_maps_if_route_map_out_route_map_destroy( + struct nb_cb_destroy_args *args) +{ + if (args->event != NB_EV_APPLY) + return NB_OK; + + if_route_map_modify(args->dnode, IF_RMAP_OUT, true); + + return NB_OK; +} + +/* * XPath: /frr-ripngd:ripngd/instance/static-route */ int ripngd_instance_static_route_create(struct nb_cb_create_args *args) |