diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2019-10-17 20:33:53 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2019-10-30 01:49:14 +0100 |
commit | 2a1c520e9f105b1a1bbdb89d59ad3c3953f46f49 (patch) | |
tree | 23ebce15b36d13f0164d1961aa3cc8df452bffc6 | |
parent | Merge pull request #5197 from SumitAgarwal123/BFD_ADMIN_DOWN (diff) | |
download | frr-2a1c520e9f105b1a1bbdb89d59ad3c3953f46f49.tar.xz frr-2a1c520e9f105b1a1bbdb89d59ad3c3953f46f49.zip |
isisd: split northbound callbacks into multiple files
Rearrange the isisd northbound callbacks as following:
* isis_nb.h: prototypes of all northbound callbacks.
* isis_nb.c: definition of all northbound callbacks and their
associated YANG data paths.
* isis_nb_config.c: implementation of YANG configuration nodes.
* isis_nb_state.c: implementation of YANG state nodes.
* isis_nb_notifications.c: implementation of YANG notifications.
This should help to keep to code more organized and easier to
maintain.
No behavior changes intended.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
-rw-r--r-- | isisd/isis_adjacency.c | 15 | ||||
-rw-r--r-- | isisd/isis_adjacency.h | 1 | ||||
-rw-r--r-- | isisd/isis_circuit.c | 1 | ||||
-rw-r--r-- | isisd/isis_cli.c | 2 | ||||
-rw-r--r-- | isisd/isis_cli.h | 127 | ||||
-rw-r--r-- | isisd/isis_lsp.c | 1 | ||||
-rw-r--r-- | isisd/isis_main.c | 1 | ||||
-rw-r--r-- | isisd/isis_nb.c | 815 | ||||
-rw-r--r-- | isisd/isis_nb.h | 548 | ||||
-rw-r--r-- | isisd/isis_nb_config.c | 2236 | ||||
-rw-r--r-- | isisd/isis_nb_notifications.c | 491 | ||||
-rw-r--r-- | isisd/isis_nb_state.c | 386 | ||||
-rw-r--r-- | isisd/isis_northbound.c | 3932 | ||||
-rw-r--r-- | isisd/isis_pdu.c | 1 | ||||
-rw-r--r-- | isisd/isisd.c | 1 | ||||
-rw-r--r-- | isisd/isisd.h | 46 | ||||
-rw-r--r-- | isisd/subdir.am | 7 |
17 files changed, 4503 insertions, 4108 deletions
diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c index d2ec6ff56..1d70521e6 100644 --- a/isisd/isis_adjacency.c +++ b/isisd/isis_adjacency.c @@ -48,6 +48,7 @@ #include "isisd/isis_mt.h" #include "isisd/isis_tlvs.h" #include "isisd/fabricd.h" +#include "isisd/isis_nb.h" extern struct isis *isis; @@ -375,6 +376,20 @@ void isis_adj_print(struct isis_adjacency *adj) return; } +const char *isis_adj_yang_state(enum isis_adj_state state) +{ + switch (state) { + case ISIS_ADJ_DOWN: + return "down"; + case ISIS_ADJ_UP: + return "up"; + case ISIS_ADJ_INITIALIZING: + return "init"; + default: + return "failed"; + } +} + int isis_adj_expire(struct thread *thread) { struct isis_adjacency *adj; diff --git a/isisd/isis_adjacency.h b/isisd/isis_adjacency.h index 2a4cb6e61..93583fc12 100644 --- a/isisd/isis_adjacency.h +++ b/isisd/isis_adjacency.h @@ -121,6 +121,7 @@ DECLARE_HOOK(isis_adj_state_change_hook, (struct isis_adjacency *adj), (adj)) void isis_adj_state_change(struct isis_adjacency *adj, enum isis_adj_state state, const char *reason); void isis_adj_print(struct isis_adjacency *adj); +const char *isis_adj_yang_state(enum isis_adj_state state); int isis_adj_expire(struct thread *thread); void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty, char detail); diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 29fb725b0..1d0e6549d 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -58,6 +58,7 @@ #include "isisd/isis_mt.h" #include "isisd/isis_errors.h" #include "isisd/isis_tx_queue.h" +#include "isisd/isis_nb.h" DEFINE_QOBJ_TYPE(isis_circuit) diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index 37f4dcfab..3144b3c28 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -32,7 +32,7 @@ #include "yang.h" #include "lib/linklist.h" #include "isisd/isisd.h" -#include "isisd/isis_cli.h" +#include "isisd/isis_nb.h" #include "isisd/isis_misc.h" #include "isisd/isis_circuit.h" #include "isisd/isis_csm.h" diff --git a/isisd/isis_cli.h b/isisd/isis_cli.h deleted file mode 100644 index 6621dc0fc..000000000 --- a/isisd/isis_cli.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2018 Volta Networks - * Emanuele Di Pascale - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; see the file COPYING; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef ISISD_ISIS_CLI_H_ -#define ISISD_ISIS_CLI_H_ - -/* add cli_show declarations here as externs */ -void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_ipv4(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_bfd_monitoring(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_area_address(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_is_type(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_dynamic_hostname(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_attached(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_overload(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_metric_style(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_area_pwd(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_domain_pwd(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_lsp_gen_interval(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_lsp_ref_interval(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_lsp_max_lifetime(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_lsp_mtu(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_spf_min_interval(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_spf_ietf_backoff(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_purge_origin(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mpls_te(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mpls_te_router_addr(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_def_origin_ipv4(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_def_origin_ipv6(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_redistribute_ipv4(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_redistribute_ipv6(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_passive(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_password(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_metric(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_hello_interval(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_hello_multi(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_threeway_shake(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_hello_padding(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_csnp_interval(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_psnp_interval(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_mt_ipv4_unicast(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_priority(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_log_adjacency(struct vty *vty, struct lyd_node *dnode, - bool show_defaults); - -#endif /* ISISD_ISIS_CLI_H_ */ diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 061e75883..c0b90e843 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -57,6 +57,7 @@ #include "isisd/isis_te.h" #include "isisd/fabricd.h" #include "isisd/isis_tx_queue.h" +#include "isisd/isis_nb.h" static int lsp_refresh(struct thread *thread); static int lsp_l1_refresh_pseudo(struct thread *thread); diff --git a/isisd/isis_main.c b/isisd/isis_main.c index 718924daf..2ef006518 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -57,6 +57,7 @@ #include "isisd/isis_lsp.h" #include "isisd/isis_mt.h" #include "isisd/fabricd.h" +#include "isisd/isis_nb.h" /* Default configuration file name */ #define ISISD_DEFAULT_CONFIG "isisd.conf" diff --git a/isisd/isis_nb.c b/isisd/isis_nb.c new file mode 100644 index 000000000..d84e53324 --- /dev/null +++ b/isisd/isis_nb.c @@ -0,0 +1,815 @@ +/* + * Copyright (C) 2018 Volta Networks + * Emanuele Di Pascale + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <zebra.h> + +#include "northbound.h" +#include "libfrr.h" + +#include "isisd/isis_nb.h" + +/* clang-format off */ +const struct frr_yang_module_info frr_isisd_info = { + .name = "frr-isisd", + .nodes = { + { + .xpath = "/frr-isisd:isis/instance", + .cbs = { + .cli_show = cli_show_router_isis, + .create = isis_instance_create, + .destroy = isis_instance_destroy, + }, + .priority = NB_DFLT_PRIORITY - 1, + }, + { + .xpath = "/frr-isisd:isis/instance/is-type", + .cbs = { + .cli_show = cli_show_isis_is_type, + .modify = isis_instance_is_type_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/area-address", + .cbs = { + .cli_show = cli_show_isis_area_address, + .create = isis_instance_area_address_create, + .destroy = isis_instance_area_address_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/dynamic-hostname", + .cbs = { + .cli_show = cli_show_isis_dynamic_hostname, + .modify = isis_instance_dynamic_hostname_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/attached", + .cbs = { + .cli_show = cli_show_isis_attached, + .modify = isis_instance_attached_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/overload", + .cbs = { + .cli_show = cli_show_isis_overload, + .modify = isis_instance_overload_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/metric-style", + .cbs = { + .cli_show = cli_show_isis_metric_style, + .modify = isis_instance_metric_style_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/purge-originator", + .cbs = { + .cli_show = cli_show_isis_purge_origin, + .modify = isis_instance_purge_originator_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/mtu", + .cbs = { + .cli_show = cli_show_isis_lsp_mtu, + .modify = isis_instance_lsp_mtu_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/refresh-interval", + .cbs = { + .cli_show = cli_show_isis_lsp_ref_interval, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/refresh-interval/level-1", + .cbs = { + .modify = isis_instance_lsp_refresh_interval_level_1_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/refresh-interval/level-2", + .cbs = { + .modify = isis_instance_lsp_refresh_interval_level_2_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime", + .cbs = { + .cli_show = cli_show_isis_lsp_max_lifetime, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-1", + .cbs = { + .modify = isis_instance_lsp_maximum_lifetime_level_1_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-2", + .cbs = { + .modify = isis_instance_lsp_maximum_lifetime_level_2_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/generation-interval", + .cbs = { + .cli_show = cli_show_isis_lsp_gen_interval, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/generation-interval/level-1", + .cbs = { + .modify = isis_instance_lsp_generation_interval_level_1_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/lsp/generation-interval/level-2", + .cbs = { + .modify = isis_instance_lsp_generation_interval_level_2_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay", + .cbs = { + .apply_finish = ietf_backoff_delay_apply_finish, + .cli_show = cli_show_isis_spf_ietf_backoff, + .create = isis_instance_spf_ietf_backoff_delay_create, + .destroy = isis_instance_spf_ietf_backoff_delay_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/init-delay", + .cbs = { + .modify = isis_instance_spf_ietf_backoff_delay_init_delay_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/short-delay", + .cbs = { + .modify = isis_instance_spf_ietf_backoff_delay_short_delay_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/long-delay", + .cbs = { + .modify = isis_instance_spf_ietf_backoff_delay_long_delay_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/hold-down", + .cbs = { + .modify = isis_instance_spf_ietf_backoff_delay_hold_down_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/time-to-learn", + .cbs = { + .modify = isis_instance_spf_ietf_backoff_delay_time_to_learn_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/spf/minimum-interval", + .cbs = { + .cli_show = cli_show_isis_spf_min_interval, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/spf/minimum-interval/level-1", + .cbs = { + .modify = isis_instance_spf_minimum_interval_level_1_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/spf/minimum-interval/level-2", + .cbs = { + .modify = isis_instance_spf_minimum_interval_level_2_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/area-password", + .cbs = { + .apply_finish = area_password_apply_finish, + .cli_show = cli_show_isis_area_pwd, + .create = isis_instance_area_password_create, + .destroy = isis_instance_area_password_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/area-password/password", + .cbs = { + .modify = isis_instance_area_password_password_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/area-password/password-type", + .cbs = { + .modify = isis_instance_area_password_password_type_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/area-password/authenticate-snp", + .cbs = { + .modify = isis_instance_area_password_authenticate_snp_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/domain-password", + .cbs = { + .apply_finish = domain_password_apply_finish, + .cli_show = cli_show_isis_domain_pwd, + .create = isis_instance_domain_password_create, + .destroy = isis_instance_domain_password_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/domain-password/password", + .cbs = { + .modify = isis_instance_domain_password_password_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/domain-password/password-type", + .cbs = { + .modify = isis_instance_domain_password_password_type_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/domain-password/authenticate-snp", + .cbs = { + .modify = isis_instance_domain_password_authenticate_snp_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4", + .cbs = { + .apply_finish = default_info_origin_ipv4_apply_finish, + .cli_show = cli_show_isis_def_origin_ipv4, + .create = isis_instance_default_information_originate_ipv4_create, + .destroy = isis_instance_default_information_originate_ipv4_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/always", + .cbs = { + .modify = isis_instance_default_information_originate_ipv4_always_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/route-map", + .cbs = { + .destroy = isis_instance_default_information_originate_ipv4_route_map_destroy, + .modify = isis_instance_default_information_originate_ipv4_route_map_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/metric", + .cbs = { + .modify = isis_instance_default_information_originate_ipv4_metric_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6", + .cbs = { + .apply_finish = default_info_origin_ipv6_apply_finish, + .cli_show = cli_show_isis_def_origin_ipv6, + .create = isis_instance_default_information_originate_ipv6_create, + .destroy = isis_instance_default_information_originate_ipv6_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/always", + .cbs = { + .modify = isis_instance_default_information_originate_ipv6_always_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/route-map", + .cbs = { + .destroy = isis_instance_default_information_originate_ipv6_route_map_destroy, + .modify = isis_instance_default_information_originate_ipv6_route_map_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/metric", + .cbs = { + .modify = isis_instance_default_information_originate_ipv6_metric_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/redistribute/ipv4", + .cbs = { + .apply_finish = redistribute_ipv4_apply_finish, + .cli_show = cli_show_isis_redistribute_ipv4, + .create = isis_instance_redistribute_ipv4_create, + .destroy = isis_instance_redistribute_ipv4_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/redistribute/ipv4/route-map", + .cbs = { + .destroy = isis_instance_redistribute_ipv4_route_map_destroy, + .modify = isis_instance_redistribute_ipv4_route_map_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/redistribute/ipv4/metric", + .cbs = { + .modify = isis_instance_redistribute_ipv4_metric_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/redistribute/ipv6", + .cbs = { + .apply_finish = redistribute_ipv6_apply_finish, + .cli_show = cli_show_isis_redistribute_ipv6, + .create = isis_instance_redistribute_ipv6_create, + .destroy = isis_instance_redistribute_ipv6_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/redistribute/ipv6/route-map", + .cbs = { + .destroy = isis_instance_redistribute_ipv6_route_map_destroy, + .modify = isis_instance_redistribute_ipv6_route_map_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/redistribute/ipv6/metric", + .cbs = { + .modify = isis_instance_redistribute_ipv6_metric_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-multicast", + .cbs = { + .cli_show = cli_show_isis_mt_ipv4_multicast, + .create = isis_instance_multi_topology_ipv4_multicast_create, + .destroy = isis_instance_multi_topology_ipv4_multicast_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-multicast/overload", + .cbs = { + .modify = isis_instance_multi_topology_ipv4_multicast_overload_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-management", + .cbs = { + .cli_show = cli_show_isis_mt_ipv4_mgmt, + .create = isis_instance_multi_topology_ipv4_management_create, + .destroy = isis_instance_multi_topology_ipv4_management_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-management/overload", + .cbs = { + .modify = isis_instance_multi_topology_ipv4_management_overload_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-unicast", + .cbs = { + .cli_show = cli_show_isis_mt_ipv6_unicast, + .create = isis_instance_multi_topology_ipv6_unicast_create, + .destroy = isis_instance_multi_topology_ipv6_unicast_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-unicast/overload", + .cbs = { + .modify = isis_instance_multi_topology_ipv6_unicast_overload_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-multicast", + .cbs = { + .cli_show = cli_show_isis_mt_ipv6_multicast, + .create = isis_instance_multi_topology_ipv6_multicast_create, + .destroy = isis_instance_multi_topology_ipv6_multicast_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-multicast/overload", + .cbs = { + .modify = isis_instance_multi_topology_ipv6_multicast_overload_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-management", + .cbs = { + .cli_show = cli_show_isis_mt_ipv6_mgmt, + .create = isis_instance_multi_topology_ipv6_management_create, + .destroy = isis_instance_multi_topology_ipv6_management_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-management/overload", + .cbs = { + .modify = isis_instance_multi_topology_ipv6_management_overload_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-dstsrc", + .cbs = { + .cli_show = cli_show_isis_mt_ipv6_dstsrc, + .create = isis_instance_multi_topology_ipv6_dstsrc_create, + .destroy = isis_instance_multi_topology_ipv6_dstsrc_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-dstsrc/overload", + .cbs = { + .modify = isis_instance_multi_topology_ipv6_dstsrc_overload_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/log-adjacency-changes", + .cbs = { + .cli_show = cli_show_isis_log_adjacency, + .modify = isis_instance_log_adjacency_changes_modify, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/mpls-te", + .cbs = { + .cli_show = cli_show_isis_mpls_te, + .create = isis_instance_mpls_te_create, + .destroy = isis_instance_mpls_te_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/mpls-te/router-address", + .cbs = { + .cli_show = cli_show_isis_mpls_te_router_addr, + .destroy = isis_instance_mpls_te_router_address_destroy, + .modify = isis_instance_mpls_te_router_address_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis", + .cbs = { + .create = lib_interface_isis_create, + .destroy = lib_interface_isis_destroy, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/area-tag", + .cbs = { + .modify = lib_interface_isis_area_tag_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/circuit-type", + .cbs = { + .cli_show = cli_show_ip_isis_circ_type, + .modify = lib_interface_isis_circuit_type_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/ipv4-routing", + .cbs = { + .cli_show = cli_show_ip_isis_ipv4, + .modify = lib_interface_isis_ipv4_routing_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/ipv6-routing", + .cbs = { + .cli_show = cli_show_ip_isis_ipv6, + .modify = lib_interface_isis_ipv6_routing_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring", + .cbs = { + .modify = lib_interface_isis_bfd_monitoring_modify, + .cli_show = cli_show_ip_isis_bfd_monitoring, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval", + .cbs = { + .cli_show = cli_show_ip_isis_csnp_interval, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1", + .cbs = { + .modify = lib_interface_isis_csnp_interval_level_1_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2", + .cbs = { + .modify = lib_interface_isis_csnp_interval_level_2_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval", + .cbs = { + .cli_show = cli_show_ip_isis_psnp_interval, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1", + .cbs = { + .modify = lib_interface_isis_psnp_interval_level_1_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2", + .cbs = { + .modify = lib_interface_isis_psnp_interval_level_2_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/padding", + .cbs = { + .cli_show = cli_show_ip_isis_hello_padding, + .modify = lib_interface_isis_hello_padding_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval", + .cbs = { + .cli_show = cli_show_ip_isis_hello_interval, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1", + .cbs = { + .modify = lib_interface_isis_hello_interval_level_1_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2", + .cbs = { + .modify = lib_interface_isis_hello_interval_level_2_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier", + .cbs = { + .cli_show = cli_show_ip_isis_hello_multi, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1", + .cbs = { + .modify = lib_interface_isis_hello_multiplier_level_1_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2", + .cbs = { + .modify = lib_interface_isis_hello_multiplier_level_2_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/metric", + .cbs = { + .cli_show = cli_show_ip_isis_metric, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/metric/level-1", + .cbs = { + .modify = lib_interface_isis_metric_level_1_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/metric/level-2", + .cbs = { + .modify = lib_interface_isis_metric_level_2_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority", + .cbs = { + .cli_show = cli_show_ip_isis_priority, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority/level-1", + .cbs = { + .modify = lib_interface_isis_priority_level_1_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority/level-2", + .cbs = { + .modify = lib_interface_isis_priority_level_2_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/network-type", + .cbs = { + .cli_show = cli_show_ip_isis_network_type, + .modify = lib_interface_isis_network_type_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/passive", + .cbs = { + .cli_show = cli_show_ip_isis_passive, + .modify = lib_interface_isis_passive_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/password", + .cbs = { + .cli_show = cli_show_ip_isis_password, + .create = lib_interface_isis_password_create, + .destroy = lib_interface_isis_password_destroy, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/password/password", + .cbs = { + .modify = lib_interface_isis_password_password_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/password/password-type", + .cbs = { + .modify = lib_interface_isis_password_password_type_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake", + .cbs = { + .cli_show = cli_show_ip_isis_threeway_shake, + .modify = lib_interface_isis_disable_three_way_handshake_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-unicast", + .cbs = { + .cli_show = cli_show_ip_isis_mt_ipv4_unicast, + .modify = lib_interface_isis_multi_topology_ipv4_unicast_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-multicast", + .cbs = { + .cli_show = cli_show_ip_isis_mt_ipv4_multicast, + .modify = lib_interface_isis_multi_topology_ipv4_multicast_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-management", + .cbs = { + .cli_show = cli_show_ip_isis_mt_ipv4_mgmt, + .modify = lib_interface_isis_multi_topology_ipv4_management_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-unicast", + .cbs = { + .cli_show = cli_show_ip_isis_mt_ipv6_unicast, + .modify = lib_interface_isis_multi_topology_ipv6_unicast_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-multicast", + .cbs = { + .cli_show = cli_show_ip_isis_mt_ipv6_multicast, + .modify = lib_interface_isis_multi_topology_ipv6_multicast_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-management", + .cbs = { + .cli_show = cli_show_ip_isis_mt_ipv6_mgmt, + .modify = lib_interface_isis_multi_topology_ipv6_management_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-dstsrc", + .cbs = { + .cli_show = cli_show_ip_isis_mt_ipv6_dstsrc, + .modify = lib_interface_isis_multi_topology_ipv6_dstsrc_modify, + }, + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency", + .cbs = { + .get_next = lib_interface_isis_adjacencies_adjacency_get_next, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sys-type", + .cbs = { + .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_sys_type_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sysid", + .cbs = { + .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_sysid_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-extended-circuit-id", + .cbs = { + .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-snpa", + .cbs = { + .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_snpa_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/hold-timer", + .cbs = { + .get_elem = lib_interface_isis_adjacencies_adjacency_hold_timer_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-priority", + .cbs = { + .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_priority_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/state", + .cbs = { + .get_elem = lib_interface_isis_adjacencies_adjacency_state_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-changes", + .cbs = { + .get_elem = lib_interface_isis_event_counters_adjacency_changes_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-number", + .cbs = { + .get_elem = lib_interface_isis_event_counters_adjacency_number_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/init-fails", + .cbs = { + .get_elem = lib_interface_isis_event_counters_init_fails_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-rejects", + .cbs = { + .get_elem = lib_interface_isis_event_counters_adjacency_rejects_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/id-len-mismatch", + .cbs = { + .get_elem = lib_interface_isis_event_counters_id_len_mismatch_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/max-area-addresses-mismatch", + .cbs = { + .get_elem = lib_interface_isis_event_counters_max_area_addresses_mismatch_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-type-fails", + .cbs = { + .get_elem = lib_interface_isis_event_counters_authentication_type_fails_get_elem, + } + }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-fails", + .cbs = { + .get_elem = lib_interface_isis_event_counters_authentication_fails_get_elem, + } + }, + { + .xpath = NULL, + }, + } +}; diff --git a/isisd/isis_nb.h b/isisd/isis_nb.h new file mode 100644 index 000000000..29a2ded0d --- /dev/null +++ b/isisd/isis_nb.h @@ -0,0 +1,548 @@ +/* + * Copyright (C) 2018 Volta Networks + * Emanuele Di Pascale + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef ISISD_ISIS_NB_H_ +#define ISISD_ISIS_NB_H_ + +extern const struct frr_yang_module_info frr_isisd_info; + +/* Forward declaration(s). */ +struct isis_area; +struct isis_circuit; +struct isis_adjacency; + +/* Mandatory callbacks. */ +int isis_instance_create(enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_destroy(enum nb_event event, const struct lyd_node *dnode); +int isis_instance_is_type_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_area_address_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_area_address_destroy(enum nb_event event, + const struct lyd_node *dnode); +int isis_instance_dynamic_hostname_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_attached_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_overload_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_metric_style_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_purge_originator_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_lsp_mtu_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_lsp_refresh_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_lsp_refresh_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_lsp_maximum_lifetime_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_lsp_maximum_lifetime_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_lsp_generation_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_lsp_generation_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_spf_ietf_backoff_delay_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_spf_ietf_backoff_delay_destroy(enum nb_event event, + const struct lyd_node *dnode); +int isis_instance_spf_ietf_backoff_delay_init_delay_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_spf_ietf_backoff_delay_short_delay_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_spf_ietf_backoff_delay_long_delay_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_spf_ietf_backoff_delay_hold_down_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_spf_minimum_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_spf_minimum_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_area_password_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_area_password_destroy(enum nb_event event, + const struct lyd_node *dnode); +int isis_instance_area_password_password_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_area_password_password_type_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_area_password_authenticate_snp_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_domain_password_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_domain_password_destroy(enum nb_event event, + const struct lyd_node *dnode); +int isis_instance_domain_password_password_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_domain_password_password_type_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_domain_password_authenticate_snp_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_default_information_originate_ipv4_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_default_information_originate_ipv4_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_default_information_originate_ipv4_always_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_default_information_originate_ipv4_route_map_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_default_information_originate_ipv4_route_map_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_default_information_originate_ipv4_metric_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_default_information_originate_ipv6_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_default_information_originate_ipv6_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_default_information_originate_ipv6_always_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_default_information_originate_ipv6_route_map_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_default_information_originate_ipv6_route_map_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_default_information_originate_ipv6_metric_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_redistribute_ipv4_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_redistribute_ipv4_destroy(enum nb_event event, + const struct lyd_node *dnode); +int isis_instance_redistribute_ipv4_route_map_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_redistribute_ipv4_route_map_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_redistribute_ipv4_metric_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_redistribute_ipv6_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_redistribute_ipv6_destroy(enum nb_event event, + const struct lyd_node *dnode); +int isis_instance_redistribute_ipv6_route_map_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_redistribute_ipv6_route_map_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_redistribute_ipv6_metric_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv4_multicast_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv4_multicast_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_multi_topology_ipv4_multicast_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv4_management_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv4_management_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_multi_topology_ipv4_management_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv6_unicast_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv6_unicast_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_multi_topology_ipv6_unicast_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv6_multicast_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv6_multicast_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_multi_topology_ipv6_multicast_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv6_management_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv6_management_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_multi_topology_ipv6_management_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv6_dstsrc_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_multi_topology_ipv6_dstsrc_destroy( + enum nb_event event, const struct lyd_node *dnode); +int isis_instance_multi_topology_ipv6_dstsrc_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_log_adjacency_changes_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_mpls_te_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_mpls_te_destroy(enum nb_event event, + const struct lyd_node *dnode); +int isis_instance_mpls_te_router_address_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int isis_instance_mpls_te_router_address_destroy(enum nb_event event, + const struct lyd_node *dnode); +int lib_interface_isis_create(enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_destroy(enum nb_event event, + const struct lyd_node *dnode); +int lib_interface_isis_area_tag_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_ipv4_routing_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_ipv6_routing_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_circuit_type_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_bfd_monitoring_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_csnp_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_csnp_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_psnp_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_psnp_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_hello_padding_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_hello_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_hello_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_hello_multiplier_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_hello_multiplier_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_metric_level_1_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_metric_level_2_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_priority_level_1_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_priority_level_2_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_network_type_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_passive_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_password_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_password_destroy(enum nb_event event, + const struct lyd_node *dnode); +int lib_interface_isis_password_password_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_password_password_type_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_disable_three_way_handshake_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_multi_topology_ipv4_unicast_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_multi_topology_ipv4_multicast_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_multi_topology_ipv4_management_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_multi_topology_ipv6_unicast_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_multi_topology_ipv6_multicast_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_multi_topology_ipv6_management_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +int lib_interface_isis_multi_topology_ipv6_dstsrc_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource); +const void * +lib_interface_isis_adjacencies_adjacency_get_next(const void *parent_list_entry, + const void *list_entry); +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_sys_type_get_elem( + const char *xpath, const void *list_entry); +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_sysid_get_elem( + const char *xpath, const void *list_entry); +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem( + const char *xpath, const void *list_entry); +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_snpa_get_elem( + const char *xpath, const void *list_entry); +struct yang_data *lib_interface_isis_adjacencies_adjacency_hold_timer_get_elem( + const char *xpath, const void *list_entry); +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_priority_get_elem( + const char *xpath, const void *list_entry); +struct yang_data * +lib_interface_isis_adjacencies_adjacency_state_get_elem(const char *xpath, + const void *list_entry); +struct yang_data *lib_interface_isis_event_counters_adjacency_changes_get_elem( + const char *xpath, const void *list_entry); +struct yang_data *lib_interface_isis_event_counters_adjacency_number_get_elem( + const char *xpath, const void *list_entry); +struct yang_data * +lib_interface_isis_event_counters_init_fails_get_elem(const char *xpath, + const void *list_entry); +struct yang_data *lib_interface_isis_event_counters_adjacency_rejects_get_elem( + const char *xpath, const void *list_entry); +struct yang_data *lib_interface_isis_event_counters_id_len_mismatch_get_elem( + const char *xpath, const void *list_entry); +struct yang_data * +lib_interface_isis_event_counters_max_area_addresses_mismatch_get_elem( + const char *xpath, const void *list_entry); +struct yang_data * +lib_interface_isis_event_counters_authentication_type_fails_get_elem( + const char *xpath, const void *list_entry); +struct yang_data * +lib_interface_isis_event_counters_authentication_fails_get_elem( + const char *xpath, const void *list_entry); + +/* Optional 'apply_finish' callbacks. */ +void ietf_backoff_delay_apply_finish(const struct lyd_node *dnode); +void area_password_apply_finish(const struct lyd_node *dnode); +void domain_password_apply_finish(const struct lyd_node *dnode); +void default_info_origin_apply_finish(const struct lyd_node *dnode, int family); +void default_info_origin_ipv4_apply_finish(const struct lyd_node *dnode); +void default_info_origin_ipv6_apply_finish(const struct lyd_node *dnode); +void redistribute_apply_finish(const struct lyd_node *dnode, int family); +void redistribute_ipv4_apply_finish(const struct lyd_node *dnode); +void redistribute_ipv6_apply_finish(const struct lyd_node *dnode); + +/* Optional 'cli_show' callbacks. */ +void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_ipv4(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_bfd_monitoring(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_area_address(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_is_type(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_dynamic_hostname(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_attached(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_overload(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_metric_style(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_area_pwd(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_domain_pwd(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_lsp_gen_interval(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_lsp_ref_interval(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_lsp_max_lifetime(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_lsp_mtu(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_spf_min_interval(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_spf_ietf_backoff(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_purge_origin(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_mpls_te(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_mpls_te_router_addr(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_def_origin_ipv4(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_def_origin_ipv6(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_redistribute_ipv4(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_redistribute_ipv6(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_passive(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_password(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_metric(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_hello_interval(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_hello_multi(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_threeway_shake(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_hello_padding(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_csnp_interval(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_psnp_interval(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_mt_ipv4_unicast(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_ip_isis_priority(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); +void cli_show_isis_log_adjacency(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); + +/* Notifications. */ +void isis_notif_db_overload(const struct isis_area *area, bool overload); +void isis_notif_lsp_too_large(const struct isis_circuit *circuit, + uint32_t pdu_size, const char *lsp_id); +void isis_notif_if_state_change(const struct isis_circuit *circuit, bool down); +void isis_notif_corrupted_lsp(const struct isis_area *area, + const char *lsp_id); /* currently unused */ +void isis_notif_lsp_exceed_max(const struct isis_area *area, + const char *lsp_id); +void isis_notif_max_area_addr_mismatch(const struct isis_circuit *circuit, + uint8_t max_area_addrs, + const char *raw_pdu); +void isis_notif_authentication_type_failure(const struct isis_circuit *circuit, + const char *raw_pdu); +void isis_notif_authentication_failure(const struct isis_circuit *circuit, + const char *raw_pdu); +void isis_notif_adj_state_change(const struct isis_adjacency *adj, + int new_state, const char *reason); +void isis_notif_reject_adjacency(const struct isis_circuit *circuit, + const char *reason, const char *raw_pdu); +void isis_notif_area_mismatch(const struct isis_circuit *circuit, + const char *raw_pdu); +void isis_notif_lsp_received(const struct isis_circuit *circuit, + const char *lsp_id, uint32_t seqno, + uint32_t timestamp, const char *sys_id); +void isis_notif_lsp_gen(const struct isis_area *area, const char *lsp_id, + uint32_t seqno, uint32_t timestamp); +void isis_notif_id_len_mismatch(const struct isis_circuit *circuit, + uint8_t rcv_id_len, const char *raw_pdu); +void isis_notif_version_skew(const struct isis_circuit *circuit, + uint8_t version, const char *raw_pdu); +void isis_notif_lsp_error(const struct isis_circuit *circuit, + const char *lsp_id, const char *raw_pdu, + uint32_t offset, uint8_t tlv_type); +void isis_notif_seqno_skipped(const struct isis_circuit *circuit, + const char *lsp_id); +void isis_notif_own_lsp_purge(const struct isis_circuit *circuit, + const char *lsp_id); + +#endif /* ISISD_ISIS_NB_H_ */ diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c new file mode 100644 index 000000000..820cfaa42 --- /dev/null +++ b/isisd/isis_nb_config.c @@ -0,0 +1,2236 @@ +/* + * Copyright (C) 2001,2002 Sampo Saaristo + * Tampere University of Technology + * Institute of Communications Engineering + * Copyright (C) 2018 Volta Networks + * Emanuele Di Pascale + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <zebra.h> + +#include "northbound.h" +#include "linklist.h" +#include "log.h" +#include "bfd.h" +#include "spf_backoff.h" +#include "lib_errors.h" +#include "vrf.h" + +#include "isisd/isisd.h" +#include "isisd/isis_nb.h" +#include "isisd/isis_common.h" +#include "isisd/isis_bfd.h" +#include "isisd/isis_circuit.h" +#include "isisd/isis_lsp.h" +#include "isisd/isis_dynhn.h" +#include "isisd/isis_misc.h" +#include "isisd/isis_csm.h" +#include "isisd/isis_adjacency.h" +#include "isisd/isis_spf.h" +#include "isisd/isis_te.h" +#include "isisd/isis_memory.h" +#include "isisd/isis_mt.h" +#include "isisd/isis_redist.h" + +/* + * XPath: /frr-isisd:isis/instance + */ +int isis_instance_create(enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + const char *area_tag; + + if (event != NB_EV_APPLY) + return NB_OK; + + area_tag = yang_dnode_get_string(dnode, "./area-tag"); + area = isis_area_lookup(area_tag); + if (area) + return NB_ERR_INCONSISTENCY; + + area = isis_area_create(area_tag); + /* save area in dnode to avoid looking it up all the time */ + nb_running_set_entry(dnode, area); + + return NB_OK; +} + +int isis_instance_destroy(enum nb_event event, const struct lyd_node *dnode) +{ + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_unset_entry(dnode); + isis_area_destroy(area->area_tag); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/is-type + */ +int isis_instance_is_type_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + int type; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + type = yang_dnode_get_enum(dnode, NULL); + isis_area_is_type_set(area, type); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/area-address + */ +int isis_instance_area_address_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + struct area_addr addr, *addrr = NULL, *addrp = NULL; + struct listnode *node; + uint8_t buff[255]; + const char *net_title = yang_dnode_get_string(dnode, NULL); + + switch (event) { + case NB_EV_VALIDATE: + addr.addr_len = dotformat2buff(buff, net_title); + memcpy(addr.area_addr, buff, addr.addr_len); + if (addr.area_addr[addr.addr_len - 1] != 0) { + flog_warn( + EC_LIB_NB_CB_CONFIG_VALIDATE, + "nsel byte (last byte) in area address must be 0"); + return NB_ERR_VALIDATION; + } + if (isis->sysid_set) { + /* Check that the SystemID portions match */ + if (memcmp(isis->sysid, GETSYSID((&addr)), + ISIS_SYS_ID_LEN)) { + flog_warn( + EC_LIB_NB_CB_CONFIG_VALIDATE, + "System ID must not change when defining additional area addresses"); + return NB_ERR_VALIDATION; + } + } + break; + case NB_EV_PREPARE: + addrr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct area_addr)); + addrr->addr_len = dotformat2buff(buff, net_title); + memcpy(addrr->area_addr, buff, addrr->addr_len); + resource->ptr = addrr; + break; + case NB_EV_ABORT: + XFREE(MTYPE_ISIS_AREA_ADDR, resource->ptr); + break; + case NB_EV_APPLY: + area = nb_running_get_entry(dnode, NULL, true); + addrr = resource->ptr; + + if (isis->sysid_set == 0) { + /* + * First area address - get the SystemID for this router + */ + memcpy(isis->sysid, GETSYSID(addrr), ISIS_SYS_ID_LEN); + isis->sysid_set = 1; + } else { + /* check that we don't already have this address */ + for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, + addrp)) { + if ((addrp->addr_len + ISIS_SYS_ID_LEN + + ISIS_NSEL_LEN) + != (addrr->addr_len)) + continue; + if (!memcmp(addrp->area_addr, addrr->area_addr, + addrr->addr_len)) { + XFREE(MTYPE_ISIS_AREA_ADDR, addrr); + return NB_OK; /* silent fail */ + } + } + } + + /*Forget the systemID part of the address */ + addrr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN); + assert(area->area_addrs); /* to silence scan-build sillyness */ + listnode_add(area->area_addrs, addrr); + + /* only now we can safely generate our LSPs for this area */ + if (listcount(area->area_addrs) > 0) { + if (area->is_type & IS_LEVEL_1) + lsp_generate(area, IS_LEVEL_1); + if (area->is_type & IS_LEVEL_2) + lsp_generate(area, IS_LEVEL_2); + } + break; + } + + return NB_OK; +} + +int isis_instance_area_address_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct area_addr addr, *addrp = NULL; + struct listnode *node; + uint8_t buff[255]; + struct isis_area *area; + const char *net_title; + + if (event != NB_EV_APPLY) + return NB_OK; + + net_title = yang_dnode_get_string(dnode, NULL); + addr.addr_len = dotformat2buff(buff, net_title); + memcpy(addr.area_addr, buff, (int)addr.addr_len); + area = nb_running_get_entry(dnode, NULL, true); + for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) { + if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len + && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len)) + break; + } + if (!addrp) + return NB_ERR_INCONSISTENCY; + + listnode_delete(area->area_addrs, addrp); + XFREE(MTYPE_ISIS_AREA_ADDR, addrp); + /* + * Last area address - reset the SystemID for this router + */ + if (listcount(area->area_addrs) == 0) { + memset(isis->sysid, 0, ISIS_SYS_ID_LEN); + isis->sysid_set = 0; + if (isis->debugs & DEBUG_EVENTS) + zlog_debug("Router has no SystemID"); + } + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/dynamic-hostname + */ +int isis_instance_dynamic_hostname_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + isis_area_dynhostname_set(area, yang_dnode_get_bool(dnode, NULL)); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/attached + */ +int isis_instance_attached_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + bool attached; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + attached = yang_dnode_get_bool(dnode, NULL); + isis_area_attached_bit_set(area, attached); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/overload + */ +int isis_instance_overload_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + bool overload; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + overload = yang_dnode_get_bool(dnode, NULL); + isis_area_overload_bit_set(area, overload); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/metric-style + */ +int isis_instance_metric_style_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + bool old_metric, new_metric; + enum isis_metric_style metric_style = yang_dnode_get_enum(dnode, NULL); + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + old_metric = (metric_style == ISIS_WIDE_METRIC) ? false : true; + new_metric = (metric_style == ISIS_NARROW_METRIC) ? false : true; + isis_area_metricstyle_set(area, old_metric, new_metric); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/purge-originator + */ +int isis_instance_purge_originator_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + area->purge_originator = yang_dnode_get_bool(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/lsp/mtu + */ +int isis_instance_lsp_mtu_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct listnode *node; + struct isis_circuit *circuit; + uint16_t lsp_mtu = yang_dnode_get_uint16(dnode, NULL); + struct isis_area *area; + + switch (event) { + case NB_EV_VALIDATE: + area = nb_running_get_entry(dnode, NULL, false); + if (!area) + break; + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + if (circuit->state != C_STATE_INIT + && circuit->state != C_STATE_UP) + continue; + if (lsp_mtu > isis_circuit_pdu_size(circuit)) { + flog_warn( + EC_LIB_NB_CB_CONFIG_VALIDATE, + "ISIS area contains circuit %s, which has a maximum PDU size of %zu", + circuit->interface->name, + isis_circuit_pdu_size(circuit)); + return NB_ERR_VALIDATION; + } + } + break; + case NB_EV_PREPARE: + case NB_EV_ABORT: + break; + case NB_EV_APPLY: + area = nb_running_get_entry(dnode, NULL, true); + isis_area_lsp_mtu_set(area, lsp_mtu); + break; + } + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/lsp/refresh-interval/level-1 + */ +int isis_instance_lsp_refresh_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + uint16_t refr_int; + + if (event != NB_EV_APPLY) + return NB_OK; + + refr_int = yang_dnode_get_uint16(dnode, NULL); + area = nb_running_get_entry(dnode, NULL, true); + isis_area_lsp_refresh_set(area, IS_LEVEL_1, refr_int); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/lsp/refresh-interval/level-2 + */ +int isis_instance_lsp_refresh_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + uint16_t refr_int; + + if (event != NB_EV_APPLY) + return NB_OK; + + refr_int = yang_dnode_get_uint16(dnode, NULL); + area = nb_running_get_entry(dnode, NULL, true); + isis_area_lsp_refresh_set(area, IS_LEVEL_2, refr_int); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/lsp/maximum-lifetime/level-1 + */ +int isis_instance_lsp_maximum_lifetime_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + uint16_t max_lt; + + if (event != NB_EV_APPLY) + return NB_OK; + + max_lt = yang_dnode_get_uint16(dnode, NULL); + area = nb_running_get_entry(dnode, NULL, true); + isis_area_max_lsp_lifetime_set(area, IS_LEVEL_1, max_lt); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/lsp/maximum-lifetime/level-2 + */ +int isis_instance_lsp_maximum_lifetime_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + uint16_t max_lt; + + if (event != NB_EV_APPLY) + return NB_OK; + + max_lt = yang_dnode_get_uint16(dnode, NULL); + area = nb_running_get_entry(dnode, NULL, true); + isis_area_max_lsp_lifetime_set(area, IS_LEVEL_2, max_lt); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/lsp/generation-interval/level-1 + */ +int isis_instance_lsp_generation_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + uint16_t gen_int; + + if (event != NB_EV_APPLY) + return NB_OK; + + gen_int = yang_dnode_get_uint16(dnode, NULL); + area = nb_running_get_entry(dnode, NULL, true); + area->lsp_gen_interval[0] = gen_int; + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/lsp/generation-interval/level-2 + */ +int isis_instance_lsp_generation_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + uint16_t gen_int; + + if (event != NB_EV_APPLY) + return NB_OK; + + gen_int = yang_dnode_get_uint16(dnode, NULL); + area = nb_running_get_entry(dnode, NULL, true); + area->lsp_gen_interval[1] = gen_int; + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay + */ +void ietf_backoff_delay_apply_finish(const struct lyd_node *dnode) +{ + long init_delay = yang_dnode_get_uint16(dnode, "./init-delay"); + long short_delay = yang_dnode_get_uint16(dnode, "./short-delay"); + long long_delay = yang_dnode_get_uint16(dnode, "./long-delay"); + long holddown = yang_dnode_get_uint16(dnode, "./hold-down"); + long timetolearn = yang_dnode_get_uint16(dnode, "./time-to-learn"); + struct isis_area *area = nb_running_get_entry(dnode, NULL, true); + size_t bufsiz = strlen(area->area_tag) + sizeof("IS-IS Lx"); + char *buf = XCALLOC(MTYPE_TMP, bufsiz); + + snprintf(buf, bufsiz, "IS-IS %s L1", area->area_tag); + spf_backoff_free(area->spf_delay_ietf[0]); + area->spf_delay_ietf[0] = + spf_backoff_new(master, buf, init_delay, short_delay, + long_delay, holddown, timetolearn); + + snprintf(buf, bufsiz, "IS-IS %s L2", area->area_tag); + spf_backoff_free(area->spf_delay_ietf[1]); + area->spf_delay_ietf[1] = + spf_backoff_new(master, buf, init_delay, short_delay, + long_delay, holddown, timetolearn); + + XFREE(MTYPE_TMP, buf); +} + +int isis_instance_spf_ietf_backoff_delay_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* All the work is done in the apply_finish */ + return NB_OK; +} + +int isis_instance_spf_ietf_backoff_delay_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + spf_backoff_free(area->spf_delay_ietf[0]); + spf_backoff_free(area->spf_delay_ietf[1]); + area->spf_delay_ietf[0] = NULL; + area->spf_delay_ietf[1] = NULL; + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/init-delay + */ +int isis_instance_spf_ietf_backoff_delay_init_delay_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* All the work is done in the apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/short-delay + */ +int isis_instance_spf_ietf_backoff_delay_short_delay_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* All the work is done in the apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/long-delay + */ +int isis_instance_spf_ietf_backoff_delay_long_delay_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* All the work is done in the apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/hold-down + */ +int isis_instance_spf_ietf_backoff_delay_hold_down_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* All the work is done in the apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/time-to-learn + */ +int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* All the work is done in the apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/spf/minimum-interval/level-1 + */ +int isis_instance_spf_minimum_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + area->min_spf_interval[0] = yang_dnode_get_uint16(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/spf/minimum-interval/level-2 + */ +int isis_instance_spf_minimum_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + area->min_spf_interval[1] = yang_dnode_get_uint16(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/area-password + */ +void area_password_apply_finish(const struct lyd_node *dnode) +{ + const char *password = yang_dnode_get_string(dnode, "./password"); + struct isis_area *area = nb_running_get_entry(dnode, NULL, true); + int pass_type = yang_dnode_get_enum(dnode, "./password-type"); + uint8_t snp_auth = yang_dnode_get_enum(dnode, "./authenticate-snp"); + + switch (pass_type) { + case ISIS_PASSWD_TYPE_CLEARTXT: + isis_area_passwd_cleartext_set(area, IS_LEVEL_1, password, + snp_auth); + break; + case ISIS_PASSWD_TYPE_HMAC_MD5: + isis_area_passwd_hmac_md5_set(area, IS_LEVEL_1, password, + snp_auth); + break; + } +} + +int isis_instance_area_password_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* actual setting is done in apply_finish */ + return NB_OK; +} + +int isis_instance_area_password_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + isis_area_passwd_unset(area, IS_LEVEL_1); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/area-password/password + */ +int isis_instance_area_password_password_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* actual setting is done in apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/area-password/password-type + */ +int isis_instance_area_password_password_type_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* actual setting is done in apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/area-password/authenticate-snp + */ +int isis_instance_area_password_authenticate_snp_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* actual setting is done in apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/domain-password + */ +void domain_password_apply_finish(const struct lyd_node *dnode) +{ + const char *password = yang_dnode_get_string(dnode, "./password"); + struct isis_area *area = nb_running_get_entry(dnode, NULL, true); + int pass_type = yang_dnode_get_enum(dnode, "./password-type"); + uint8_t snp_auth = yang_dnode_get_enum(dnode, "./authenticate-snp"); + + switch (pass_type) { + case ISIS_PASSWD_TYPE_CLEARTXT: + isis_area_passwd_cleartext_set(area, IS_LEVEL_2, password, + snp_auth); + break; + case ISIS_PASSWD_TYPE_HMAC_MD5: + isis_area_passwd_hmac_md5_set(area, IS_LEVEL_2, password, + snp_auth); + break; + } +} + +int isis_instance_domain_password_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* actual setting is done in apply_finish */ + return NB_OK; +} + +int isis_instance_domain_password_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + isis_area_passwd_unset(area, IS_LEVEL_2); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/domain-password/password + */ +int isis_instance_domain_password_password_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* actual setting is done in apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/domain-password/password-type + */ +int isis_instance_domain_password_password_type_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* actual setting is done in apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/domain-password/authenticate-snp + */ +int isis_instance_domain_password_authenticate_snp_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* actual setting is done in apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4 + */ +void default_info_origin_apply_finish(const struct lyd_node *dnode, int family) +{ + int originate_type = DEFAULT_ORIGINATE; + unsigned long metric = 0; + const char *routemap = NULL; + struct isis_area *area = nb_running_get_entry(dnode, NULL, true); + int level = yang_dnode_get_enum(dnode, "./level"); + + if (yang_dnode_get_bool(dnode, "./always")) { + originate_type = DEFAULT_ORIGINATE_ALWAYS; + } else if (family == AF_INET6) { + zlog_warn( + "%s: Zebra doesn't implement default-originate for IPv6 yet, so use with care or use default-originate always.", + __func__); + } + + if (yang_dnode_exists(dnode, "./metric")) + metric = yang_dnode_get_uint32(dnode, "./metric"); + if (yang_dnode_exists(dnode, "./route-map")) + routemap = yang_dnode_get_string(dnode, "./route-map"); + + isis_redist_set(area, level, family, DEFAULT_ROUTE, metric, routemap, + originate_type); +} + +void default_info_origin_ipv4_apply_finish(const struct lyd_node *dnode) +{ + default_info_origin_apply_finish(dnode, AF_INET); +} + +void default_info_origin_ipv6_apply_finish(const struct lyd_node *dnode) +{ + default_info_origin_apply_finish(dnode, AF_INET6); +} + +int isis_instance_default_information_originate_ipv4_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +int isis_instance_default_information_originate_ipv4_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + struct isis_area *area; + int level; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + level = yang_dnode_get_enum(dnode, "./level"); + isis_redist_unset(area, level, AF_INET, DEFAULT_ROUTE); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/always + */ +int isis_instance_default_information_originate_ipv4_always_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/route-map + */ +int isis_instance_default_information_originate_ipv4_route_map_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +int isis_instance_default_information_originate_ipv4_route_map_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/metric + */ +int isis_instance_default_information_originate_ipv4_metric_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6 + */ +int isis_instance_default_information_originate_ipv6_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +int isis_instance_default_information_originate_ipv6_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + struct isis_area *area; + int level; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + level = yang_dnode_get_enum(dnode, "./level"); + isis_redist_unset(area, level, AF_INET6, DEFAULT_ROUTE); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/always + */ +int isis_instance_default_information_originate_ipv6_always_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/route-map + */ +int isis_instance_default_information_originate_ipv6_route_map_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +int isis_instance_default_information_originate_ipv6_route_map_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/metric + */ +int isis_instance_default_information_originate_ipv6_metric_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by default_info_origin_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/redistribute/ipv4 + */ +void redistribute_apply_finish(const struct lyd_node *dnode, int family) +{ + assert(family == AF_INET || family == AF_INET6); + int type, level; + unsigned long metric = 0; + const char *routemap = NULL; + struct isis_area *area; + + type = yang_dnode_get_enum(dnode, "./protocol"); + level = yang_dnode_get_enum(dnode, "./level"); + area = nb_running_get_entry(dnode, NULL, true); + + if (yang_dnode_exists(dnode, "./metric")) + metric = yang_dnode_get_uint32(dnode, "./metric"); + if (yang_dnode_exists(dnode, "./route-map")) + routemap = yang_dnode_get_string(dnode, "./route-map"); + + isis_redist_set(area, level, family, type, metric, routemap, 0); +} + +void redistribute_ipv4_apply_finish(const struct lyd_node *dnode) +{ + redistribute_apply_finish(dnode, AF_INET); +} + +void redistribute_ipv6_apply_finish(const struct lyd_node *dnode) +{ + redistribute_apply_finish(dnode, AF_INET6); +} + +int isis_instance_redistribute_ipv4_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by redistribute_apply_finish */ + return NB_OK; +} + +int isis_instance_redistribute_ipv4_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct isis_area *area; + int level, type; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + level = yang_dnode_get_enum(dnode, "./level"); + type = yang_dnode_get_enum(dnode, "./protocol"); + isis_redist_unset(area, level, AF_INET, type); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/redistribute/ipv4/route-map + */ +int isis_instance_redistribute_ipv4_route_map_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by redistribute_apply_finish */ + return NB_OK; +} + +int isis_instance_redistribute_ipv4_route_map_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + /* It's all done by redistribute_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/redistribute/ipv4/metric + */ +int isis_instance_redistribute_ipv4_metric_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by redistribute_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/redistribute/ipv6 + */ +int isis_instance_redistribute_ipv6_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by redistribute_apply_finish */ + return NB_OK; +} + +int isis_instance_redistribute_ipv6_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct isis_area *area; + int level, type; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + level = yang_dnode_get_enum(dnode, "./level"); + type = yang_dnode_get_enum(dnode, "./protocol"); + isis_redist_unset(area, level, AF_INET6, type); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/redistribute/ipv6/route-map + */ +int isis_instance_redistribute_ipv6_route_map_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by redistribute_apply_finish */ + return NB_OK; +} + +int isis_instance_redistribute_ipv6_route_map_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + /* It's all done by redistribute_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/redistribute/ipv6/metric + */ +int isis_instance_redistribute_ipv6_metric_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + /* It's all done by redistribute_apply_finish */ + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-multicast + */ +static int isis_multi_topology_common(enum nb_event event, + const struct lyd_node *dnode, + const char *topology, bool create) +{ + struct isis_area *area; + struct isis_area_mt_setting *setting; + uint16_t mtid = isis_str2mtid(topology); + + switch (event) { + case NB_EV_VALIDATE: + if (mtid == (uint16_t)-1) { + flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, + "Unknown topology %s", topology); + return NB_ERR_VALIDATION; + } + break; + case NB_EV_PREPARE: + case NB_EV_ABORT: + break; + case NB_EV_APPLY: + area = nb_running_get_entry(dnode, NULL, true); + setting = area_get_mt_setting(area, mtid); + setting->enabled = create; + lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); + break; + } + + return NB_OK; +} + +static int isis_multi_topology_overload_common(enum nb_event event, + const struct lyd_node *dnode, + const char *topology) +{ + struct isis_area *area; + struct isis_area_mt_setting *setting; + uint16_t mtid = isis_str2mtid(topology); + + /* validation is done in isis_multi_topology_common */ + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + setting = area_get_mt_setting(area, mtid); + setting->overload = yang_dnode_get_bool(dnode, NULL); + if (setting->enabled) + lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); + + return NB_OK; +} + +int isis_instance_multi_topology_ipv4_multicast_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_common(event, dnode, "ipv4-multicast", true); +} + +int isis_instance_multi_topology_ipv4_multicast_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + return isis_multi_topology_common(event, dnode, "ipv4-multicast", + false); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-multicast/overload + */ +int isis_instance_multi_topology_ipv4_multicast_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_overload_common(event, dnode, + "ipv4-multicast"); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-management + */ +int isis_instance_multi_topology_ipv4_management_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_common(event, dnode, "ipv4-mgmt", true); +} + +int isis_instance_multi_topology_ipv4_management_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + return isis_multi_topology_common(event, dnode, "ipv4-mgmt", false); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-management/overload + */ +int isis_instance_multi_topology_ipv4_management_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_overload_common(event, dnode, "ipv4-mgmt"); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-unicast + */ +int isis_instance_multi_topology_ipv6_unicast_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_common(event, dnode, "ipv6-unicast", true); +} + +int isis_instance_multi_topology_ipv6_unicast_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + return isis_multi_topology_common(event, dnode, "ipv6-unicast", false); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-unicast/overload + */ +int isis_instance_multi_topology_ipv6_unicast_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_overload_common(event, dnode, + "ipv6-unicast"); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-multicast + */ +int isis_instance_multi_topology_ipv6_multicast_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_common(event, dnode, "ipv6-multicast", true); +} + +int isis_instance_multi_topology_ipv6_multicast_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + return isis_multi_topology_common(event, dnode, "ipv6-multicast", + false); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-multicast/overload + */ +int isis_instance_multi_topology_ipv6_multicast_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_overload_common(event, dnode, + "ipv6-multicast"); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-management + */ +int isis_instance_multi_topology_ipv6_management_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_common(event, dnode, "ipv6-mgmt", true); +} + +int isis_instance_multi_topology_ipv6_management_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + return isis_multi_topology_common(event, dnode, "ipv6-mgmt", false); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-management/overload + */ +int isis_instance_multi_topology_ipv6_management_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_overload_common(event, dnode, "ipv6-mgmt"); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-dstsrc + */ +int isis_instance_multi_topology_ipv6_dstsrc_create( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_common(event, dnode, "ipv6-dstsrc", true); +} + +int isis_instance_multi_topology_ipv6_dstsrc_destroy( + enum nb_event event, const struct lyd_node *dnode) +{ + return isis_multi_topology_common(event, dnode, "ipv6-dstsrc", false); +} + +/* + * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-dstsrc/overload + */ +int isis_instance_multi_topology_ipv6_dstsrc_overload_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return isis_multi_topology_overload_common(event, dnode, "ipv6-dstsrc"); +} + +/* + * XPath: /frr-isisd:isis/instance/log-adjacency-changes + */ +int isis_instance_log_adjacency_changes_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + bool log = yang_dnode_get_bool(dnode, NULL); + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + area->log_adj_changes = log ? 1 : 0; + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/mpls-te + */ +int isis_instance_mpls_te_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct listnode *node; + struct isis_area *area; + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + if (area->mta == NULL) { + + struct mpls_te_area *new; + + zlog_debug("ISIS-TE(%s): Initialize MPLS Traffic Engineering", + area->area_tag); + + new = XCALLOC(MTYPE_ISIS_MPLS_TE, sizeof(struct mpls_te_area)); + + /* Initialize MPLS_TE structure */ + new->status = enable; + new->level = 0; + new->inter_as = off; + new->interas_areaid.s_addr = 0; + new->router_id.s_addr = 0; + + area->mta = new; + } else { + area->mta->status = enable; + } + + /* Update Extended TLVs according to Interface link parameters */ + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) + isis_link_params_update(circuit, circuit->interface); + + /* Reoriginate STD_TE & GMPLS circuits */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +int isis_instance_mpls_te_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct listnode *node; + struct isis_area *area; + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + if (IS_MPLS_TE(area->mta)) + area->mta->status = disable; + else + return NB_OK; + + /* Flush LSP if circuit engage */ + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + if (!IS_EXT_TE(circuit->ext)) + continue; + + /* disable MPLS_TE Circuit keeping SR one's */ + if (IS_SUBTLV(circuit->ext, EXT_ADJ_SID)) + circuit->ext->status = EXT_ADJ_SID; + else if (IS_SUBTLV(circuit->ext, EXT_LAN_ADJ_SID)) + circuit->ext->status = EXT_LAN_ADJ_SID; + else + circuit->ext->status = 0; + } + + /* Reoriginate STD_TE & GMPLS circuits */ + lsp_regenerate_schedule(area, area->is_type, 0); + + zlog_debug("ISIS-TE(%s): Disabled MPLS Traffic Engineering", + area->area_tag); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/mpls-te/router-address + */ +int isis_instance_mpls_te_router_address_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct in_addr value; + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + /* only proceed if MPLS-TE is enabled */ + if (!IS_MPLS_TE(area->mta)) + return NB_OK; + + /* Update Area Router ID */ + yang_dnode_get_ipv4(&value, dnode, NULL); + area->mta->router_id.s_addr = value.s_addr; + + /* And re-schedule LSP update */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +int isis_instance_mpls_te_router_address_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct isis_area *area; + + if (event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(dnode, NULL, true); + /* only proceed if MPLS-TE is enabled */ + if (!IS_MPLS_TE(area->mta)) + return NB_OK; + + /* Reset Area Router ID */ + area->mta->router_id.s_addr = INADDR_ANY; + + /* And re-schedule LSP update */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis + */ +int lib_interface_isis_create(enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_area *area; + struct interface *ifp; + struct isis_circuit *circuit; + const char *area_tag = yang_dnode_get_string(dnode, "./area-tag"); + uint32_t min_mtu, actual_mtu; + + switch (event) { + case NB_EV_PREPARE: + case NB_EV_ABORT: + break; + case NB_EV_VALIDATE: + /* check if interface mtu is sufficient. If the area has not + * been created yet, assume default MTU for the area + */ + ifp = nb_running_get_entry(dnode, NULL, false); + /* zebra might not know yet about the MTU - nothing we can do */ + if (!ifp || ifp->mtu == 0) + break; + actual_mtu = + if_is_broadcast(ifp) ? ifp->mtu - LLC_LEN : ifp->mtu; + area = isis_area_lookup(area_tag); + if (area) + min_mtu = area->lsp_mtu; + else +#ifndef FABRICD + min_mtu = yang_get_default_uint16( + "/frr-isisd:isis/instance/lsp/mtu"); +#else + min_mtu = DEFAULT_LSP_MTU; +#endif /* ifndef FABRICD */ + if (actual_mtu < min_mtu) { + flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, + "Interface %s has MTU %" PRIu32 + ", minimum MTU for the area is %" PRIu32 "", + ifp->name, actual_mtu, min_mtu); + return NB_ERR_VALIDATION; + } + break; + case NB_EV_APPLY: + area = isis_area_lookup(area_tag); + /* The area should have already be created. We are + * setting the priority of the global isis area creation + * slightly lower, so it should be executed first, but I + * cannot rely on that so here I have to check. + */ + if (!area) { + flog_err( + EC_LIB_NB_CB_CONFIG_APPLY, + "%s: attempt to create circuit for area %s before the area has been created", + __func__, area_tag); + abort(); + } + + ifp = nb_running_get_entry(dnode, NULL, true); + circuit = isis_circuit_create(area, ifp); + assert(circuit + && (circuit->state == C_STATE_CONF + || circuit->state == C_STATE_UP)); + nb_running_set_entry(dnode, circuit); + break; + } + + return NB_OK; +} + +int lib_interface_isis_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_unset_entry(dnode); + if (!circuit) + return NB_ERR_INCONSISTENCY; + if (circuit->state == C_STATE_UP || circuit->state == C_STATE_CONF) + isis_csm_state_change(ISIS_DISABLE, circuit, circuit->area); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/area-tag + */ +int lib_interface_isis_area_tag_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + struct interface *ifp; + struct vrf *vrf; + const char *area_tag, *ifname, *vrfname; + + if (event == NB_EV_VALIDATE) { + /* libyang doesn't like relative paths across module boundaries + */ + ifname = yang_dnode_get_string(dnode->parent->parent, "./name"); + vrfname = yang_dnode_get_string(dnode->parent->parent, "./vrf"); + vrf = vrf_lookup_by_name(vrfname); + assert(vrf); + ifp = if_lookup_by_name(ifname, vrf->vrf_id); + if (!ifp) + return NB_OK; + circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list); + area_tag = yang_dnode_get_string(dnode, NULL); + if (circuit && circuit->area && circuit->area->area_tag + && strcmp(circuit->area->area_tag, area_tag)) { + flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, + "ISIS circuit is already defined on %s", + circuit->area->area_tag); + return NB_ERR_VALIDATION; + } + } + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/circuit-type + */ +int lib_interface_isis_circuit_type_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + int circ_type = yang_dnode_get_enum(dnode, NULL); + struct isis_circuit *circuit; + struct interface *ifp; + struct vrf *vrf; + const char *ifname, *vrfname; + + switch (event) { + case NB_EV_VALIDATE: + /* libyang doesn't like relative paths across module boundaries + */ + ifname = yang_dnode_get_string(dnode->parent->parent, "./name"); + vrfname = yang_dnode_get_string(dnode->parent->parent, "./vrf"); + vrf = vrf_lookup_by_name(vrfname); + assert(vrf); + ifp = if_lookup_by_name(ifname, vrf->vrf_id); + if (!ifp) + break; + circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list); + if (circuit && circuit->state == C_STATE_UP + && circuit->area->is_type != IS_LEVEL_1_AND_2 + && circuit->area->is_type != circ_type) { + flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, + "Invalid circuit level for area %s", + circuit->area->area_tag); + return NB_ERR_VALIDATION; + } + break; + case NB_EV_PREPARE: + case NB_EV_ABORT: + break; + case NB_EV_APPLY: + circuit = nb_running_get_entry(dnode, NULL, true); + isis_circuit_is_type_set(circuit, circ_type); + break; + } + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv4-routing + */ +int lib_interface_isis_ipv4_routing_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + bool ipv4, ipv6; + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + ipv4 = yang_dnode_get_bool(dnode, NULL); + ipv6 = yang_dnode_get_bool(dnode, "../ipv6-routing"); + isis_circuit_af_set(circuit, ipv4, ipv6); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv6-routing + */ +int lib_interface_isis_ipv6_routing_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + bool ipv4, ipv6; + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + ipv4 = yang_dnode_exists(dnode, "../ipv4-routing"); + ipv6 = yang_dnode_get_bool(dnode, NULL); + isis_circuit_af_set(circuit, ipv4, ipv6); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring + */ +int lib_interface_isis_bfd_monitoring_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + bool bfd_monitoring; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + bfd_monitoring = yang_dnode_get_bool(dnode, NULL); + + if (bfd_monitoring) { + isis_bfd_circuit_param_set(circuit, BFD_DEF_MIN_RX, + BFD_DEF_MIN_TX, BFD_DEF_DETECT_MULT, + true); + } else { + isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_DEREGISTER); + bfd_info_free(&circuit->bfd_info); + } + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1 + */ +int lib_interface_isis_csnp_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + circuit->csnp_interval[0] = yang_dnode_get_uint16(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2 + */ +int lib_interface_isis_csnp_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + circuit->csnp_interval[1] = yang_dnode_get_uint16(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1 + */ +int lib_interface_isis_psnp_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + circuit->psnp_interval[0] = yang_dnode_get_uint16(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2 + */ +int lib_interface_isis_psnp_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + circuit->psnp_interval[1] = yang_dnode_get_uint16(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/padding + */ +int lib_interface_isis_hello_padding_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + circuit->pad_hellos = yang_dnode_get_bool(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1 + */ +int lib_interface_isis_hello_interval_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + uint32_t interval; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + interval = yang_dnode_get_uint32(dnode, NULL); + circuit->hello_interval[0] = interval; + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2 + */ +int lib_interface_isis_hello_interval_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + uint32_t interval; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + interval = yang_dnode_get_uint32(dnode, NULL); + circuit->hello_interval[1] = interval; + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1 + */ +int lib_interface_isis_hello_multiplier_level_1_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + uint16_t multi; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + multi = yang_dnode_get_uint16(dnode, NULL); + circuit->hello_multiplier[0] = multi; + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2 + */ +int lib_interface_isis_hello_multiplier_level_2_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + uint16_t multi; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + multi = yang_dnode_get_uint16(dnode, NULL); + circuit->hello_multiplier[1] = multi; + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric/level-1 + */ +int lib_interface_isis_metric_level_1_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + unsigned int met; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + met = yang_dnode_get_uint32(dnode, NULL); + isis_circuit_metric_set(circuit, IS_LEVEL_1, met); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric/level-2 + */ +int lib_interface_isis_metric_level_2_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + unsigned int met; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + met = yang_dnode_get_uint32(dnode, NULL); + isis_circuit_metric_set(circuit, IS_LEVEL_2, met); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority/level-1 + */ +int lib_interface_isis_priority_level_1_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + circuit->priority[0] = yang_dnode_get_uint8(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority/level-2 + */ +int lib_interface_isis_priority_level_2_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + circuit->priority[1] = yang_dnode_get_uint8(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/network-type + */ +int lib_interface_isis_network_type_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + int net_type = yang_dnode_get_enum(dnode, NULL); + + switch (event) { + case NB_EV_VALIDATE: + circuit = nb_running_get_entry(dnode, NULL, false); + if (!circuit) + break; + if (circuit->circ_type == CIRCUIT_T_LOOPBACK) { + flog_warn( + EC_LIB_NB_CB_CONFIG_VALIDATE, + "Cannot change network type on loopback interface"); + return NB_ERR_VALIDATION; + } + if (net_type == CIRCUIT_T_BROADCAST + && circuit->state == C_STATE_UP + && !if_is_broadcast(circuit->interface)) { + flog_warn( + EC_LIB_NB_CB_CONFIG_VALIDATE, + "Cannot configure non-broadcast interface for broadcast operation"); + return NB_ERR_VALIDATION; + } + break; + case NB_EV_PREPARE: + case NB_EV_ABORT: + break; + case NB_EV_APPLY: + circuit = nb_running_get_entry(dnode, NULL, true); + isis_circuit_circ_type_set(circuit, net_type); + break; + } + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/passive + */ +int lib_interface_isis_passive_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + struct isis_area *area; + struct interface *ifp; + bool passive = yang_dnode_get_bool(dnode, NULL); + + /* validation only applies if we are setting passive to false */ + if (!passive && event == NB_EV_VALIDATE) { + circuit = nb_running_get_entry(dnode, NULL, false); + if (!circuit) + return NB_OK; + ifp = circuit->interface; + if (!ifp) + return NB_OK; + if (if_is_loopback(ifp)) { + flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, + "Loopback is always passive"); + return NB_ERR_VALIDATION; + } + } + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + if (circuit->state != C_STATE_UP) { + circuit->is_passive = passive; + } else { + area = circuit->area; + isis_csm_state_change(ISIS_DISABLE, circuit, area); + circuit->is_passive = passive; + isis_csm_state_change(ISIS_ENABLE, circuit, area); + } + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/password + */ +int lib_interface_isis_password_create(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + return NB_OK; +} + +int lib_interface_isis_password_destroy(enum nb_event event, + const struct lyd_node *dnode) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + isis_circuit_passwd_unset(circuit); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/password/password + */ +int lib_interface_isis_password_password_modify(enum nb_event event, + const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + const char *password; + + if (event != NB_EV_APPLY) + return NB_OK; + + password = yang_dnode_get_string(dnode, NULL); + circuit = nb_running_get_entry(dnode, NULL, true); + + isis_circuit_passwd_set(circuit, circuit->passwd.type, password); + + return NB_OK; +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/password/password-type + */ +int lib_interface_isis_password_password_type_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + uint8_t pass_type; + + if (event != NB_EV_APPLY) + return NB_OK; + + pass_type = yang_dnode_get_enum(dnode, NULL); + circuit = nb_running_get_entry(dnode, NULL, true); + circuit->passwd.type = pass_type; + + return NB_OK; +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake + */ +int lib_interface_isis_disable_three_way_handshake_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + struct isis_circuit *circuit; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = nb_running_get_entry(dnode, NULL, true); + circuit->disable_threeway_adj = yang_dnode_get_bool(dnode, NULL); + + return NB_OK; +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-unicast + */ +static int lib_interface_isis_multi_topology_common( + enum nb_event event, const struct lyd_node *dnode, uint16_t mtid) +{ + struct isis_circuit *circuit; + bool value; + + switch (event) { + case NB_EV_VALIDATE: + circuit = nb_running_get_entry(dnode, NULL, false); + if (circuit && circuit->area && circuit->area->oldmetric) { + flog_warn( + EC_LIB_NB_CB_CONFIG_VALIDATE, + "Multi topology IS-IS can only be used with wide metrics"); + return NB_ERR_VALIDATION; + } + break; + case NB_EV_PREPARE: + case NB_EV_ABORT: + break; + case NB_EV_APPLY: + circuit = nb_running_get_entry(dnode, NULL, true); + value = yang_dnode_get_bool(dnode, NULL); + isis_circuit_mt_enabled_set(circuit, mtid, value); + break; + } + + return NB_OK; +} + +int lib_interface_isis_multi_topology_ipv4_unicast_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return lib_interface_isis_multi_topology_common(event, dnode, + ISIS_MT_IPV4_UNICAST); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-multicast + */ +int lib_interface_isis_multi_topology_ipv4_multicast_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return lib_interface_isis_multi_topology_common(event, dnode, + ISIS_MT_IPV4_MULTICAST); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-management + */ +int lib_interface_isis_multi_topology_ipv4_management_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return lib_interface_isis_multi_topology_common(event, dnode, + ISIS_MT_IPV4_MGMT); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-unicast + */ +int lib_interface_isis_multi_topology_ipv6_unicast_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return lib_interface_isis_multi_topology_common(event, dnode, + ISIS_MT_IPV6_UNICAST); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-multicast + */ +int lib_interface_isis_multi_topology_ipv6_multicast_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return lib_interface_isis_multi_topology_common(event, dnode, + ISIS_MT_IPV6_MULTICAST); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-management + */ +int lib_interface_isis_multi_topology_ipv6_management_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return lib_interface_isis_multi_topology_common(event, dnode, + ISIS_MT_IPV6_MGMT); +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-dstsrc + */ +int lib_interface_isis_multi_topology_ipv6_dstsrc_modify( + enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + return lib_interface_isis_multi_topology_common(event, dnode, + ISIS_MT_IPV6_DSTSRC); +} diff --git a/isisd/isis_nb_notifications.c b/isisd/isis_nb_notifications.c new file mode 100644 index 000000000..ea33ec10e --- /dev/null +++ b/isisd/isis_nb_notifications.c @@ -0,0 +1,491 @@ +/* + * Copyright (C) 2018 Volta Networks + * Emanuele Di Pascale + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <zebra.h> + +#include "northbound.h" +#include "log.h" + +#include "isisd/isisd.h" +#include "isisd/isis_nb.h" +#include "isisd/isis_adjacency.h" +#include "isisd/isis_dynhn.h" +#include "isisd/isis_misc.h" + +/* + * Helper functions. + */ +static void notif_prep_instance_hdr(const char *xpath, + const struct isis_area *area, + const char *routing_instance, + struct list *args) +{ + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + + snprintf(xpath_arg, sizeof(xpath_arg), "%s/routing-instance", xpath); + data = yang_data_new_string(xpath_arg, routing_instance); + listnode_add(args, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/routing-protocol-name", + xpath); + data = yang_data_new_string(xpath_arg, area->area_tag); + listnode_add(args, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/isis-level", xpath); + data = yang_data_new_enum(xpath_arg, area->is_type); + listnode_add(args, data); +} + +static void notif_prepr_iface_hdr(const char *xpath, + const struct isis_circuit *circuit, + struct list *args) +{ + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + + snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath); + data = yang_data_new_string(xpath_arg, circuit->interface->name); + listnode_add(args, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-level", xpath); + data = yang_data_new_enum(xpath_arg, circuit->is_type); + listnode_add(args, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/extended-circuit-id", xpath); + /* we do not seem to have the extended version of the circuit_id */ + data = yang_data_new_uint32(xpath_arg, (uint32_t)circuit->circuit_id); + listnode_add(args, data); +} + +/* + * XPath: /frr-isisd:database-overload + */ +void isis_notif_db_overload(const struct isis_area *area, bool overload) +{ + const char *xpath = "/frr-isisd:database-overload"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/overload", xpath); + data = yang_data_new_enum(xpath_arg, !!overload); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:lsp-too-large + */ +void isis_notif_lsp_too_large(const struct isis_circuit *circuit, + uint32_t pdu_size, const char *lsp_id) +{ + const char *xpath = "/frr-isisd:lsp-too-large"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/pdu-size", xpath); + data = yang_data_new_uint32(xpath_arg, pdu_size); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); + data = yang_data_new_string(xpath_arg, lsp_id); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:if-state-change + */ +void isis_notif_if_state_change(const struct isis_circuit *circuit, bool down) +{ + const char *xpath = "/frr-isisd:if-state-change"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/state", xpath); + data = yang_data_new_enum(xpath_arg, !!down); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:corrupted-lsp-detected + */ +void isis_notif_corrupted_lsp(const struct isis_area *area, const char *lsp_id) +{ + const char *xpath = "/frr-isisd:corrupted-lsp-detected"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); + data = yang_data_new_string(xpath_arg, lsp_id); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:attempt-to-exceed-max-sequence + */ +void isis_notif_lsp_exceed_max(const struct isis_area *area, const char *lsp_id) +{ + const char *xpath = "/frr-isisd:attempt-to-exceed-max-sequence"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); + data = yang_data_new_string(xpath_arg, lsp_id); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:max-area-addresses-mismatch + */ +void isis_notif_max_area_addr_mismatch(const struct isis_circuit *circuit, + uint8_t max_area_addrs, + const char *raw_pdu) +{ + const char *xpath = "/frr-isisd:max-area-addresses-mismatch"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/max-area-addresses", xpath); + data = yang_data_new_uint8(xpath_arg, max_area_addrs); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); + data = yang_data_new(xpath_arg, raw_pdu); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:authentication-type-failure + */ +void isis_notif_authentication_type_failure(const struct isis_circuit *circuit, + const char *raw_pdu) +{ + const char *xpath = "/frr-isisd:authentication-type-failure"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); + data = yang_data_new(xpath_arg, raw_pdu); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:authentication-failure + */ +void isis_notif_authentication_failure(const struct isis_circuit *circuit, + const char *raw_pdu) +{ + const char *xpath = "/frr-isisd:authentication-failure"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); + data = yang_data_new(xpath_arg, raw_pdu); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:adjacency-state-change + */ +void isis_notif_adj_state_change(const struct isis_adjacency *adj, + int new_state, const char *reason) +{ + const char *xpath = "/frr-isisd:adjacency-state-change"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_circuit *circuit = adj->circuit; + struct isis_area *area = circuit->area; + struct isis_dynhn *dyn = dynhn_find_by_id(adj->sysid); + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + if (dyn) { + snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor", xpath); + data = yang_data_new_string(xpath_arg, dyn->hostname); + listnode_add(arguments, data); + } + snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor-system-id", xpath); + data = yang_data_new_string(xpath_arg, sysid_print(adj->sysid)); + listnode_add(arguments, data); + + snprintf(xpath_arg, sizeof(xpath_arg), "%s/state", xpath); + data = yang_data_new_string(xpath_arg, isis_adj_yang_state(new_state)); + listnode_add(arguments, data); + if (new_state == ISIS_ADJ_DOWN) { + snprintf(xpath_arg, sizeof(xpath_arg), "%s/reason", xpath); + data = yang_data_new_string(xpath_arg, reason); + listnode_add(arguments, data); + } + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:rejected-adjacency + */ +void isis_notif_reject_adjacency(const struct isis_circuit *circuit, + const char *reason, const char *raw_pdu) +{ + const char *xpath = "/frr-isisd:rejected-adjacency"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/reason", xpath); + data = yang_data_new_string(xpath_arg, reason); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); + data = yang_data_new(xpath_arg, raw_pdu); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:area-mismatch + */ +void isis_notif_area_mismatch(const struct isis_circuit *circuit, + const char *raw_pdu) +{ + const char *xpath = "/frr-isisd:area-mismatch"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); + data = yang_data_new(xpath_arg, raw_pdu); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:lsp-received + */ +void isis_notif_lsp_received(const struct isis_circuit *circuit, + const char *lsp_id, uint32_t seqno, + uint32_t timestamp, const char *sys_id) +{ + const char *xpath = "/frr-isisd:lsp-received"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); + data = yang_data_new_string(xpath_arg, lsp_id); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/sequence", xpath); + data = yang_data_new_uint32(xpath_arg, seqno); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/received-timestamp", xpath); + data = yang_data_new_uint32(xpath_arg, timestamp); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor-system-id", xpath); + data = yang_data_new_string(xpath_arg, sys_id); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:lsp-generation + */ +void isis_notif_lsp_gen(const struct isis_area *area, const char *lsp_id, + uint32_t seqno, uint32_t timestamp) +{ + const char *xpath = "/frr-isisd:lsp-generation"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); + data = yang_data_new_string(xpath_arg, lsp_id); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/sequence", xpath); + data = yang_data_new_uint32(xpath_arg, seqno); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/send-timestamp", xpath); + data = yang_data_new_uint32(xpath_arg, timestamp); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:id-len-mismatch + */ +void isis_notif_id_len_mismatch(const struct isis_circuit *circuit, + uint8_t rcv_id_len, const char *raw_pdu) +{ + const char *xpath = "/frr-isisd:id-len-mismatch"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/pdu-field-len", xpath); + data = yang_data_new_uint8(xpath_arg, rcv_id_len); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); + data = yang_data_new(xpath_arg, raw_pdu); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:version-skew + */ +void isis_notif_version_skew(const struct isis_circuit *circuit, + uint8_t version, const char *raw_pdu) +{ + const char *xpath = "/frr-isisd:version-skew"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/protocol-version", xpath); + data = yang_data_new_uint8(xpath_arg, version); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); + data = yang_data_new(xpath_arg, raw_pdu); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:lsp-error-detected + */ +void isis_notif_lsp_error(const struct isis_circuit *circuit, + const char *lsp_id, const char *raw_pdu, + __attribute__((unused)) uint32_t offset, + __attribute__((unused)) uint8_t tlv_type) +{ + const char *xpath = "/frr-isisd:lsp-error-detected"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); + data = yang_data_new_string(xpath_arg, lsp_id); + listnode_add(arguments, data); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); + data = yang_data_new(xpath_arg, raw_pdu); + listnode_add(arguments, data); + /* ignore offset and tlv_type which cannot be set properly */ + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:sequence-number-skipped + */ +void isis_notif_seqno_skipped(const struct isis_circuit *circuit, + const char *lsp_id) +{ + const char *xpath = "/frr-isisd:sequence-number-skipped"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); + data = yang_data_new_string(xpath_arg, lsp_id); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} + +/* + * XPath: /frr-isisd:own-lsp-purge + */ +void isis_notif_own_lsp_purge(const struct isis_circuit *circuit, + const char *lsp_id) +{ + const char *xpath = "/frr-isisd:own-lsp-purge"; + struct list *arguments = yang_data_list_new(); + char xpath_arg[XPATH_MAXLEN]; + struct yang_data *data; + struct isis_area *area = circuit->area; + + notif_prep_instance_hdr(xpath, area, "default", arguments); + notif_prepr_iface_hdr(xpath, circuit, arguments); + snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); + data = yang_data_new_string(xpath_arg, lsp_id); + listnode_add(arguments, data); + + nb_notification_send(xpath, arguments); +} diff --git a/isisd/isis_nb_state.c b/isisd/isis_nb_state.c new file mode 100644 index 000000000..e52d0201d --- /dev/null +++ b/isisd/isis_nb_state.c @@ -0,0 +1,386 @@ +/* + * Copyright (C) 2018 Volta Networks + * Emanuele Di Pascale + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <zebra.h> + +#include "northbound.h" +#include "linklist.h" + +#include "isisd/isisd.h" +#include "isisd/isis_nb.h" +#include "isisd/isis_circuit.h" +#include "isisd/isis_adjacency.h" +#include "isisd/isis_misc.h" + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency + */ +const void * +lib_interface_isis_adjacencies_adjacency_get_next(const void *parent_list_entry, + const void *list_entry) +{ + struct interface *ifp; + struct isis_circuit *circuit; + struct isis_adjacency *adj, *adj_next = NULL; + struct list *list; + struct listnode *node, *node_next; + + /* Get first adjacency. */ + if (list_entry == NULL) { + ifp = (struct interface *)parent_list_entry; + if (!ifp) + return NULL; + + circuit = circuit_scan_by_ifp(ifp); + if (!circuit) + return NULL; + + switch (circuit->circ_type) { + case CIRCUIT_T_BROADCAST: + for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; + level++) { + adj = listnode_head( + circuit->u.bc.adjdb[level - 1]); + if (adj) + break; + } + break; + case CIRCUIT_T_P2P: + adj = circuit->u.p2p.neighbor; + break; + default: + adj = NULL; + break; + } + + return adj; + } + + /* Get next adjacency. */ + adj = (struct isis_adjacency *)list_entry; + circuit = adj->circuit; + switch (circuit->circ_type) { + case CIRCUIT_T_BROADCAST: + list = circuit->u.bc.adjdb[adj->level - 1]; + node = listnode_lookup(list, adj); + node_next = listnextnode(node); + if (node_next) + adj_next = listgetdata(node_next); + else if (adj->level == ISIS_LEVEL1) { + /* + * Once we finish the L1 adjacencies, move to the L2 + * adjacencies list. + */ + list = circuit->u.bc.adjdb[ISIS_LEVEL2 - 1]; + adj_next = listnode_head(list); + } + break; + case CIRCUIT_T_P2P: + /* P2P circuits have at most one adjacency. */ + default: + break; + } + + return adj_next; +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sys-type + */ +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_sys_type_get_elem( + const char *xpath, const void *list_entry) +{ + const struct isis_adjacency *adj = list_entry; + + return yang_data_new_enum(xpath, adj->level); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sysid + */ +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_sysid_get_elem( + const char *xpath, const void *list_entry) +{ + const struct isis_adjacency *adj = list_entry; + + return yang_data_new_string(xpath, sysid_print(adj->sysid)); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-extended-circuit-id + */ +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem( + const char *xpath, const void *list_entry) +{ + const struct isis_adjacency *adj = list_entry; + + return yang_data_new_uint32(xpath, adj->circuit->circuit_id); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-snpa + */ +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_snpa_get_elem( + const char *xpath, const void *list_entry) +{ + const struct isis_adjacency *adj = list_entry; + + return yang_data_new_string(xpath, snpa_print(adj->snpa)); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/hold-timer + */ +struct yang_data *lib_interface_isis_adjacencies_adjacency_hold_timer_get_elem( + const char *xpath, const void *list_entry) +{ + const struct isis_adjacency *adj = list_entry; + + return yang_data_new_uint16(xpath, adj->hold_time); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-priority + */ +struct yang_data * +lib_interface_isis_adjacencies_adjacency_neighbor_priority_get_elem( + const char *xpath, const void *list_entry) +{ + const struct isis_adjacency *adj = list_entry; + + return yang_data_new_uint8(xpath, adj->prio[adj->level - 1]); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/state + */ +struct yang_data * +lib_interface_isis_adjacencies_adjacency_state_get_elem(const char *xpath, + const void *list_entry) +{ + const struct isis_adjacency *adj = list_entry; + + return yang_data_new_string(xpath, isis_adj_yang_state(adj->adj_state)); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-changes + */ +struct yang_data *lib_interface_isis_event_counters_adjacency_changes_get_elem( + const char *xpath, const void *list_entry) +{ + struct interface *ifp; + struct isis_circuit *circuit; + + ifp = (struct interface *)list_entry; + if (!ifp) + return NULL; + + circuit = circuit_scan_by_ifp(ifp); + if (!circuit) + return NULL; + + return yang_data_new_uint32(xpath, circuit->adj_state_changes); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-number + */ +struct yang_data *lib_interface_isis_event_counters_adjacency_number_get_elem( + const char *xpath, const void *list_entry) +{ + struct interface *ifp; + struct isis_circuit *circuit; + struct isis_adjacency *adj; + struct listnode *node; + uint32_t total = 0; + + ifp = (struct interface *)list_entry; + if (!ifp) + return NULL; + + circuit = circuit_scan_by_ifp(ifp); + if (!circuit) + return NULL; + + /* + * TODO: keep track of the number of adjacencies instead of calculating + * it on demand. + */ + switch (circuit->circ_type) { + case CIRCUIT_T_BROADCAST: + for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { + for (ALL_LIST_ELEMENTS_RO( + circuit->u.bc.adjdb[level - 1], node, adj)) + total++; + } + break; + case CIRCUIT_T_P2P: + adj = circuit->u.p2p.neighbor; + if (adj) + total = 1; + break; + default: + break; + } + + return yang_data_new_uint32(xpath, total); +} + +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/event-counters/init-fails + */ +struct yang_data * +lib_interface_isis_event_counters_init_fails_get_elem(const char *xpath, + const void *list_entry) +{ + struct interface *ifp; + struct isis_circuit *circuit; + + ifp = (struct interface *)list_entry; + if (!ifp) + return NULL; + + circuit = circuit_scan_by_ifp(ifp); + if (!circuit) + return NULL; + + return yang_data_new_uint32(xpath, circuit->init_failures); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-rejects + */ +struct yang_data *lib_interface_isis_event_counters_adjacency_rejects_get_elem( + const char *xpath, const void *list_entry) +{ + struct interface *ifp; + struct isis_circuit *circuit; + + ifp = (struct interface *)list_entry; + if (!ifp) + return NULL; + + circuit = circuit_scan_by_ifp(ifp); + if (!circuit) + return NULL; + + return yang_data_new_uint32(xpath, circuit->rej_adjacencies); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/event-counters/id-len-mismatch + */ +struct yang_data *lib_interface_isis_event_counters_id_len_mismatch_get_elem( + const char *xpath, const void *list_entry) +{ + struct interface *ifp; + struct isis_circuit *circuit; + + ifp = (struct interface *)list_entry; + if (!ifp) + return NULL; + + circuit = circuit_scan_by_ifp(ifp); + if (!circuit) + return NULL; + + return yang_data_new_uint32(xpath, circuit->id_len_mismatches); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/event-counters/max-area-addresses-mismatch + */ +struct yang_data * +lib_interface_isis_event_counters_max_area_addresses_mismatch_get_elem( + const char *xpath, const void *list_entry) +{ + struct interface *ifp; + struct isis_circuit *circuit; + + ifp = (struct interface *)list_entry; + if (!ifp) + return NULL; + + circuit = circuit_scan_by_ifp(ifp); + if (!circuit) + return NULL; + + return yang_data_new_uint32(xpath, circuit->max_area_addr_mismatches); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-type-fails + */ +struct yang_data * +lib_interface_isis_event_counters_authentication_type_fails_get_elem( + const char *xpath, const void *list_entry) +{ + struct interface *ifp; + struct isis_circuit *circuit; + + ifp = (struct interface *)list_entry; + if (!ifp) + return NULL; + + circuit = circuit_scan_by_ifp(ifp); + if (!circuit) + return NULL; + + return yang_data_new_uint32(xpath, circuit->auth_type_failures); +} + +/* + * XPath: + * /frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-fails + */ +struct yang_data * +lib_interface_isis_event_counters_authentication_fails_get_elem( + const char *xpath, const void *list_entry) +{ + struct interface *ifp; + struct isis_circuit *circuit; + + ifp = (struct interface *)list_entry; + if (!ifp) + return NULL; + + circuit = circuit_scan_by_ifp(ifp); + if (!circuit) + return NULL; + + return yang_data_new_uint32(xpath, circuit->auth_failures); +} diff --git a/isisd/isis_northbound.c b/isisd/isis_northbound.c deleted file mode 100644 index 97b7ae4f7..000000000 --- a/isisd/isis_northbound.c +++ /dev/null @@ -1,3932 +0,0 @@ -/* - * Copyright (C) 2001,2002 Sampo Saaristo - * Tampere University of Technology - * Institute of Communications Engineering - * Copyright (C) 2018 Volta Networks - * Emanuele Di Pascale - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; see the file COPYING; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <zebra.h> -#include "northbound.h" -#include "libfrr.h" -#include "linklist.h" -#include "log.h" -#include "lib/bfd.h" -#include "isisd/isis_bfd.h" -#include "isisd/isis_constants.h" -#include "isisd/isis_common.h" -#include "isisd/isis_flags.h" -#include "isisd/isis_circuit.h" -#include "isisd/isisd.h" -#include "isisd/isis_lsp.h" -#include "isisd/isis_pdu.h" -#include "isisd/isis_dynhn.h" -#include "isisd/isis_misc.h" -#include "isisd/isis_csm.h" -#include "isisd/isis_adjacency.h" -#include "isisd/isis_spf.h" -#include "isisd/isis_te.h" -#include "isisd/isis_memory.h" -#include "isisd/isis_mt.h" -#include "isisd/isis_cli.h" -#include "isisd/isis_redist.h" -#include "lib/spf_backoff.h" -#include "lib/lib_errors.h" -#include "lib/vrf.h" - -/* - * Helper functions. - */ -static const char *isis_yang_adj_state(enum isis_adj_state state) -{ - switch (state) { - case ISIS_ADJ_DOWN: - return "down"; - case ISIS_ADJ_UP: - return "up"; - case ISIS_ADJ_INITIALIZING: - return "init"; - default: - return "failed"; - } -} - -/* - * XPath: /frr-isisd:isis/instance - */ -static int isis_instance_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - const char *area_tag; - - if (event != NB_EV_APPLY) - return NB_OK; - - area_tag = yang_dnode_get_string(dnode, "./area-tag"); - area = isis_area_lookup(area_tag); - if (area) - return NB_ERR_INCONSISTENCY; - - area = isis_area_create(area_tag); - /* save area in dnode to avoid looking it up all the time */ - nb_running_set_entry(dnode, area); - - return NB_OK; -} - -static int isis_instance_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_unset_entry(dnode); - isis_area_destroy(area->area_tag); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/is-type - */ -static int isis_instance_is_type_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - int type; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - type = yang_dnode_get_enum(dnode, NULL); - isis_area_is_type_set(area, type); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/area-address - */ -static int isis_instance_area_address_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - struct area_addr addr, *addrr = NULL, *addrp = NULL; - struct listnode *node; - uint8_t buff[255]; - const char *net_title = yang_dnode_get_string(dnode, NULL); - - switch (event) { - case NB_EV_VALIDATE: - addr.addr_len = dotformat2buff(buff, net_title); - memcpy(addr.area_addr, buff, addr.addr_len); - if (addr.area_addr[addr.addr_len - 1] != 0) { - flog_warn( - EC_LIB_NB_CB_CONFIG_VALIDATE, - "nsel byte (last byte) in area address must be 0"); - return NB_ERR_VALIDATION; - } - if (isis->sysid_set) { - /* Check that the SystemID portions match */ - if (memcmp(isis->sysid, GETSYSID((&addr)), - ISIS_SYS_ID_LEN)) { - flog_warn( - EC_LIB_NB_CB_CONFIG_VALIDATE, - "System ID must not change when defining additional area addresses"); - return NB_ERR_VALIDATION; - } - } - break; - case NB_EV_PREPARE: - addrr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct area_addr)); - addrr->addr_len = dotformat2buff(buff, net_title); - memcpy(addrr->area_addr, buff, addrr->addr_len); - resource->ptr = addrr; - break; - case NB_EV_ABORT: - XFREE(MTYPE_ISIS_AREA_ADDR, resource->ptr); - break; - case NB_EV_APPLY: - area = nb_running_get_entry(dnode, NULL, true); - addrr = resource->ptr; - - if (isis->sysid_set == 0) { - /* - * First area address - get the SystemID for this router - */ - memcpy(isis->sysid, GETSYSID(addrr), ISIS_SYS_ID_LEN); - isis->sysid_set = 1; - } else { - /* check that we don't already have this address */ - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, - addrp)) { - if ((addrp->addr_len + ISIS_SYS_ID_LEN - + ISIS_NSEL_LEN) - != (addrr->addr_len)) - continue; - if (!memcmp(addrp->area_addr, addrr->area_addr, - addrr->addr_len)) { - XFREE(MTYPE_ISIS_AREA_ADDR, addrr); - return NB_OK; /* silent fail */ - } - } - } - - /*Forget the systemID part of the address */ - addrr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN); - assert(area->area_addrs); /* to silence scan-build sillyness */ - listnode_add(area->area_addrs, addrr); - - /* only now we can safely generate our LSPs for this area */ - if (listcount(area->area_addrs) > 0) { - if (area->is_type & IS_LEVEL_1) - lsp_generate(area, IS_LEVEL_1); - if (area->is_type & IS_LEVEL_2) - lsp_generate(area, IS_LEVEL_2); - } - break; - } - - return NB_OK; -} - -static int isis_instance_area_address_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct area_addr addr, *addrp = NULL; - struct listnode *node; - uint8_t buff[255]; - struct isis_area *area; - const char *net_title; - - if (event != NB_EV_APPLY) - return NB_OK; - - net_title = yang_dnode_get_string(dnode, NULL); - addr.addr_len = dotformat2buff(buff, net_title); - memcpy(addr.area_addr, buff, (int)addr.addr_len); - area = nb_running_get_entry(dnode, NULL, true); - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) { - if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len - && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len)) - break; - } - if (!addrp) - return NB_ERR_INCONSISTENCY; - - listnode_delete(area->area_addrs, addrp); - XFREE(MTYPE_ISIS_AREA_ADDR, addrp); - /* - * Last area address - reset the SystemID for this router - */ - if (listcount(area->area_addrs) == 0) { - memset(isis->sysid, 0, ISIS_SYS_ID_LEN); - isis->sysid_set = 0; - if (isis->debugs & DEBUG_EVENTS) - zlog_debug("Router has no SystemID"); - } - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/dynamic-hostname - */ -static int isis_instance_dynamic_hostname_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - isis_area_dynhostname_set(area, yang_dnode_get_bool(dnode, NULL)); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/attached - */ -static int isis_instance_attached_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - bool attached; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - attached = yang_dnode_get_bool(dnode, NULL); - isis_area_attached_bit_set(area, attached); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/overload - */ -static int isis_instance_overload_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - bool overload; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - overload = yang_dnode_get_bool(dnode, NULL); - isis_area_overload_bit_set(area, overload); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/metric-style - */ -static int isis_instance_metric_style_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - bool old_metric, new_metric; - enum isis_metric_style metric_style = yang_dnode_get_enum(dnode, NULL); - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - old_metric = (metric_style == ISIS_WIDE_METRIC) ? false : true; - new_metric = (metric_style == ISIS_NARROW_METRIC) ? false : true; - isis_area_metricstyle_set(area, old_metric, new_metric); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/purge-originator - */ -static int isis_instance_purge_originator_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - area->purge_originator = yang_dnode_get_bool(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/lsp/mtu - */ -static int isis_instance_lsp_mtu_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct listnode *node; - struct isis_circuit *circuit; - uint16_t lsp_mtu = yang_dnode_get_uint16(dnode, NULL); - struct isis_area *area; - - switch (event) { - case NB_EV_VALIDATE: - area = nb_running_get_entry(dnode, NULL, false); - if (!area) - break; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { - if (circuit->state != C_STATE_INIT - && circuit->state != C_STATE_UP) - continue; - if (lsp_mtu > isis_circuit_pdu_size(circuit)) { - flog_warn( - EC_LIB_NB_CB_CONFIG_VALIDATE, - "ISIS area contains circuit %s, which has a maximum PDU size of %zu", - circuit->interface->name, - isis_circuit_pdu_size(circuit)); - return NB_ERR_VALIDATION; - } - } - break; - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; - case NB_EV_APPLY: - area = nb_running_get_entry(dnode, NULL, true); - isis_area_lsp_mtu_set(area, lsp_mtu); - break; - } - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/lsp/refresh-interval/level-1 - */ -static int -isis_instance_lsp_refresh_interval_level_1_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - uint16_t refr_int; - - if (event != NB_EV_APPLY) - return NB_OK; - - refr_int = yang_dnode_get_uint16(dnode, NULL); - area = nb_running_get_entry(dnode, NULL, true); - isis_area_lsp_refresh_set(area, IS_LEVEL_1, refr_int); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/lsp/refresh-interval/level-2 - */ -static int -isis_instance_lsp_refresh_interval_level_2_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - uint16_t refr_int; - - if (event != NB_EV_APPLY) - return NB_OK; - - refr_int = yang_dnode_get_uint16(dnode, NULL); - area = nb_running_get_entry(dnode, NULL, true); - isis_area_lsp_refresh_set(area, IS_LEVEL_2, refr_int); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/lsp/maximum-lifetime/level-1 - */ -static int -isis_instance_lsp_maximum_lifetime_level_1_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - uint16_t max_lt; - - if (event != NB_EV_APPLY) - return NB_OK; - - max_lt = yang_dnode_get_uint16(dnode, NULL); - area = nb_running_get_entry(dnode, NULL, true); - isis_area_max_lsp_lifetime_set(area, IS_LEVEL_1, max_lt); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/lsp/maximum-lifetime/level-2 - */ -static int -isis_instance_lsp_maximum_lifetime_level_2_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - uint16_t max_lt; - - if (event != NB_EV_APPLY) - return NB_OK; - - max_lt = yang_dnode_get_uint16(dnode, NULL); - area = nb_running_get_entry(dnode, NULL, true); - isis_area_max_lsp_lifetime_set(area, IS_LEVEL_2, max_lt); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/lsp/generation-interval/level-1 - */ -static int isis_instance_lsp_generation_interval_level_1_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - uint16_t gen_int; - - if (event != NB_EV_APPLY) - return NB_OK; - - gen_int = yang_dnode_get_uint16(dnode, NULL); - area = nb_running_get_entry(dnode, NULL, true); - area->lsp_gen_interval[0] = gen_int; - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/lsp/generation-interval/level-2 - */ -static int isis_instance_lsp_generation_interval_level_2_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - uint16_t gen_int; - - if (event != NB_EV_APPLY) - return NB_OK; - - gen_int = yang_dnode_get_uint16(dnode, NULL); - area = nb_running_get_entry(dnode, NULL, true); - area->lsp_gen_interval[1] = gen_int; - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay - */ -static void ietf_backoff_delay_apply_finish(const struct lyd_node *dnode) -{ - long init_delay = yang_dnode_get_uint16(dnode, "./init-delay"); - long short_delay = yang_dnode_get_uint16(dnode, "./short-delay"); - long long_delay = yang_dnode_get_uint16(dnode, "./long-delay"); - long holddown = yang_dnode_get_uint16(dnode, "./hold-down"); - long timetolearn = yang_dnode_get_uint16(dnode, "./time-to-learn"); - struct isis_area *area = nb_running_get_entry(dnode, NULL, true); - size_t bufsiz = strlen(area->area_tag) + sizeof("IS-IS Lx"); - char *buf = XCALLOC(MTYPE_TMP, bufsiz); - - snprintf(buf, bufsiz, "IS-IS %s L1", area->area_tag); - spf_backoff_free(area->spf_delay_ietf[0]); - area->spf_delay_ietf[0] = - spf_backoff_new(master, buf, init_delay, short_delay, - long_delay, holddown, timetolearn); - - snprintf(buf, bufsiz, "IS-IS %s L2", area->area_tag); - spf_backoff_free(area->spf_delay_ietf[1]); - area->spf_delay_ietf[1] = - spf_backoff_new(master, buf, init_delay, short_delay, - long_delay, holddown, timetolearn); - - XFREE(MTYPE_TMP, buf); -} - -static int -isis_instance_spf_ietf_backoff_delay_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* All the work is done in the apply_finish */ - return NB_OK; -} - -static int -isis_instance_spf_ietf_backoff_delay_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - spf_backoff_free(area->spf_delay_ietf[0]); - spf_backoff_free(area->spf_delay_ietf[1]); - area->spf_delay_ietf[0] = NULL; - area->spf_delay_ietf[1] = NULL; - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/init-delay - */ -static int isis_instance_spf_ietf_backoff_delay_init_delay_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* All the work is done in the apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/short-delay - */ -static int isis_instance_spf_ietf_backoff_delay_short_delay_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* All the work is done in the apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/long-delay - */ -static int isis_instance_spf_ietf_backoff_delay_long_delay_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* All the work is done in the apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/hold-down - */ -static int isis_instance_spf_ietf_backoff_delay_hold_down_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* All the work is done in the apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/time-to-learn - */ -static int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* All the work is done in the apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/spf/minimum-interval/level-1 - */ -static int -isis_instance_spf_minimum_interval_level_1_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - area->min_spf_interval[0] = yang_dnode_get_uint16(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/spf/minimum-interval/level-2 - */ -static int -isis_instance_spf_minimum_interval_level_2_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - area->min_spf_interval[1] = yang_dnode_get_uint16(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/area-password - */ -static void area_password_apply_finish(const struct lyd_node *dnode) -{ - const char *password = yang_dnode_get_string(dnode, "./password"); - struct isis_area *area = nb_running_get_entry(dnode, NULL, true); - int pass_type = yang_dnode_get_enum(dnode, "./password-type"); - uint8_t snp_auth = yang_dnode_get_enum(dnode, "./authenticate-snp"); - - switch (pass_type) { - case ISIS_PASSWD_TYPE_CLEARTXT: - isis_area_passwd_cleartext_set(area, IS_LEVEL_1, password, - snp_auth); - break; - case ISIS_PASSWD_TYPE_HMAC_MD5: - isis_area_passwd_hmac_md5_set(area, IS_LEVEL_1, password, - snp_auth); - break; - } -} - -static int isis_instance_area_password_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* actual setting is done in apply_finish */ - return NB_OK; -} - -static int isis_instance_area_password_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - isis_area_passwd_unset(area, IS_LEVEL_1); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/area-password/password - */ -static int -isis_instance_area_password_password_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* actual setting is done in apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/area-password/password-type - */ -static int -isis_instance_area_password_password_type_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* actual setting is done in apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/area-password/authenticate-snp - */ -static int isis_instance_area_password_authenticate_snp_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* actual setting is done in apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/domain-password - */ -static void domain_password_apply_finish(const struct lyd_node *dnode) -{ - const char *password = yang_dnode_get_string(dnode, "./password"); - struct isis_area *area = nb_running_get_entry(dnode, NULL, true); - int pass_type = yang_dnode_get_enum(dnode, "./password-type"); - uint8_t snp_auth = yang_dnode_get_enum(dnode, "./authenticate-snp"); - - switch (pass_type) { - case ISIS_PASSWD_TYPE_CLEARTXT: - isis_area_passwd_cleartext_set(area, IS_LEVEL_2, password, - snp_auth); - break; - case ISIS_PASSWD_TYPE_HMAC_MD5: - isis_area_passwd_hmac_md5_set(area, IS_LEVEL_2, password, - snp_auth); - break; - } -} - -static int isis_instance_domain_password_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* actual setting is done in apply_finish */ - return NB_OK; -} - -static int isis_instance_domain_password_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - isis_area_passwd_unset(area, IS_LEVEL_2); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/domain-password/password - */ -static int -isis_instance_domain_password_password_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* actual setting is done in apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/domain-password/password-type - */ -static int -isis_instance_domain_password_password_type_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* actual setting is done in apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/domain-password/authenticate-snp - */ -static int isis_instance_domain_password_authenticate_snp_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* actual setting is done in apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4 - */ -static void default_info_origin_apply_finish(const struct lyd_node *dnode, - int family) -{ - int originate_type = DEFAULT_ORIGINATE; - unsigned long metric = 0; - const char *routemap = NULL; - struct isis_area *area = nb_running_get_entry(dnode, NULL, true); - int level = yang_dnode_get_enum(dnode, "./level"); - - if (yang_dnode_get_bool(dnode, "./always")) { - originate_type = DEFAULT_ORIGINATE_ALWAYS; - } else if (family == AF_INET6) { - zlog_warn( - "%s: Zebra doesn't implement default-originate for IPv6 yet, so use with care or use default-originate always.", - __func__); - } - - if (yang_dnode_exists(dnode, "./metric")) - metric = yang_dnode_get_uint32(dnode, "./metric"); - if (yang_dnode_exists(dnode, "./route-map")) - routemap = yang_dnode_get_string(dnode, "./route-map"); - - isis_redist_set(area, level, family, DEFAULT_ROUTE, metric, routemap, - originate_type); -} - -static void default_info_origin_ipv4_apply_finish(const struct lyd_node *dnode) -{ - default_info_origin_apply_finish(dnode, AF_INET); -} - -static void default_info_origin_ipv6_apply_finish(const struct lyd_node *dnode) -{ - default_info_origin_apply_finish(dnode, AF_INET6); -} - -static int isis_instance_default_information_originate_ipv4_create( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -static int isis_instance_default_information_originate_ipv4_destroy( - enum nb_event event, const struct lyd_node *dnode) -{ - struct isis_area *area; - int level; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - level = yang_dnode_get_enum(dnode, "./level"); - isis_redist_unset(area, level, AF_INET, DEFAULT_ROUTE); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/always - */ -static int isis_instance_default_information_originate_ipv4_always_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/route-map - */ -static int isis_instance_default_information_originate_ipv4_route_map_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -static int isis_instance_default_information_originate_ipv4_route_map_destroy( - enum nb_event event, const struct lyd_node *dnode) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/metric - */ -static int isis_instance_default_information_originate_ipv4_metric_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6 - */ -static int isis_instance_default_information_originate_ipv6_create( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -static int isis_instance_default_information_originate_ipv6_destroy( - enum nb_event event, const struct lyd_node *dnode) -{ - struct isis_area *area; - int level; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - level = yang_dnode_get_enum(dnode, "./level"); - isis_redist_unset(area, level, AF_INET6, DEFAULT_ROUTE); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/always - */ -static int isis_instance_default_information_originate_ipv6_always_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/route-map - */ -static int isis_instance_default_information_originate_ipv6_route_map_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -static int isis_instance_default_information_originate_ipv6_route_map_destroy( - enum nb_event event, const struct lyd_node *dnode) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/metric - */ -static int isis_instance_default_information_originate_ipv6_metric_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by default_info_origin_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/redistribute/ipv4 - */ -static void redistribute_apply_finish(const struct lyd_node *dnode, int family) -{ - assert(family == AF_INET || family == AF_INET6); - int type, level; - unsigned long metric = 0; - const char *routemap = NULL; - struct isis_area *area; - - type = yang_dnode_get_enum(dnode, "./protocol"); - level = yang_dnode_get_enum(dnode, "./level"); - area = nb_running_get_entry(dnode, NULL, true); - - if (yang_dnode_exists(dnode, "./metric")) - metric = yang_dnode_get_uint32(dnode, "./metric"); - if (yang_dnode_exists(dnode, "./route-map")) - routemap = yang_dnode_get_string(dnode, "./route-map"); - - isis_redist_set(area, level, family, type, metric, routemap, 0); -} - -static void redistribute_ipv4_apply_finish(const struct lyd_node *dnode) -{ - redistribute_apply_finish(dnode, AF_INET); -} - -static void redistribute_ipv6_apply_finish(const struct lyd_node *dnode) -{ - redistribute_apply_finish(dnode, AF_INET6); -} - -static int isis_instance_redistribute_ipv4_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by redistribute_apply_finish */ - return NB_OK; -} - -static int isis_instance_redistribute_ipv4_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct isis_area *area; - int level, type; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - level = yang_dnode_get_enum(dnode, "./level"); - type = yang_dnode_get_enum(dnode, "./protocol"); - isis_redist_unset(area, level, AF_INET, type); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/redistribute/ipv4/route-map - */ -static int -isis_instance_redistribute_ipv4_route_map_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by redistribute_apply_finish */ - return NB_OK; -} - -static int -isis_instance_redistribute_ipv4_route_map_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - /* It's all done by redistribute_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/redistribute/ipv4/metric - */ -static int -isis_instance_redistribute_ipv4_metric_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by redistribute_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/redistribute/ipv6 - */ -static int isis_instance_redistribute_ipv6_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by redistribute_apply_finish */ - return NB_OK; -} - -static int isis_instance_redistribute_ipv6_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct isis_area *area; - int level, type; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - level = yang_dnode_get_enum(dnode, "./level"); - type = yang_dnode_get_enum(dnode, "./protocol"); - isis_redist_unset(area, level, AF_INET6, type); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/redistribute/ipv6/route-map - */ -static int -isis_instance_redistribute_ipv6_route_map_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by redistribute_apply_finish */ - return NB_OK; -} - -static int -isis_instance_redistribute_ipv6_route_map_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - /* It's all done by redistribute_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/redistribute/ipv6/metric - */ -static int -isis_instance_redistribute_ipv6_metric_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - /* It's all done by redistribute_apply_finish */ - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-multicast - */ -static int isis_multi_topology_common(enum nb_event event, - const struct lyd_node *dnode, - const char *topology, bool create) -{ - struct isis_area *area; - struct isis_area_mt_setting *setting; - uint16_t mtid = isis_str2mtid(topology); - - switch (event) { - case NB_EV_VALIDATE: - if (mtid == (uint16_t)-1) { - flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, - "Unknown topology %s", topology); - return NB_ERR_VALIDATION; - } - break; - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; - case NB_EV_APPLY: - area = nb_running_get_entry(dnode, NULL, true); - setting = area_get_mt_setting(area, mtid); - setting->enabled = create; - lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); - break; - } - - return NB_OK; -} - -static int isis_multi_topology_overload_common(enum nb_event event, - const struct lyd_node *dnode, - const char *topology) -{ - struct isis_area *area; - struct isis_area_mt_setting *setting; - uint16_t mtid = isis_str2mtid(topology); - - /* validation is done in isis_multi_topology_common */ - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - setting = area_get_mt_setting(area, mtid); - setting->overload = yang_dnode_get_bool(dnode, NULL); - if (setting->enabled) - lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); - - return NB_OK; -} - -static int -isis_instance_multi_topology_ipv4_multicast_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_common(event, dnode, "ipv4-multicast", true); -} - -static int -isis_instance_multi_topology_ipv4_multicast_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - return isis_multi_topology_common(event, dnode, "ipv4-multicast", - false); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-multicast/overload - */ -static int isis_instance_multi_topology_ipv4_multicast_overload_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_overload_common(event, dnode, - "ipv4-multicast"); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-management - */ -static int isis_instance_multi_topology_ipv4_management_create( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_common(event, dnode, "ipv4-mgmt", true); -} - -static int isis_instance_multi_topology_ipv4_management_destroy( - enum nb_event event, const struct lyd_node *dnode) -{ - return isis_multi_topology_common(event, dnode, "ipv4-mgmt", false); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-management/overload - */ -static int isis_instance_multi_topology_ipv4_management_overload_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_overload_common(event, dnode, "ipv4-mgmt"); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-unicast - */ -static int -isis_instance_multi_topology_ipv6_unicast_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_common(event, dnode, "ipv6-unicast", true); -} - -static int -isis_instance_multi_topology_ipv6_unicast_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - return isis_multi_topology_common(event, dnode, "ipv6-unicast", false); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-unicast/overload - */ -static int isis_instance_multi_topology_ipv6_unicast_overload_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_overload_common(event, dnode, - "ipv6-unicast"); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-multicast - */ -static int -isis_instance_multi_topology_ipv6_multicast_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_common(event, dnode, "ipv6-multicast", true); -} - -static int -isis_instance_multi_topology_ipv6_multicast_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - return isis_multi_topology_common(event, dnode, "ipv6-multicast", - false); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-multicast/overload - */ -static int isis_instance_multi_topology_ipv6_multicast_overload_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_overload_common(event, dnode, - "ipv6-multicast"); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-management - */ -static int isis_instance_multi_topology_ipv6_management_create( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_common(event, dnode, "ipv6-mgmt", true); -} - -static int isis_instance_multi_topology_ipv6_management_destroy( - enum nb_event event, const struct lyd_node *dnode) -{ - return isis_multi_topology_common(event, dnode, "ipv6-mgmt", false); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-management/overload - */ -static int isis_instance_multi_topology_ipv6_management_overload_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_overload_common(event, dnode, "ipv6-mgmt"); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-dstsrc - */ -static int -isis_instance_multi_topology_ipv6_dstsrc_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_common(event, dnode, "ipv6-dstsrc", true); -} - -static int -isis_instance_multi_topology_ipv6_dstsrc_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - return isis_multi_topology_common(event, dnode, "ipv6-dstsrc", false); -} - -/* - * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-dstsrc/overload - */ -static int isis_instance_multi_topology_ipv6_dstsrc_overload_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return isis_multi_topology_overload_common(event, dnode, "ipv6-dstsrc"); -} - -/* - * XPath: /frr-isisd:isis/instance/log-adjacency-changes - */ -static int -isis_instance_log_adjacency_changes_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - bool log = yang_dnode_get_bool(dnode, NULL); - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - area->log_adj_changes = log ? 1 : 0; - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/mpls-te - */ -static int isis_instance_mpls_te_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct listnode *node; - struct isis_area *area; - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - if (area->mta == NULL) { - - struct mpls_te_area *new; - - zlog_debug("ISIS-TE(%s): Initialize MPLS Traffic Engineering", - area->area_tag); - - new = XCALLOC(MTYPE_ISIS_MPLS_TE, sizeof(struct mpls_te_area)); - - /* Initialize MPLS_TE structure */ - new->status = enable; - new->level = 0; - new->inter_as = off; - new->interas_areaid.s_addr = 0; - new->router_id.s_addr = 0; - - area->mta = new; - } else { - area->mta->status = enable; - } - - /* Update Extended TLVs according to Interface link parameters */ - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) - isis_link_params_update(circuit, circuit->interface); - - /* Reoriginate STD_TE & GMPLS circuits */ - lsp_regenerate_schedule(area, area->is_type, 0); - - return NB_OK; -} - -static int isis_instance_mpls_te_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct listnode *node; - struct isis_area *area; - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - if (IS_MPLS_TE(area->mta)) - area->mta->status = disable; - else - return NB_OK; - - /* Flush LSP if circuit engage */ - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { - if (!IS_EXT_TE(circuit->ext)) - continue; - - /* disable MPLS_TE Circuit keeping SR one's */ - if (IS_SUBTLV(circuit->ext, EXT_ADJ_SID)) - circuit->ext->status = EXT_ADJ_SID; - else if (IS_SUBTLV(circuit->ext, EXT_LAN_ADJ_SID)) - circuit->ext->status = EXT_LAN_ADJ_SID; - else - circuit->ext->status = 0; - } - - /* Reoriginate STD_TE & GMPLS circuits */ - lsp_regenerate_schedule(area, area->is_type, 0); - - zlog_debug("ISIS-TE(%s): Disabled MPLS Traffic Engineering", - area->area_tag); - - return NB_OK; -} - -/* - * XPath: /frr-isisd:isis/instance/mpls-te/router-address - */ -static int isis_instance_mpls_te_router_address_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct in_addr value; - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - /* only proceed if MPLS-TE is enabled */ - if (!IS_MPLS_TE(area->mta)) - return NB_OK; - - /* Update Area Router ID */ - yang_dnode_get_ipv4(&value, dnode, NULL); - area->mta->router_id.s_addr = value.s_addr; - - /* And re-schedule LSP update */ - lsp_regenerate_schedule(area, area->is_type, 0); - - return NB_OK; -} - -static int isis_instance_mpls_te_router_address_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct isis_area *area; - - if (event != NB_EV_APPLY) - return NB_OK; - - area = nb_running_get_entry(dnode, NULL, true); - /* only proceed if MPLS-TE is enabled */ - if (!IS_MPLS_TE(area->mta)) - return NB_OK; - - /* Reset Area Router ID */ - area->mta->router_id.s_addr = INADDR_ANY; - - /* And re-schedule LSP update */ - lsp_regenerate_schedule(area, area->is_type, 0); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis - */ -static int lib_interface_isis_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_area *area; - struct interface *ifp; - struct isis_circuit *circuit; - const char *area_tag = yang_dnode_get_string(dnode, "./area-tag"); - uint32_t min_mtu, actual_mtu; - - switch (event) { - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; - case NB_EV_VALIDATE: - /* check if interface mtu is sufficient. If the area has not - * been created yet, assume default MTU for the area - */ - ifp = nb_running_get_entry(dnode, NULL, false); - /* zebra might not know yet about the MTU - nothing we can do */ - if (!ifp || ifp->mtu == 0) - break; - actual_mtu = - if_is_broadcast(ifp) ? ifp->mtu - LLC_LEN : ifp->mtu; - area = isis_area_lookup(area_tag); - if (area) - min_mtu = area->lsp_mtu; - else -#ifndef FABRICD - min_mtu = yang_get_default_uint16( - "/frr-isisd:isis/instance/lsp/mtu"); -#else - min_mtu = DEFAULT_LSP_MTU; -#endif /* ifndef FABRICD */ - if (actual_mtu < min_mtu) { - flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, - "Interface %s has MTU %" PRIu32 - ", minimum MTU for the area is %" PRIu32 "", - ifp->name, actual_mtu, min_mtu); - return NB_ERR_VALIDATION; - } - break; - case NB_EV_APPLY: - area = isis_area_lookup(area_tag); - /* The area should have already be created. We are - * setting the priority of the global isis area creation - * slightly lower, so it should be executed first, but I - * cannot rely on that so here I have to check. - */ - if (!area) { - flog_err( - EC_LIB_NB_CB_CONFIG_APPLY, - "%s: attempt to create circuit for area %s before the area has been created", - __func__, area_tag); - abort(); - } - - ifp = nb_running_get_entry(dnode, NULL, true); - circuit = isis_circuit_create(area, ifp); - assert(circuit - && (circuit->state == C_STATE_CONF - || circuit->state == C_STATE_UP)); - nb_running_set_entry(dnode, circuit); - break; - } - - return NB_OK; -} - -static int lib_interface_isis_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_unset_entry(dnode); - if (!circuit) - return NB_ERR_INCONSISTENCY; - if (circuit->state == C_STATE_UP || circuit->state == C_STATE_CONF) - isis_csm_state_change(ISIS_DISABLE, circuit, circuit->area); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/area-tag - */ -static int lib_interface_isis_area_tag_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - struct interface *ifp; - struct vrf *vrf; - const char *area_tag, *ifname, *vrfname; - - if (event == NB_EV_VALIDATE) { - /* libyang doesn't like relative paths across module boundaries - */ - ifname = yang_dnode_get_string(dnode->parent->parent, "./name"); - vrfname = yang_dnode_get_string(dnode->parent->parent, "./vrf"); - vrf = vrf_lookup_by_name(vrfname); - assert(vrf); - ifp = if_lookup_by_name(ifname, vrf->vrf_id); - if (!ifp) - return NB_OK; - circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list); - area_tag = yang_dnode_get_string(dnode, NULL); - if (circuit && circuit->area && circuit->area->area_tag - && strcmp(circuit->area->area_tag, area_tag)) { - flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, - "ISIS circuit is already defined on %s", - circuit->area->area_tag); - return NB_ERR_VALIDATION; - } - } - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/circuit-type - */ -static int lib_interface_isis_circuit_type_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - int circ_type = yang_dnode_get_enum(dnode, NULL); - struct isis_circuit *circuit; - struct interface *ifp; - struct vrf *vrf; - const char *ifname, *vrfname; - - switch (event) { - case NB_EV_VALIDATE: - /* libyang doesn't like relative paths across module boundaries - */ - ifname = yang_dnode_get_string(dnode->parent->parent, "./name"); - vrfname = yang_dnode_get_string(dnode->parent->parent, "./vrf"); - vrf = vrf_lookup_by_name(vrfname); - assert(vrf); - ifp = if_lookup_by_name(ifname, vrf->vrf_id); - if (!ifp) - break; - circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list); - if (circuit && circuit->state == C_STATE_UP - && circuit->area->is_type != IS_LEVEL_1_AND_2 - && circuit->area->is_type != circ_type) { - flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, - "Invalid circuit level for area %s", - circuit->area->area_tag); - return NB_ERR_VALIDATION; - } - break; - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; - case NB_EV_APPLY: - circuit = nb_running_get_entry(dnode, NULL, true); - isis_circuit_is_type_set(circuit, circ_type); - break; - } - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv4-routing - */ -static int lib_interface_isis_ipv4_routing_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - bool ipv4, ipv6; - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - ipv4 = yang_dnode_get_bool(dnode, NULL); - ipv6 = yang_dnode_get_bool(dnode, "../ipv6-routing"); - isis_circuit_af_set(circuit, ipv4, ipv6); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv6-routing - */ -static int lib_interface_isis_ipv6_routing_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - bool ipv4, ipv6; - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - ipv4 = yang_dnode_exists(dnode, "../ipv4-routing"); - ipv6 = yang_dnode_get_bool(dnode, NULL); - isis_circuit_af_set(circuit, ipv4, ipv6); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring - */ -static int lib_interface_isis_bfd_monitoring_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - bool bfd_monitoring; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - bfd_monitoring = yang_dnode_get_bool(dnode, NULL); - - if (bfd_monitoring) { - isis_bfd_circuit_param_set(circuit, BFD_DEF_MIN_RX, - BFD_DEF_MIN_TX, BFD_DEF_DETECT_MULT, - true); - } else { - isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_DEREGISTER); - bfd_info_free(&circuit->bfd_info); - } - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1 - */ -static int -lib_interface_isis_csnp_interval_level_1_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - circuit->csnp_interval[0] = yang_dnode_get_uint16(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2 - */ -static int -lib_interface_isis_csnp_interval_level_2_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - circuit->csnp_interval[1] = yang_dnode_get_uint16(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1 - */ -static int -lib_interface_isis_psnp_interval_level_1_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - circuit->psnp_interval[0] = yang_dnode_get_uint16(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2 - */ -static int -lib_interface_isis_psnp_interval_level_2_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - circuit->psnp_interval[1] = yang_dnode_get_uint16(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/padding - */ -static int lib_interface_isis_hello_padding_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - circuit->pad_hellos = yang_dnode_get_bool(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1 - */ -static int -lib_interface_isis_hello_interval_level_1_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - uint32_t interval; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - interval = yang_dnode_get_uint32(dnode, NULL); - circuit->hello_interval[0] = interval; - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2 - */ -static int -lib_interface_isis_hello_interval_level_2_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - uint32_t interval; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - interval = yang_dnode_get_uint32(dnode, NULL); - circuit->hello_interval[1] = interval; - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1 - */ -static int -lib_interface_isis_hello_multiplier_level_1_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - uint16_t multi; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - multi = yang_dnode_get_uint16(dnode, NULL); - circuit->hello_multiplier[0] = multi; - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2 - */ -static int -lib_interface_isis_hello_multiplier_level_2_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - uint16_t multi; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - multi = yang_dnode_get_uint16(dnode, NULL); - circuit->hello_multiplier[1] = multi; - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric/level-1 - */ -static int -lib_interface_isis_metric_level_1_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - unsigned int met; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - met = yang_dnode_get_uint32(dnode, NULL); - isis_circuit_metric_set(circuit, IS_LEVEL_1, met); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric/level-2 - */ -static int -lib_interface_isis_metric_level_2_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - unsigned int met; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - met = yang_dnode_get_uint32(dnode, NULL); - isis_circuit_metric_set(circuit, IS_LEVEL_2, met); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority/level-1 - */ -static int -lib_interface_isis_priority_level_1_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - circuit->priority[0] = yang_dnode_get_uint8(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority/level-2 - */ -static int -lib_interface_isis_priority_level_2_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - circuit->priority[1] = yang_dnode_get_uint8(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/network-type - */ -static int lib_interface_isis_network_type_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - int net_type = yang_dnode_get_enum(dnode, NULL); - - switch (event) { - case NB_EV_VALIDATE: - circuit = nb_running_get_entry(dnode, NULL, false); - if (!circuit) - break; - if (circuit->circ_type == CIRCUIT_T_LOOPBACK) { - flog_warn( - EC_LIB_NB_CB_CONFIG_VALIDATE, - "Cannot change network type on loopback interface"); - return NB_ERR_VALIDATION; - } - if (net_type == CIRCUIT_T_BROADCAST - && circuit->state == C_STATE_UP - && !if_is_broadcast(circuit->interface)) { - flog_warn( - EC_LIB_NB_CB_CONFIG_VALIDATE, - "Cannot configure non-broadcast interface for broadcast operation"); - return NB_ERR_VALIDATION; - } - break; - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; - case NB_EV_APPLY: - circuit = nb_running_get_entry(dnode, NULL, true); - isis_circuit_circ_type_set(circuit, net_type); - break; - } - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/passive - */ -static int lib_interface_isis_passive_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - struct isis_area *area; - struct interface *ifp; - bool passive = yang_dnode_get_bool(dnode, NULL); - - /* validation only applies if we are setting passive to false */ - if (!passive && event == NB_EV_VALIDATE) { - circuit = nb_running_get_entry(dnode, NULL, false); - if (!circuit) - return NB_OK; - ifp = circuit->interface; - if (!ifp) - return NB_OK; - if (if_is_loopback(ifp)) { - flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, - "Loopback is always passive"); - return NB_ERR_VALIDATION; - } - } - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - if (circuit->state != C_STATE_UP) { - circuit->is_passive = passive; - } else { - area = circuit->area; - isis_csm_state_change(ISIS_DISABLE, circuit, area); - circuit->is_passive = passive; - isis_csm_state_change(ISIS_ENABLE, circuit, area); - } - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/password - */ -static int lib_interface_isis_password_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - return NB_OK; -} - -static int lib_interface_isis_password_destroy(enum nb_event event, - const struct lyd_node *dnode) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - isis_circuit_passwd_unset(circuit); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/password/password - */ -static int -lib_interface_isis_password_password_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - const char *password; - - if (event != NB_EV_APPLY) - return NB_OK; - - password = yang_dnode_get_string(dnode, NULL); - circuit = nb_running_get_entry(dnode, NULL, true); - - isis_circuit_passwd_set(circuit, circuit->passwd.type, password); - - return NB_OK; -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/password/password-type - */ -static int -lib_interface_isis_password_password_type_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - uint8_t pass_type; - - if (event != NB_EV_APPLY) - return NB_OK; - - pass_type = yang_dnode_get_enum(dnode, NULL); - circuit = nb_running_get_entry(dnode, NULL, true); - circuit->passwd.type = pass_type; - - return NB_OK; -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake - */ -static int lib_interface_isis_disable_three_way_handshake_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - struct isis_circuit *circuit; - - if (event != NB_EV_APPLY) - return NB_OK; - - circuit = nb_running_get_entry(dnode, NULL, true); - circuit->disable_threeway_adj = yang_dnode_get_bool(dnode, NULL); - - return NB_OK; -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-unicast - */ -static int lib_interface_isis_multi_topology_common( - enum nb_event event, const struct lyd_node *dnode, uint16_t mtid) -{ - struct isis_circuit *circuit; - bool value; - - switch (event) { - case NB_EV_VALIDATE: - circuit = nb_running_get_entry(dnode, NULL, false); - if (circuit && circuit->area && circuit->area->oldmetric) { - flog_warn( - EC_LIB_NB_CB_CONFIG_VALIDATE, - "Multi topology IS-IS can only be used with wide metrics"); - return NB_ERR_VALIDATION; - } - break; - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; - case NB_EV_APPLY: - circuit = nb_running_get_entry(dnode, NULL, true); - value = yang_dnode_get_bool(dnode, NULL); - isis_circuit_mt_enabled_set(circuit, mtid, value); - break; - } - - return NB_OK; -} - -static int lib_interface_isis_multi_topology_ipv4_unicast_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return lib_interface_isis_multi_topology_common(event, dnode, - ISIS_MT_IPV4_UNICAST); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-multicast - */ -static int lib_interface_isis_multi_topology_ipv4_multicast_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return lib_interface_isis_multi_topology_common(event, dnode, - ISIS_MT_IPV4_MULTICAST); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-management - */ -static int lib_interface_isis_multi_topology_ipv4_management_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return lib_interface_isis_multi_topology_common(event, dnode, - ISIS_MT_IPV4_MGMT); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-unicast - */ -static int lib_interface_isis_multi_topology_ipv6_unicast_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return lib_interface_isis_multi_topology_common(event, dnode, - ISIS_MT_IPV6_UNICAST); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-multicast - */ -static int lib_interface_isis_multi_topology_ipv6_multicast_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return lib_interface_isis_multi_topology_common(event, dnode, - ISIS_MT_IPV6_MULTICAST); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-management - */ -static int lib_interface_isis_multi_topology_ipv6_management_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return lib_interface_isis_multi_topology_common(event, dnode, - ISIS_MT_IPV6_MGMT); -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-dstsrc - */ -static int lib_interface_isis_multi_topology_ipv6_dstsrc_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) -{ - return lib_interface_isis_multi_topology_common(event, dnode, - ISIS_MT_IPV6_DSTSRC); -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency - */ -static const void * -lib_interface_isis_adjacencies_adjacency_get_next(const void *parent_list_entry, - const void *list_entry) -{ - struct interface *ifp; - struct isis_circuit *circuit; - struct isis_adjacency *adj, *adj_next = NULL; - struct list *list; - struct listnode *node, *node_next; - - /* Get first adjacency. */ - if (list_entry == NULL) { - ifp = (struct interface *)parent_list_entry; - if (!ifp) - return NULL; - - circuit = circuit_scan_by_ifp(ifp); - if (!circuit) - return NULL; - - switch (circuit->circ_type) { - case CIRCUIT_T_BROADCAST: - for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; - level++) { - adj = listnode_head( - circuit->u.bc.adjdb[level - 1]); - if (adj) - break; - } - break; - case CIRCUIT_T_P2P: - adj = circuit->u.p2p.neighbor; - break; - default: - adj = NULL; - break; - } - - return adj; - } - - /* Get next adjacency. */ - adj = (struct isis_adjacency *)list_entry; - circuit = adj->circuit; - switch (circuit->circ_type) { - case CIRCUIT_T_BROADCAST: - list = circuit->u.bc.adjdb[adj->level - 1]; - node = listnode_lookup(list, adj); - node_next = listnextnode(node); - if (node_next) - adj_next = listgetdata(node_next); - else if (adj->level == ISIS_LEVEL1) { - /* - * Once we finish the L1 adjacencies, move to the L2 - * adjacencies list. - */ - list = circuit->u.bc.adjdb[ISIS_LEVEL2 - 1]; - adj_next = listnode_head(list); - } - break; - case CIRCUIT_T_P2P: - /* P2P circuits have at most one adjacency. */ - default: - break; - } - - return adj_next; -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sys-type - */ -static struct yang_data * -lib_interface_isis_adjacencies_adjacency_neighbor_sys_type_get_elem( - const char *xpath, const void *list_entry) -{ - const struct isis_adjacency *adj = list_entry; - - return yang_data_new_enum(xpath, adj->level); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sysid - */ -static struct yang_data * -lib_interface_isis_adjacencies_adjacency_neighbor_sysid_get_elem( - const char *xpath, const void *list_entry) -{ - const struct isis_adjacency *adj = list_entry; - - return yang_data_new_string(xpath, sysid_print(adj->sysid)); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-extended-circuit-id - */ -static struct yang_data * -lib_interface_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem( - const char *xpath, const void *list_entry) -{ - const struct isis_adjacency *adj = list_entry; - - return yang_data_new_uint32(xpath, adj->circuit->circuit_id); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-snpa - */ -static struct yang_data * -lib_interface_isis_adjacencies_adjacency_neighbor_snpa_get_elem( - const char *xpath, const void *list_entry) -{ - const struct isis_adjacency *adj = list_entry; - - return yang_data_new_string(xpath, snpa_print(adj->snpa)); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/hold-timer - */ -static struct yang_data * -lib_interface_isis_adjacencies_adjacency_hold_timer_get_elem( - const char *xpath, const void *list_entry) -{ - const struct isis_adjacency *adj = list_entry; - - return yang_data_new_uint16(xpath, adj->hold_time); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-priority - */ -static struct yang_data * -lib_interface_isis_adjacencies_adjacency_neighbor_priority_get_elem( - const char *xpath, const void *list_entry) -{ - const struct isis_adjacency *adj = list_entry; - - return yang_data_new_uint8(xpath, adj->prio[adj->level - 1]); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/state - */ -static struct yang_data * -lib_interface_isis_adjacencies_adjacency_state_get_elem(const char *xpath, - const void *list_entry) -{ - const struct isis_adjacency *adj = list_entry; - - return yang_data_new_string(xpath, isis_yang_adj_state(adj->adj_state)); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-changes - */ -static struct yang_data * -lib_interface_isis_event_counters_adjacency_changes_get_elem( - const char *xpath, const void *list_entry) -{ - struct interface *ifp; - struct isis_circuit *circuit; - - ifp = (struct interface *)list_entry; - if (!ifp) - return NULL; - - circuit = circuit_scan_by_ifp(ifp); - if (!circuit) - return NULL; - - return yang_data_new_uint32(xpath, circuit->adj_state_changes); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-number - */ -static struct yang_data * -lib_interface_isis_event_counters_adjacency_number_get_elem( - const char *xpath, const void *list_entry) -{ - struct interface *ifp; - struct isis_circuit *circuit; - struct isis_adjacency *adj; - struct listnode *node; - uint32_t total = 0; - - ifp = (struct interface *)list_entry; - if (!ifp) - return NULL; - - circuit = circuit_scan_by_ifp(ifp); - if (!circuit) - return NULL; - - /* - * TODO: keep track of the number of adjacencies instead of calculating - * it on demand. - */ - switch (circuit->circ_type) { - case CIRCUIT_T_BROADCAST: - for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { - for (ALL_LIST_ELEMENTS_RO( - circuit->u.bc.adjdb[level - 1], node, adj)) - total++; - } - break; - case CIRCUIT_T_P2P: - adj = circuit->u.p2p.neighbor; - if (adj) - total = 1; - break; - default: - break; - } - - return yang_data_new_uint32(xpath, total); -} - -/* - * XPath: /frr-interface:lib/interface/frr-isisd:isis/event-counters/init-fails - */ -static struct yang_data * -lib_interface_isis_event_counters_init_fails_get_elem(const char *xpath, - const void *list_entry) -{ - struct interface *ifp; - struct isis_circuit *circuit; - - ifp = (struct interface *)list_entry; - if (!ifp) - return NULL; - - circuit = circuit_scan_by_ifp(ifp); - if (!circuit) - return NULL; - - return yang_data_new_uint32(xpath, circuit->init_failures); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-rejects - */ -static struct yang_data * -lib_interface_isis_event_counters_adjacency_rejects_get_elem( - const char *xpath, const void *list_entry) -{ - struct interface *ifp; - struct isis_circuit *circuit; - - ifp = (struct interface *)list_entry; - if (!ifp) - return NULL; - - circuit = circuit_scan_by_ifp(ifp); - if (!circuit) - return NULL; - - return yang_data_new_uint32(xpath, circuit->rej_adjacencies); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/event-counters/id-len-mismatch - */ -static struct yang_data * -lib_interface_isis_event_counters_id_len_mismatch_get_elem( - const char *xpath, const void *list_entry) -{ - struct interface *ifp; - struct isis_circuit *circuit; - - ifp = (struct interface *)list_entry; - if (!ifp) - return NULL; - - circuit = circuit_scan_by_ifp(ifp); - if (!circuit) - return NULL; - - return yang_data_new_uint32(xpath, circuit->id_len_mismatches); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/event-counters/max-area-addresses-mismatch - */ -static struct yang_data * -lib_interface_isis_event_counters_max_area_addresses_mismatch_get_elem( - const char *xpath, const void *list_entry) -{ - struct interface *ifp; - struct isis_circuit *circuit; - - ifp = (struct interface *)list_entry; - if (!ifp) - return NULL; - - circuit = circuit_scan_by_ifp(ifp); - if (!circuit) - return NULL; - - return yang_data_new_uint32(xpath, circuit->max_area_addr_mismatches); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-type-fails - */ -static struct yang_data * -lib_interface_isis_event_counters_authentication_type_fails_get_elem( - const char *xpath, const void *list_entry) -{ - struct interface *ifp; - struct isis_circuit *circuit; - - ifp = (struct interface *)list_entry; - if (!ifp) - return NULL; - - circuit = circuit_scan_by_ifp(ifp); - if (!circuit) - return NULL; - - return yang_data_new_uint32(xpath, circuit->auth_type_failures); -} - -/* - * XPath: - * /frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-fails - */ -static struct yang_data * -lib_interface_isis_event_counters_authentication_fails_get_elem( - const char *xpath, const void *list_entry) -{ - struct interface *ifp; - struct isis_circuit *circuit; - - ifp = (struct interface *)list_entry; - if (!ifp) - return NULL; - - circuit = circuit_scan_by_ifp(ifp); - if (!circuit) - return NULL; - - return yang_data_new_uint32(xpath, circuit->auth_failures); -} - -/* - * NOTIFICATIONS - */ -static void notif_prep_instance_hdr(const char *xpath, - const struct isis_area *area, - const char *routing_instance, - struct list *args) -{ - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - - snprintf(xpath_arg, sizeof(xpath_arg), "%s/routing-instance", xpath); - data = yang_data_new_string(xpath_arg, routing_instance); - listnode_add(args, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/routing-protocol-name", - xpath); - data = yang_data_new_string(xpath_arg, area->area_tag); - listnode_add(args, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/isis-level", xpath); - data = yang_data_new_enum(xpath_arg, area->is_type); - listnode_add(args, data); -} - -static void notif_prepr_iface_hdr(const char *xpath, - const struct isis_circuit *circuit, - struct list *args) -{ - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - - snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath); - data = yang_data_new_string(xpath_arg, circuit->interface->name); - listnode_add(args, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-level", xpath); - data = yang_data_new_enum(xpath_arg, circuit->is_type); - listnode_add(args, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/extended-circuit-id", xpath); - /* we do not seem to have the extended version of the circuit_id */ - data = yang_data_new_uint32(xpath_arg, (uint32_t)circuit->circuit_id); - listnode_add(args, data); -} - -/* - * XPath: - * /frr-isisd:database-overload - */ -void isis_notif_db_overload(const struct isis_area *area, bool overload) -{ - const char *xpath = "/frr-isisd:database-overload"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/overload", xpath); - data = yang_data_new_enum(xpath_arg, !!overload); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:lsp-too-large - */ -void isis_notif_lsp_too_large(const struct isis_circuit *circuit, - uint32_t pdu_size, const char *lsp_id) -{ - const char *xpath = "/frr-isisd:lsp-too-large"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/pdu-size", xpath); - data = yang_data_new_uint32(xpath_arg, pdu_size); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); - data = yang_data_new_string(xpath_arg, lsp_id); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:if-state-change - */ -void isis_notif_if_state_change(const struct isis_circuit *circuit, bool down) -{ - const char *xpath = "/frr-isisd:if-state-change"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/state", xpath); - data = yang_data_new_enum(xpath_arg, !!down); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:corrupted-lsp-detected - */ -void isis_notif_corrupted_lsp(const struct isis_area *area, const char *lsp_id) -{ - const char *xpath = "/frr-isisd:corrupted-lsp-detected"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); - data = yang_data_new_string(xpath_arg, lsp_id); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:attempt-to-exceed-max-sequence - */ -void isis_notif_lsp_exceed_max(const struct isis_area *area, const char *lsp_id) -{ - const char *xpath = "/frr-isisd:attempt-to-exceed-max-sequence"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); - data = yang_data_new_string(xpath_arg, lsp_id); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:max-area-addresses-mismatch - */ -void isis_notif_max_area_addr_mismatch(const struct isis_circuit *circuit, - uint8_t max_area_addrs, - const char *raw_pdu) -{ - const char *xpath = "/frr-isisd:max-area-addresses-mismatch"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/max-area-addresses", xpath); - data = yang_data_new_uint8(xpath_arg, max_area_addrs); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); - data = yang_data_new(xpath_arg, raw_pdu); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:authentication-type-failure - */ -void isis_notif_authentication_type_failure(const struct isis_circuit *circuit, - const char *raw_pdu) -{ - const char *xpath = "/frr-isisd:authentication-type-failure"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); - data = yang_data_new(xpath_arg, raw_pdu); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:authentication-failure - */ -void isis_notif_authentication_failure(const struct isis_circuit *circuit, - const char *raw_pdu) -{ - const char *xpath = "/frr-isisd:authentication-failure"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); - data = yang_data_new(xpath_arg, raw_pdu); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:adjacency-state-change - */ -void isis_notif_adj_state_change(const struct isis_adjacency *adj, - int new_state, const char *reason) -{ - const char *xpath = "/frr-isisd:adjacency-state-change"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_circuit *circuit = adj->circuit; - struct isis_area *area = circuit->area; - struct isis_dynhn *dyn = dynhn_find_by_id(adj->sysid); - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - if (dyn) { - snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor", xpath); - data = yang_data_new_string(xpath_arg, dyn->hostname); - listnode_add(arguments, data); - } - snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor-system-id", xpath); - data = yang_data_new_string(xpath_arg, sysid_print(adj->sysid)); - listnode_add(arguments, data); - - snprintf(xpath_arg, sizeof(xpath_arg), "%s/state", xpath); - data = yang_data_new_string(xpath_arg, isis_yang_adj_state(new_state)); - listnode_add(arguments, data); - if (new_state == ISIS_ADJ_DOWN) { - snprintf(xpath_arg, sizeof(xpath_arg), "%s/reason", xpath); - data = yang_data_new_string(xpath_arg, reason); - listnode_add(arguments, data); - } - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:rejected-adjacency - */ -void isis_notif_reject_adjacency(const struct isis_circuit *circuit, - const char *reason, const char *raw_pdu) -{ - const char *xpath = "/frr-isisd:rejected-adjacency"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/reason", xpath); - data = yang_data_new_string(xpath_arg, reason); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); - data = yang_data_new(xpath_arg, raw_pdu); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:area-mismatch - */ -void isis_notif_area_mismatch(const struct isis_circuit *circuit, - const char *raw_pdu) -{ - const char *xpath = "/frr-isisd:area-mismatch"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); - data = yang_data_new(xpath_arg, raw_pdu); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:lsp-received - */ -void isis_notif_lsp_received(const struct isis_circuit *circuit, - const char *lsp_id, uint32_t seqno, - uint32_t timestamp, const char *sys_id) -{ - const char *xpath = "/frr-isisd:lsp-received"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); - data = yang_data_new_string(xpath_arg, lsp_id); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/sequence", xpath); - data = yang_data_new_uint32(xpath_arg, seqno); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/received-timestamp", xpath); - data = yang_data_new_uint32(xpath_arg, timestamp); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor-system-id", xpath); - data = yang_data_new_string(xpath_arg, sys_id); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:lsp-generation - */ -void isis_notif_lsp_gen(const struct isis_area *area, const char *lsp_id, - uint32_t seqno, uint32_t timestamp) -{ - const char *xpath = "/frr-isisd:lsp-generation"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); - data = yang_data_new_string(xpath_arg, lsp_id); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/sequence", xpath); - data = yang_data_new_uint32(xpath_arg, seqno); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/send-timestamp", xpath); - data = yang_data_new_uint32(xpath_arg, timestamp); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:id-len-mismatch - */ -void isis_notif_id_len_mismatch(const struct isis_circuit *circuit, - uint8_t rcv_id_len, const char *raw_pdu) -{ - const char *xpath = "/frr-isisd:id-len-mismatch"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/pdu-field-len", xpath); - data = yang_data_new_uint8(xpath_arg, rcv_id_len); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); - data = yang_data_new(xpath_arg, raw_pdu); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:version-skew - */ -void isis_notif_version_skew(const struct isis_circuit *circuit, - uint8_t version, const char *raw_pdu) -{ - const char *xpath = "/frr-isisd:version-skew"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/protocol-version", xpath); - data = yang_data_new_uint8(xpath_arg, version); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); - data = yang_data_new(xpath_arg, raw_pdu); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:lsp-error-detected - */ -void isis_notif_lsp_error(const struct isis_circuit *circuit, - const char *lsp_id, const char *raw_pdu, - __attribute__((unused)) uint32_t offset, - __attribute__((unused)) uint8_t tlv_type) -{ - const char *xpath = "/frr-isisd:lsp-error-detected"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); - data = yang_data_new_string(xpath_arg, lsp_id); - listnode_add(arguments, data); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath); - data = yang_data_new(xpath_arg, raw_pdu); - listnode_add(arguments, data); - /* ignore offset and tlv_type which cannot be set properly */ - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:sequence-number-skipped - */ -void isis_notif_seqno_skipped(const struct isis_circuit *circuit, - const char *lsp_id) -{ - const char *xpath = "/frr-isisd:sequence-number-skipped"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); - data = yang_data_new_string(xpath_arg, lsp_id); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* - * XPath: - * /frr-isisd:own-lsp-purge - */ -void isis_notif_own_lsp_purge(const struct isis_circuit *circuit, - const char *lsp_id) -{ - const char *xpath = "/frr-isisd:own-lsp-purge"; - struct list *arguments = yang_data_list_new(); - char xpath_arg[XPATH_MAXLEN]; - struct yang_data *data; - struct isis_area *area = circuit->area; - - notif_prep_instance_hdr(xpath, area, "default", arguments); - notif_prepr_iface_hdr(xpath, circuit, arguments); - snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath); - data = yang_data_new_string(xpath_arg, lsp_id); - listnode_add(arguments, data); - - nb_notification_send(xpath, arguments); -} - -/* clang-format off */ -const struct frr_yang_module_info frr_isisd_info = { - .name = "frr-isisd", - .nodes = { - { - .xpath = "/frr-isisd:isis/instance", - .cbs = { - .cli_show = cli_show_router_isis, - .create = isis_instance_create, - .destroy = isis_instance_destroy, - }, - .priority = NB_DFLT_PRIORITY - 1, - }, - { - .xpath = "/frr-isisd:isis/instance/is-type", - .cbs = { - .cli_show = cli_show_isis_is_type, - .modify = isis_instance_is_type_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/area-address", - .cbs = { - .cli_show = cli_show_isis_area_address, - .create = isis_instance_area_address_create, - .destroy = isis_instance_area_address_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/dynamic-hostname", - .cbs = { - .cli_show = cli_show_isis_dynamic_hostname, - .modify = isis_instance_dynamic_hostname_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/attached", - .cbs = { - .cli_show = cli_show_isis_attached, - .modify = isis_instance_attached_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/overload", - .cbs = { - .cli_show = cli_show_isis_overload, - .modify = isis_instance_overload_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/metric-style", - .cbs = { - .cli_show = cli_show_isis_metric_style, - .modify = isis_instance_metric_style_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/purge-originator", - .cbs = { - .cli_show = cli_show_isis_purge_origin, - .modify = isis_instance_purge_originator_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/mtu", - .cbs = { - .cli_show = cli_show_isis_lsp_mtu, - .modify = isis_instance_lsp_mtu_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/refresh-interval", - .cbs = { - .cli_show = cli_show_isis_lsp_ref_interval, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/refresh-interval/level-1", - .cbs = { - .modify = isis_instance_lsp_refresh_interval_level_1_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/refresh-interval/level-2", - .cbs = { - .modify = isis_instance_lsp_refresh_interval_level_2_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime", - .cbs = { - .cli_show = cli_show_isis_lsp_max_lifetime, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-1", - .cbs = { - .modify = isis_instance_lsp_maximum_lifetime_level_1_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-2", - .cbs = { - .modify = isis_instance_lsp_maximum_lifetime_level_2_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/generation-interval", - .cbs = { - .cli_show = cli_show_isis_lsp_gen_interval, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/generation-interval/level-1", - .cbs = { - .modify = isis_instance_lsp_generation_interval_level_1_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/lsp/generation-interval/level-2", - .cbs = { - .modify = isis_instance_lsp_generation_interval_level_2_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay", - .cbs = { - .apply_finish = ietf_backoff_delay_apply_finish, - .cli_show = cli_show_isis_spf_ietf_backoff, - .create = isis_instance_spf_ietf_backoff_delay_create, - .destroy = isis_instance_spf_ietf_backoff_delay_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/init-delay", - .cbs = { - .modify = isis_instance_spf_ietf_backoff_delay_init_delay_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/short-delay", - .cbs = { - .modify = isis_instance_spf_ietf_backoff_delay_short_delay_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/long-delay", - .cbs = { - .modify = isis_instance_spf_ietf_backoff_delay_long_delay_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/hold-down", - .cbs = { - .modify = isis_instance_spf_ietf_backoff_delay_hold_down_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/time-to-learn", - .cbs = { - .modify = isis_instance_spf_ietf_backoff_delay_time_to_learn_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/spf/minimum-interval", - .cbs = { - .cli_show = cli_show_isis_spf_min_interval, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/spf/minimum-interval/level-1", - .cbs = { - .modify = isis_instance_spf_minimum_interval_level_1_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/spf/minimum-interval/level-2", - .cbs = { - .modify = isis_instance_spf_minimum_interval_level_2_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/area-password", - .cbs = { - .apply_finish = area_password_apply_finish, - .cli_show = cli_show_isis_area_pwd, - .create = isis_instance_area_password_create, - .destroy = isis_instance_area_password_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/area-password/password", - .cbs = { - .modify = isis_instance_area_password_password_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/area-password/password-type", - .cbs = { - .modify = isis_instance_area_password_password_type_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/area-password/authenticate-snp", - .cbs = { - .modify = isis_instance_area_password_authenticate_snp_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/domain-password", - .cbs = { - .apply_finish = domain_password_apply_finish, - .cli_show = cli_show_isis_domain_pwd, - .create = isis_instance_domain_password_create, - .destroy = isis_instance_domain_password_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/domain-password/password", - .cbs = { - .modify = isis_instance_domain_password_password_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/domain-password/password-type", - .cbs = { - .modify = isis_instance_domain_password_password_type_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/domain-password/authenticate-snp", - .cbs = { - .modify = isis_instance_domain_password_authenticate_snp_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4", - .cbs = { - .apply_finish = default_info_origin_ipv4_apply_finish, - .cli_show = cli_show_isis_def_origin_ipv4, - .create = isis_instance_default_information_originate_ipv4_create, - .destroy = isis_instance_default_information_originate_ipv4_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/always", - .cbs = { - .modify = isis_instance_default_information_originate_ipv4_always_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/route-map", - .cbs = { - .destroy = isis_instance_default_information_originate_ipv4_route_map_destroy, - .modify = isis_instance_default_information_originate_ipv4_route_map_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/metric", - .cbs = { - .modify = isis_instance_default_information_originate_ipv4_metric_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6", - .cbs = { - .apply_finish = default_info_origin_ipv6_apply_finish, - .cli_show = cli_show_isis_def_origin_ipv6, - .create = isis_instance_default_information_originate_ipv6_create, - .destroy = isis_instance_default_information_originate_ipv6_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/always", - .cbs = { - .modify = isis_instance_default_information_originate_ipv6_always_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/route-map", - .cbs = { - .destroy = isis_instance_default_information_originate_ipv6_route_map_destroy, - .modify = isis_instance_default_information_originate_ipv6_route_map_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/metric", - .cbs = { - .modify = isis_instance_default_information_originate_ipv6_metric_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/redistribute/ipv4", - .cbs = { - .apply_finish = redistribute_ipv4_apply_finish, - .cli_show = cli_show_isis_redistribute_ipv4, - .create = isis_instance_redistribute_ipv4_create, - .destroy = isis_instance_redistribute_ipv4_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/redistribute/ipv4/route-map", - .cbs = { - .destroy = isis_instance_redistribute_ipv4_route_map_destroy, - .modify = isis_instance_redistribute_ipv4_route_map_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/redistribute/ipv4/metric", - .cbs = { - .modify = isis_instance_redistribute_ipv4_metric_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/redistribute/ipv6", - .cbs = { - .apply_finish = redistribute_ipv6_apply_finish, - .cli_show = cli_show_isis_redistribute_ipv6, - .create = isis_instance_redistribute_ipv6_create, - .destroy = isis_instance_redistribute_ipv6_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/redistribute/ipv6/route-map", - .cbs = { - .destroy = isis_instance_redistribute_ipv6_route_map_destroy, - .modify = isis_instance_redistribute_ipv6_route_map_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/redistribute/ipv6/metric", - .cbs = { - .modify = isis_instance_redistribute_ipv6_metric_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-multicast", - .cbs = { - .cli_show = cli_show_isis_mt_ipv4_multicast, - .create = isis_instance_multi_topology_ipv4_multicast_create, - .destroy = isis_instance_multi_topology_ipv4_multicast_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-multicast/overload", - .cbs = { - .modify = isis_instance_multi_topology_ipv4_multicast_overload_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-management", - .cbs = { - .cli_show = cli_show_isis_mt_ipv4_mgmt, - .create = isis_instance_multi_topology_ipv4_management_create, - .destroy = isis_instance_multi_topology_ipv4_management_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-management/overload", - .cbs = { - .modify = isis_instance_multi_topology_ipv4_management_overload_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-unicast", - .cbs = { - .cli_show = cli_show_isis_mt_ipv6_unicast, - .create = isis_instance_multi_topology_ipv6_unicast_create, - .destroy = isis_instance_multi_topology_ipv6_unicast_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-unicast/overload", - .cbs = { - .modify = isis_instance_multi_topology_ipv6_unicast_overload_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-multicast", - .cbs = { - .cli_show = cli_show_isis_mt_ipv6_multicast, - .create = isis_instance_multi_topology_ipv6_multicast_create, - .destroy = isis_instance_multi_topology_ipv6_multicast_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-multicast/overload", - .cbs = { - .modify = isis_instance_multi_topology_ipv6_multicast_overload_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-management", - .cbs = { - .cli_show = cli_show_isis_mt_ipv6_mgmt, - .create = isis_instance_multi_topology_ipv6_management_create, - .destroy = isis_instance_multi_topology_ipv6_management_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-management/overload", - .cbs = { - .modify = isis_instance_multi_topology_ipv6_management_overload_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-dstsrc", - .cbs = { - .cli_show = cli_show_isis_mt_ipv6_dstsrc, - .create = isis_instance_multi_topology_ipv6_dstsrc_create, - .destroy = isis_instance_multi_topology_ipv6_dstsrc_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-dstsrc/overload", - .cbs = { - .modify = isis_instance_multi_topology_ipv6_dstsrc_overload_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/log-adjacency-changes", - .cbs = { - .cli_show = cli_show_isis_log_adjacency, - .modify = isis_instance_log_adjacency_changes_modify, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/mpls-te", - .cbs = { - .cli_show = cli_show_isis_mpls_te, - .create = isis_instance_mpls_te_create, - .destroy = isis_instance_mpls_te_destroy, - }, - }, - { - .xpath = "/frr-isisd:isis/instance/mpls-te/router-address", - .cbs = { - .cli_show = cli_show_isis_mpls_te_router_addr, - .destroy = isis_instance_mpls_te_router_address_destroy, - .modify = isis_instance_mpls_te_router_address_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis", - .cbs = { - .create = lib_interface_isis_create, - .destroy = lib_interface_isis_destroy, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/area-tag", - .cbs = { - .modify = lib_interface_isis_area_tag_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/circuit-type", - .cbs = { - .cli_show = cli_show_ip_isis_circ_type, - .modify = lib_interface_isis_circuit_type_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/ipv4-routing", - .cbs = { - .cli_show = cli_show_ip_isis_ipv4, - .modify = lib_interface_isis_ipv4_routing_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/ipv6-routing", - .cbs = { - .cli_show = cli_show_ip_isis_ipv6, - .modify = lib_interface_isis_ipv6_routing_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring", - .cbs = { - .modify = lib_interface_isis_bfd_monitoring_modify, - .cli_show = cli_show_ip_isis_bfd_monitoring, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval", - .cbs = { - .cli_show = cli_show_ip_isis_csnp_interval, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1", - .cbs = { - .modify = lib_interface_isis_csnp_interval_level_1_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2", - .cbs = { - .modify = lib_interface_isis_csnp_interval_level_2_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval", - .cbs = { - .cli_show = cli_show_ip_isis_psnp_interval, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1", - .cbs = { - .modify = lib_interface_isis_psnp_interval_level_1_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2", - .cbs = { - .modify = lib_interface_isis_psnp_interval_level_2_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/padding", - .cbs = { - .cli_show = cli_show_ip_isis_hello_padding, - .modify = lib_interface_isis_hello_padding_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval", - .cbs = { - .cli_show = cli_show_ip_isis_hello_interval, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1", - .cbs = { - .modify = lib_interface_isis_hello_interval_level_1_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2", - .cbs = { - .modify = lib_interface_isis_hello_interval_level_2_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier", - .cbs = { - .cli_show = cli_show_ip_isis_hello_multi, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1", - .cbs = { - .modify = lib_interface_isis_hello_multiplier_level_1_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2", - .cbs = { - .modify = lib_interface_isis_hello_multiplier_level_2_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/metric", - .cbs = { - .cli_show = cli_show_ip_isis_metric, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/metric/level-1", - .cbs = { - .modify = lib_interface_isis_metric_level_1_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/metric/level-2", - .cbs = { - .modify = lib_interface_isis_metric_level_2_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority", - .cbs = { - .cli_show = cli_show_ip_isis_priority, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority/level-1", - .cbs = { - .modify = lib_interface_isis_priority_level_1_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority/level-2", - .cbs = { - .modify = lib_interface_isis_priority_level_2_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/network-type", - .cbs = { - .cli_show = cli_show_ip_isis_network_type, - .modify = lib_interface_isis_network_type_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/passive", - .cbs = { - .cli_show = cli_show_ip_isis_passive, - .modify = lib_interface_isis_passive_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/password", - .cbs = { - .cli_show = cli_show_ip_isis_password, - .create = lib_interface_isis_password_create, - .destroy = lib_interface_isis_password_destroy, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/password/password", - .cbs = { - .modify = lib_interface_isis_password_password_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/password/password-type", - .cbs = { - .modify = lib_interface_isis_password_password_type_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake", - .cbs = { - .cli_show = cli_show_ip_isis_threeway_shake, - .modify = lib_interface_isis_disable_three_way_handshake_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-unicast", - .cbs = { - .cli_show = cli_show_ip_isis_mt_ipv4_unicast, - .modify = lib_interface_isis_multi_topology_ipv4_unicast_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-multicast", - .cbs = { - .cli_show = cli_show_ip_isis_mt_ipv4_multicast, - .modify = lib_interface_isis_multi_topology_ipv4_multicast_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-management", - .cbs = { - .cli_show = cli_show_ip_isis_mt_ipv4_mgmt, - .modify = lib_interface_isis_multi_topology_ipv4_management_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-unicast", - .cbs = { - .cli_show = cli_show_ip_isis_mt_ipv6_unicast, - .modify = lib_interface_isis_multi_topology_ipv6_unicast_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-multicast", - .cbs = { - .cli_show = cli_show_ip_isis_mt_ipv6_multicast, - .modify = lib_interface_isis_multi_topology_ipv6_multicast_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-management", - .cbs = { - .cli_show = cli_show_ip_isis_mt_ipv6_mgmt, - .modify = lib_interface_isis_multi_topology_ipv6_management_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-dstsrc", - .cbs = { - .cli_show = cli_show_ip_isis_mt_ipv6_dstsrc, - .modify = lib_interface_isis_multi_topology_ipv6_dstsrc_modify, - }, - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency", - .cbs = { - .get_next = lib_interface_isis_adjacencies_adjacency_get_next, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sys-type", - .cbs = { - .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_sys_type_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sysid", - .cbs = { - .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_sysid_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-extended-circuit-id", - .cbs = { - .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-snpa", - .cbs = { - .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_snpa_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/hold-timer", - .cbs = { - .get_elem = lib_interface_isis_adjacencies_adjacency_hold_timer_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-priority", - .cbs = { - .get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_priority_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/state", - .cbs = { - .get_elem = lib_interface_isis_adjacencies_adjacency_state_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-changes", - .cbs = { - .get_elem = lib_interface_isis_event_counters_adjacency_changes_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-number", - .cbs = { - .get_elem = lib_interface_isis_event_counters_adjacency_number_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/init-fails", - .cbs = { - .get_elem = lib_interface_isis_event_counters_init_fails_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-rejects", - .cbs = { - .get_elem = lib_interface_isis_event_counters_adjacency_rejects_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/id-len-mismatch", - .cbs = { - .get_elem = lib_interface_isis_event_counters_id_len_mismatch_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/max-area-addresses-mismatch", - .cbs = { - .get_elem = lib_interface_isis_event_counters_max_area_addresses_mismatch_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-type-fails", - .cbs = { - .get_elem = lib_interface_isis_event_counters_authentication_type_fails_get_elem, - } - }, - { - .xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-fails", - .cbs = { - .get_elem = lib_interface_isis_event_counters_authentication_fails_get_elem, - } - }, - { - .xpath = NULL, - }, - } -}; diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index a637ff003..71249cf65 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -58,6 +58,7 @@ #include "isisd/fabricd.h" #include "isisd/isis_tx_queue.h" #include "isisd/isis_pdu_counter.h" +#include "isisd/isis_nb.h" static int ack_lsp(struct isis_lsp_hdr *hdr, struct isis_circuit *circuit, int level) diff --git a/isisd/isisd.c b/isisd/isisd.c index 029a9e068..f15d7a9c7 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -57,6 +57,7 @@ #include "isisd/isis_te.h" #include "isisd/isis_mt.h" #include "isisd/fabricd.h" +#include "isisd/isis_nb.h" struct isis *isis = NULL; diff --git a/isisd/isisd.h b/isisd/isisd.h index f825b6ecb..052cc1092 100644 --- a/isisd/isisd.h +++ b/isisd/isisd.h @@ -219,52 +219,6 @@ int isis_area_passwd_cleartext_set(struct isis_area *area, int level, int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level, const char *passwd, uint8_t snp_auth); -extern const struct frr_yang_module_info frr_isisd_info; -extern void isis_northbound_init(void); - -/* YANG northbound notifications */ -extern void isis_notif_db_overload(const struct isis_area *area, bool overload); -extern void isis_notif_lsp_too_large(const struct isis_circuit *circuit, - uint32_t pdu_size, const char *lsp_id); -extern void isis_notif_if_state_change(const struct isis_circuit *circuit, - bool down); -extern void isis_notif_corrupted_lsp(const struct isis_area *area, - const char *lsp_id); /* currently unused */ -extern void isis_notif_lsp_exceed_max(const struct isis_area *area, - const char *lsp_id); -extern void -isis_notif_max_area_addr_mismatch(const struct isis_circuit *circuit, - uint8_t max_area_addrs, const char *raw_pdu); -extern void -isis_notif_authentication_type_failure(const struct isis_circuit *circuit, - const char *raw_pdu); -extern void -isis_notif_authentication_failure(const struct isis_circuit *circuit, - const char *raw_pdu); -extern void isis_notif_adj_state_change(const struct isis_adjacency *adj, - int new_state, const char *reason); -extern void isis_notif_reject_adjacency(const struct isis_circuit *circuit, - const char *reason, - const char *raw_pdu); -extern void isis_notif_area_mismatch(const struct isis_circuit *circuit, - const char *raw_pdu); -extern void isis_notif_lsp_received(const struct isis_circuit *circuit, - const char *lsp_id, uint32_t seqno, - uint32_t timestamp, const char *sys_id); -extern void isis_notif_lsp_gen(const struct isis_area *area, const char *lsp_id, - uint32_t seqno, uint32_t timestamp); -extern void isis_notif_id_len_mismatch(const struct isis_circuit *circuit, - uint8_t rcv_id_len, const char *raw_pdu); -extern void isis_notif_version_skew(const struct isis_circuit *circuit, - uint8_t version, const char *raw_pdu); -extern void isis_notif_lsp_error(const struct isis_circuit *circuit, - const char *lsp_id, const char *raw_pdu, - uint32_t offset, uint8_t tlv_type); -extern void isis_notif_seqno_skipped(const struct isis_circuit *circuit, - const char *lsp_id); -extern void isis_notif_own_lsp_purge(const struct isis_circuit *circuit, - const char *lsp_id); - /* Master of threads. */ extern struct thread_master *master; diff --git a/isisd/subdir.am b/isisd/subdir.am index 24f24022a..e77fef41d 100644 --- a/isisd/subdir.am +++ b/isisd/subdir.am @@ -39,6 +39,7 @@ noinst_HEADERS += \ isisd/isis_memory.h \ isisd/isis_misc.h \ isisd/isis_mt.h \ + isisd/isis_nb.h \ isisd/isis_network.h \ isisd/isis_pdu.h \ isisd/isis_pdu_counter.h \ @@ -54,7 +55,6 @@ noinst_HEADERS += \ isisd/isisd.h \ isisd/iso_checksum.h \ isisd/fabricd.h \ - isisd/isis_cli.h \ # end LIBISIS_SOURCES = \ @@ -99,7 +99,10 @@ ISIS_LDADD_COMMON = lib/libfrr.la $(LIBCAP) isisd_libisis_a_SOURCES = \ $(LIBISIS_SOURCES) \ - isisd/isis_northbound.c \ + isisd/isis_nb.c \ + isisd/isis_nb_config.c \ + isisd/isis_nb_notifications.c \ + isisd/isis_nb_state.c \ isisd/isis_cli.c \ #end |