diff options
Diffstat (limited to '')
-rw-r--r-- | ripngd/ripng_cli.c | 338 | ||||
-rw-r--r-- | ripngd/ripng_interface.c | 16 | ||||
-rw-r--r-- | ripngd/ripng_main.c | 42 | ||||
-rw-r--r-- | ripngd/ripng_nb.c | 54 | ||||
-rw-r--r-- | ripngd/ripng_nb.h | 8 | ||||
-rw-r--r-- | ripngd/ripng_nb_config.c | 28 | ||||
-rw-r--r-- | ripngd/ripng_peer.c | 1 | ||||
-rw-r--r-- | ripngd/ripng_routemap.c | 2 | ||||
-rw-r--r-- | ripngd/ripngd.c | 90 | ||||
-rw-r--r-- | ripngd/ripngd.h | 2 | ||||
-rw-r--r-- | ripngd/subdir.am | 2 |
11 files changed, 402 insertions, 181 deletions
diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c index 9a96e29..4806861 100644 --- a/ripngd/ripng_cli.c +++ b/ripngd/ripng_cli.c @@ -8,6 +8,7 @@ #include <zebra.h> #include "if.h" +#include "if_rmap.h" #include "vrf.h" #include "log.h" #include "prefix.h" @@ -73,7 +74,7 @@ void cli_show_router_ripng(struct vty *vty, const struct lyd_node *dnode, { const char *vrf_name; - vrf_name = yang_dnode_get_string(dnode, "./vrf"); + vrf_name = yang_dnode_get_string(dnode, "vrf"); vty_out(vty, "!\n"); vty_out(vty, "router ripng"); @@ -82,6 +83,11 @@ void cli_show_router_ripng(struct vty *vty, const struct lyd_node *dnode, vty_out(vty, "\n"); } +void cli_show_end_router_ripng(struct vty *vty, const struct lyd_node *dnode) +{ + vty_out(vty, "exit\n"); +} + /* * XPath: /frr-ripngd:ripngd/instance/allow-ecmp */ @@ -199,8 +205,12 @@ DEFPY_YANG (ripng_network_prefix, "RIPng enable on specified interface or network.\n" "IPv6 network\n") { - nb_cli_enqueue_change(vty, "./network", - no ? NB_OP_DESTROY : NB_OP_CREATE, network_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./network[.='%s']", network_str); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -222,8 +232,12 @@ DEFPY_YANG (ripng_network_if, "RIPng enable on specified interface or network.\n" "Interface name\n") { - nb_cli_enqueue_change(vty, "./interface", - no ? NB_OP_DESTROY : NB_OP_CREATE, network); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./interface[.='%s']", network); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -267,12 +281,12 @@ void cli_show_ripng_offset_list(struct vty *vty, const struct lyd_node *dnode, { const char *interface; - interface = yang_dnode_get_string(dnode, "./interface"); + interface = yang_dnode_get_string(dnode, "interface"); vty_out(vty, " offset-list %s %s %s", - yang_dnode_get_string(dnode, "./access-list"), - yang_dnode_get_string(dnode, "./direction"), - yang_dnode_get_string(dnode, "./metric")); + yang_dnode_get_string(dnode, "access-list"), + yang_dnode_get_string(dnode, "direction"), + yang_dnode_get_string(dnode, "metric")); if (!strmatch(interface, "*")) vty_out(vty, " %s", interface); vty_out(vty, "\n"); @@ -288,8 +302,12 @@ DEFPY_YANG (ripng_passive_interface, "Suppress routing updates on an interface\n" "Interface name\n") { - nb_cli_enqueue_change(vty, "./passive-interface", - no ? NB_OP_DESTROY : NB_OP_CREATE, ifname); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./passive-interface[.='%s']", ifname); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + ifname); return nb_cli_apply_changes(vty, NULL); } @@ -335,13 +353,13 @@ void cli_show_ripng_redistribute(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " redistribute %s", - yang_dnode_get_string(dnode, "./protocol")); - if (yang_dnode_exists(dnode, "./metric")) + yang_dnode_get_string(dnode, "protocol")); + if (yang_dnode_exists(dnode, "metric")) vty_out(vty, " metric %s", - yang_dnode_get_string(dnode, "./metric")); - if (yang_dnode_exists(dnode, "./route-map")) + yang_dnode_get_string(dnode, "metric")); + if (yang_dnode_exists(dnode, "route-map")) vty_out(vty, " route-map %s", - yang_dnode_get_string(dnode, "./route-map")); + yang_dnode_get_string(dnode, "route-map")); vty_out(vty, "\n"); } @@ -355,8 +373,12 @@ DEFPY_YANG (ripng_route, "Static route setup\n" "Set static RIPng route announcement\n") { - nb_cli_enqueue_change(vty, "./static-route", - no ? NB_OP_DESTROY : NB_OP_CREATE, route_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./static-route[.='%s']", route_str); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -377,9 +399,13 @@ DEFPY_YANG (ripng_aggregate_address, "Set aggregate RIPng route announcement\n" "Aggregate network\n") { - nb_cli_enqueue_change(vty, "./aggregate-address", - no ? NB_OP_DESTROY : NB_OP_CREATE, - aggregate_address_str); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, sizeof(xpath), "./aggregate-address[.='%s']", + aggregate_address_str); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -435,9 +461,9 @@ void cli_show_ripng_timers(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " timers basic %s %s %s\n", - yang_dnode_get_string(dnode, "./update-interval"), - yang_dnode_get_string(dnode, "./holddown-interval"), - yang_dnode_get_string(dnode, "./flush-interval")); + yang_dnode_get_string(dnode, "update-interval"), + yang_dnode_get_string(dnode, "holddown-interval"), + yang_dnode_get_string(dnode, "flush-interval")); } /* @@ -486,87 +512,139 @@ void cli_show_ipv6_ripng_split_horizon(struct vty *vty, } } -/* - * XPath: /frr-ripngd:clear-ripng-route - */ -DEFPY_YANG (clear_ipv6_rip, - clear_ipv6_rip_cmd, - "clear ipv6 ripng [vrf WORD]", - CLEAR_STR - IPV6_STR - "Clear IPv6 RIP database\n" - VRF_CMD_HELP_STR) +DEFPY_YANG( + ripng_ipv6_distribute_list, ripng_ipv6_distribute_list_cmd, + "ipv6 distribute-list ACCESSLIST6_NAME$name <in|out>$dir [WORD$ifname]", + "IPv6\n" + "Filter networks in routing updates\n" + "Access-list name\n" + "Filter incoming routing updates\n" + "Filter outgoing routing updates\n" + "Interface name\n") { - struct list *input; - int ret; - - input = list_new(); - if (vrf) { - struct yang_data *yang_vrf; - - yang_vrf = yang_data_new( - "/frr-ripngd:clear-ripng-route/input/vrf", vrf); - listnode_add(input, yang_vrf); - } + char xpath[XPATH_MAXLEN]; - ret = nb_cli_rpc(vty, "/frr-ripngd:clear-ripng-route", input, NULL); + snprintf(xpath, sizeof(xpath), + "./distribute-list[interface='%s']/%s/access-list", + ifname ? ifname : "", dir); + /* nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); */ + nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, name); + return nb_cli_apply_changes(vty, NULL); +} - list_delete(&input); +DEFPY_YANG( + ripng_ipv6_distribute_list_prefix, ripng_ipv6_distribute_list_prefix_cmd, + "ipv6 distribute-list prefix PREFIXLIST6_NAME$name <in|out>$dir [WORD$ifname]", + "IPv6\n" + "Filter networks in routing updates\n" + "Specify a prefix list\n" + "Prefix-list name\n" + "Filter incoming routing updates\n" + "Filter outgoing routing updates\n" + "Interface name\n") +{ + char xpath[XPATH_MAXLEN]; - return ret; + snprintf(xpath, sizeof(xpath), + "./distribute-list[interface='%s']/%s/prefix-list", + ifname ? ifname : "", dir); + /* nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); */ + nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, name); + return nb_cli_apply_changes(vty, NULL); } -DEFUN (ripng_ipv6_distribute_list, - ripng_ipv6_distribute_list_cmd, - "ipv6 distribute-list [prefix] ACCESSLIST6_NAME <in|out> [WORD]", - "IPv6\n" - "Filter networks in routing updates\n" - "Specify a prefix\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") +DEFPY_YANG(no_ripng_ipv6_distribute_list, + no_ripng_ipv6_distribute_list_cmd, + "no ipv6 distribute-list [ACCESSLIST6_NAME$name] <in|out>$dir [WORD$ifname]", + NO_STR + "IPv6\n" + "Filter networks in routing updates\n" + "Access-list name\n" + "Filter incoming routing updates\n" + "Filter outgoing routing updates\n" + "Interface name\n") { - const char *ifname = NULL; - int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0; - - if (argv[argc - 1]->type == VARIABLE_TKN) - ifname = argv[argc - 1]->arg; + const struct lyd_node *value_node; + char xpath[XPATH_MAXLEN]; - return distribute_list_parser(prefix, false, argv[3 + prefix]->text, - argv[2 + prefix]->arg, ifname); + snprintf(xpath, sizeof(xpath), + "./distribute-list[interface='%s']/%s/access-list", + ifname ? ifname : "", dir); + /* + * See if the user has specified specific list so check it exists. + * + * NOTE: Other FRR CLI commands do not do this sort of verification and + * there may be an official decision not to. + */ + if (name) { + value_node = yang_dnode_getf(vty->candidate_config->dnode, "%s/%s", + VTY_CURR_XPATH, xpath); + if (!value_node || strcmp(name, lyd_get_value(value_node))) { + vty_out(vty, "distribute list doesn't exist\n"); + return CMD_WARNING_CONFIG_FAILED; + } + } + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + return nb_cli_apply_changes(vty, NULL); } -DEFUN (ripng_no_ipv6_distribute_list, - ripng_no_ipv6_distribute_list_cmd, - "no ipv6 distribute-list [prefix] ACCESSLIST6_NAME <in|out> [WORD]", - NO_STR - "IPv6\n" - "Filter networks in routing updates\n" - "Specify a prefix\n" - "Access-list name\n" - "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") +DEFPY_YANG(no_ripng_ipv6_distribute_list_prefix, + no_ripng_ipv6_distribute_list_prefix_cmd, + "no ipv6 distribute-list prefix [PREFIXLIST6_NAME$name] <in|out>$dir [WORD$ifname]", + NO_STR + "IPv6\n" + "Filter networks in routing updates\n" + "Specify a prefix list\n" + "Prefix-list name\n" + "Filter incoming routing updates\n" + "Filter outgoing routing updates\n" + "Interface name\n") { - const char *ifname = NULL; - int prefix = (argv[3]->type == WORD_TKN) ? 1 : 0; - - if (argv[argc - 1]->type == VARIABLE_TKN) - ifname = argv[argc - 1]->arg; + const struct lyd_node *value_node; + char xpath[XPATH_MAXLEN]; - return distribute_list_no_parser(vty, prefix, false, - argv[4 + prefix]->text, - argv[3 + prefix]->arg, ifname); + snprintf(xpath, sizeof(xpath), + "./distribute-list[interface='%s']/%s/prefix-list", + ifname ? ifname : "", dir); + /* + * See if the user has specified specific list so check it exists. + * + * NOTE: Other FRR CLI commands do not do this sort of verification and + * there may be an official decision not to. + */ + if (name) { + value_node = yang_dnode_getf(vty->candidate_config->dnode, "%s/%s", + VTY_CURR_XPATH, xpath); + if (!value_node || strcmp(name, lyd_get_value(value_node))) { + vty_out(vty, "distribute list doesn't exist\n"); + return CMD_WARNING_CONFIG_FAILED; + } + } + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + return nb_cli_apply_changes(vty, NULL); } +/* RIPng node structure. */ +static struct cmd_node cmd_ripng_node = { + .name = "ripng", + .node = RIPNG_NODE, + .parent_node = CONFIG_NODE, + .prompt = "%s(config-router)# ", +}; + void ripng_cli_init(void) { + /* Install RIPNG_NODE. */ + install_node(&cmd_ripng_node); + install_default(RIPNG_NODE); + install_element(CONFIG_NODE, &router_ripng_cmd); install_element(CONFIG_NODE, &no_router_ripng_cmd); install_element(RIPNG_NODE, &ripng_ipv6_distribute_list_cmd); - install_element(RIPNG_NODE, &ripng_no_ipv6_distribute_list_cmd); + install_element(RIPNG_NODE, &ripng_ipv6_distribute_list_prefix_cmd); + install_element(RIPNG_NODE, &no_ripng_ipv6_distribute_list_cmd); + install_element(RIPNG_NODE, &no_ripng_ipv6_distribute_list_prefix_cmd); install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd); install_element(RIPNG_NODE, &no_ripng_allow_ecmp_cmd); @@ -585,5 +663,91 @@ void ripng_cli_init(void) install_element(INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd); - install_element(ENABLE_NODE, &clear_ipv6_rip_cmd); -} + if_rmap_init(RIPNG_NODE); +} + +/* clang-format off */ +const struct frr_yang_module_info frr_ripngd_cli_info = { + .name = "frr-ripngd", + .ignore_cfg_cbs = true, + .nodes = { + { + .xpath = "/frr-ripngd:ripngd/instance", + .cbs.cli_show = cli_show_router_ripng, + .cbs.cli_show_end = cli_show_end_router_ripng, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/allow-ecmp", + .cbs.cli_show = cli_show_ripng_allow_ecmp, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/default-information-originate", + .cbs.cli_show = cli_show_ripng_default_information_originate, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/default-metric", + .cbs.cli_show = cli_show_ripng_default_metric, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/network", + .cbs.cli_show = cli_show_ripng_network_prefix, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/interface", + .cbs.cli_show = cli_show_ripng_network_interface, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/offset-list", + .cbs.cli_show = cli_show_ripng_offset_list, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/passive-interface", + .cbs.cli_show = cli_show_ripng_passive_interface, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/distribute-list/in/access-list", + .cbs.cli_show = group_distribute_list_ipv6_cli_show, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/distribute-list/out/access-list", + .cbs.cli_show = group_distribute_list_ipv6_cli_show, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/distribute-list/in/prefix-list", + .cbs.cli_show = group_distribute_list_ipv6_cli_show, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/distribute-list/out/prefix-list", + .cbs.cli_show = group_distribute_list_ipv6_cli_show, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/redistribute", + .cbs.cli_show = cli_show_ripng_redistribute, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/if-route-maps/if-route-map", + .cbs.cli_show = cli_show_if_route_map, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/static-route", + .cbs.cli_show = cli_show_ripng_route, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/aggregate-address", + .cbs.cli_show = cli_show_ripng_aggregate_address, + }, + { + .xpath = "/frr-ripngd:ripngd/instance/timers", + .cbs.cli_show = cli_show_ripng_timers, + }, + { + .xpath = "/frr-interface:lib/interface/frr-ripngd:ripng/split-horizon", + .cbs = { + .cli_show = cli_show_ipv6_ripng_split_horizon, + }, + }, + { + .xpath = NULL, + }, + } +}; diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index 4cb4bb5..9ef9f89 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -128,11 +128,10 @@ static int ripng_multicast_leave(struct interface *ifp, int sock) /* How many link local IPv6 address could be used on the interface ? */ static int ripng_if_ipv6_lladdress_check(struct interface *ifp) { - struct listnode *nn; struct connected *connected; int count = 0; - for (ALL_LIST_ELEMENTS_RO(ifp->connected, nn, connected)) { + frr_each (if_connected, ifp->connected, connected) { struct prefix *p; p = connected->address; @@ -408,14 +407,13 @@ static int ripng_enable_network_lookup_if(struct interface *ifp) { struct ripng_interface *ri = ifp->info; struct ripng *ripng = ri->ripng; - struct listnode *node; struct connected *connected; struct prefix_ipv6 address; if (!ripng) return -1; - for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) { + frr_each (if_connected, ifp->connected, connected) { struct prefix *p; struct agg_node *n; @@ -590,11 +588,10 @@ static void ripng_connect_set(struct interface *ifp, int set) { struct ripng_interface *ri = ifp->info; struct ripng *ripng = ri->ripng; - struct listnode *node, *nnode; struct connected *connected; struct prefix_ipv6 address; - for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) { + frr_each (if_connected, ifp->connected, connected) { struct prefix *p; p = connected->address; @@ -876,7 +873,8 @@ void ripng_if_init(void) hook_register_prio(if_del, 0, ripng_if_delete_hook); /* Install interface node. */ - if_cmd_init_default(); - if_zapi_callbacks(ripng_ifp_create, ripng_ifp_up, - ripng_ifp_down, ripng_ifp_destroy); + hook_register_prio(if_real, 0, ripng_ifp_create); + hook_register_prio(if_up, 0, ripng_ifp_up); + hook_register_prio(if_down, 0, ripng_ifp_down); + hook_register_prio(if_unreal, 0, ripng_ifp_destroy); } diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index 9933dae..ada9ad4 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -22,6 +22,7 @@ #include "if_rmap.h" #include "libfrr.h" #include "routemap.h" +#include "mgmt_be_client.h" #include "ripngd/ripngd.h" #include "ripngd/ripng_nb.h" @@ -52,6 +53,8 @@ struct zebra_privs_t ripngd_privs = { /* Master of threads. */ struct event_loop *master; +struct mgmt_be_client *mgmt_be_client; + static struct frr_daemon_info ripngd_di; /* SIGHUP handler. */ @@ -66,11 +69,27 @@ static void sighup(void) /* SIGINT handler. */ static void sigint(void) { + struct vrf *vrf; + zlog_notice("Terminating on signal"); + nb_oper_cancel_all_walks(); + mgmt_be_client_destroy(mgmt_be_client); + mgmt_be_client = NULL; + + RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { + if (!vrf->info) + continue; + + ripng_clean(vrf->info); + } + ripng_vrf_terminate(); if_rmap_terminate(); ripng_zebra_stop(); + + route_map_finish(); + frr_fini(); exit(0); } @@ -108,18 +127,23 @@ static const struct frr_yang_module_info *const ripngd_yang_modules[] = { &frr_vrf_info, }; -FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT, +/* clang-format off */ +FRR_DAEMON_INFO(ripngd, RIPNG, + .vty_port = RIPNG_VTY_PORT, + .proghelp = "Implementation of the RIPng routing protocol.", - .proghelp = "Implementation of the RIPng routing protocol.", + .signals = ripng_signals, + .n_signals = array_size(ripng_signals), - .signals = ripng_signals, - .n_signals = array_size(ripng_signals), + .privs = &ripngd_privs, - .privs = &ripngd_privs, + .yang_modules = ripngd_yang_modules, + .n_yang_modules = array_size(ripngd_yang_modules), - .yang_modules = ripngd_yang_modules, - .n_yang_modules = array_size(ripngd_yang_modules), + /* mgmtd will load the per-daemon config file now */ + .flags = FRR_NO_SPLIT_CONFIG, ); +/* clang-format on */ #define DEPRECATED_OPTIONS "" @@ -160,7 +184,9 @@ int main(int argc, char **argv) /* RIPngd inits. */ ripng_init(); - ripng_cli_init(); + + mgmt_be_client = mgmt_be_client_create("ripngd", NULL, 0, master); + zebra_init(master); frr_config_fork(); diff --git a/ripngd/ripng_nb.c b/ripngd/ripng_nb.c index 1c6d719..8e20541 100644 --- a/ripngd/ripng_nb.c +++ b/ripngd/ripng_nb.c @@ -6,11 +6,12 @@ #include <zebra.h> -#include "northbound.h" +#include "distribute.h" +#include "if_rmap.h" #include "libfrr.h" +#include "northbound.h" #include "ripngd/ripng_nb.h" -#include "lib/if_rmap.h" /* clang-format off */ const struct frr_yang_module_info frr_ripngd_info = { @@ -19,7 +20,6 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance", .cbs = { - .cli_show = cli_show_router_ripng, .create = ripngd_instance_create, .destroy = ripngd_instance_destroy, .get_keys = ripngd_instance_get_keys, @@ -30,28 +30,24 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance/allow-ecmp", .cbs = { - .cli_show = cli_show_ripng_allow_ecmp, .modify = ripngd_instance_allow_ecmp_modify, }, }, { .xpath = "/frr-ripngd:ripngd/instance/default-information-originate", .cbs = { - .cli_show = cli_show_ripng_default_information_originate, .modify = ripngd_instance_default_information_originate_modify, }, }, { .xpath = "/frr-ripngd:ripngd/instance/default-metric", .cbs = { - .cli_show = cli_show_ripng_default_metric, .modify = ripngd_instance_default_metric_modify, }, }, { .xpath = "/frr-ripngd:ripngd/instance/network", .cbs = { - .cli_show = cli_show_ripng_network_prefix, .create = ripngd_instance_network_create, .destroy = ripngd_instance_network_destroy, }, @@ -59,7 +55,6 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance/interface", .cbs = { - .cli_show = cli_show_ripng_network_interface, .create = ripngd_instance_interface_create, .destroy = ripngd_instance_interface_destroy, }, @@ -67,7 +62,6 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance/offset-list", .cbs = { - .cli_show = cli_show_ripng_offset_list, .create = ripngd_instance_offset_list_create, .destroy = ripngd_instance_offset_list_destroy, }, @@ -87,16 +81,49 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance/passive-interface", .cbs = { - .cli_show = cli_show_ripng_passive_interface, .create = ripngd_instance_passive_interface_create, .destroy = ripngd_instance_passive_interface_destroy, }, }, { + .xpath = "/frr-ripngd:ripngd/instance/distribute-list", + .cbs = { + .create = ripngd_instance_distribute_list_create, + .destroy = group_distribute_list_destroy, + } + }, + { + .xpath = "/frr-ripngd:ripngd/instance/distribute-list/in/access-list", + .cbs = { + .modify = group_distribute_list_ipv6_modify, + .destroy = group_distribute_list_ipv6_destroy, + } + }, + { + .xpath = "/frr-ripngd:ripngd/instance/distribute-list/out/access-list", + .cbs = { + .modify = group_distribute_list_ipv6_modify, + .destroy = group_distribute_list_ipv6_destroy, + } + }, + { + .xpath = "/frr-ripngd:ripngd/instance/distribute-list/in/prefix-list", + .cbs = { + .modify = group_distribute_list_ipv6_modify, + .destroy = group_distribute_list_ipv6_destroy, + } + }, + { + .xpath = "/frr-ripngd:ripngd/instance/distribute-list/out/prefix-list", + .cbs = { + .modify = group_distribute_list_ipv6_modify, + .destroy = group_distribute_list_ipv6_destroy, + } + }, + { .xpath = "/frr-ripngd:ripngd/instance/redistribute", .cbs = { .apply_finish = ripngd_instance_redistribute_apply_finish, - .cli_show = cli_show_ripng_redistribute, .create = ripngd_instance_redistribute_create, .destroy = ripngd_instance_redistribute_destroy, }, @@ -120,7 +147,6 @@ const struct frr_yang_module_info frr_ripngd_info = { .cbs = { .create = ripngd_instance_if_route_maps_if_route_map_create, .destroy = ripngd_instance_if_route_maps_if_route_map_destroy, - .cli_show = cli_show_if_route_map, } }, { @@ -140,7 +166,6 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance/static-route", .cbs = { - .cli_show = cli_show_ripng_route, .create = ripngd_instance_static_route_create, .destroy = ripngd_instance_static_route_destroy, }, @@ -148,7 +173,6 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance/aggregate-address", .cbs = { - .cli_show = cli_show_ripng_aggregate_address, .create = ripngd_instance_aggregate_address_create, .destroy = ripngd_instance_aggregate_address_destroy, }, @@ -157,7 +181,6 @@ const struct frr_yang_module_info frr_ripngd_info = { .xpath = "/frr-ripngd:ripngd/instance/timers", .cbs = { .apply_finish = ripngd_instance_timers_apply_finish, - .cli_show = cli_show_ripng_timers, }, }, { @@ -251,7 +274,6 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-interface:lib/interface/frr-ripngd:ripng/split-horizon", .cbs = { - .cli_show = cli_show_ipv6_ripng_split_horizon, .modify = lib_interface_ripng_split_horizon_modify, }, }, diff --git a/ripngd/ripng_nb.h b/ripngd/ripng_nb.h index 1c0e63c..790a50f 100644 --- a/ripngd/ripng_nb.h +++ b/ripngd/ripng_nb.h @@ -7,7 +7,10 @@ #ifndef _FRR_RIPNG_NB_H_ #define _FRR_RIPNG_NB_H_ +#include "northbound.h" + extern const struct frr_yang_module_info frr_ripngd_info; +extern const struct frr_yang_module_info frr_ripngd_cli_info; /* Mandatory callbacks. */ int ripngd_instance_create(struct nb_cb_create_args *args); @@ -30,6 +33,8 @@ int ripngd_instance_offset_list_access_list_modify( int ripngd_instance_offset_list_metric_modify(struct nb_cb_modify_args *args); int ripngd_instance_passive_interface_create(struct nb_cb_create_args *args); int ripngd_instance_passive_interface_destroy(struct nb_cb_destroy_args *args); +int ripngd_instance_distribute_list_create(struct nb_cb_create_args *args); +int ripngd_instance_distribute_list_destroy(struct nb_cb_destroy_args *args); int ripngd_instance_redistribute_create(struct nb_cb_create_args *args); int ripngd_instance_redistribute_destroy(struct nb_cb_destroy_args *args); int ripngd_instance_redistribute_route_map_modify( @@ -102,6 +107,7 @@ void ripngd_instance_timers_apply_finish(struct nb_cb_apply_finish_args *args); /* Optional 'cli_show' callbacks. */ void cli_show_router_ripng(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_end_router_ripng(struct vty *vty, const struct lyd_node *dnode); void cli_show_ripng_allow_ecmp(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); void cli_show_ripng_default_information_originate(struct vty *vty, @@ -134,4 +140,6 @@ void cli_show_ipv6_ripng_split_horizon(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +extern void ripng_cli_init(void); + #endif /* _FRR_RIPNG_NB_H_ */ diff --git a/ripngd/ripng_nb_config.c b/ripngd/ripng_nb_config.c index 0b1bd68..d05d91c 100644 --- a/ripngd/ripng_nb_config.c +++ b/ripngd/ripng_nb_config.c @@ -35,7 +35,7 @@ int ripngd_instance_create(struct nb_cb_create_args *args) const char *vrf_name; int socket; - vrf_name = yang_dnode_get_string(args->dnode, "./vrf"); + vrf_name = yang_dnode_get_string(args->dnode, "vrf"); vrf = vrf_lookup_by_name(vrf_name); /* @@ -262,7 +262,7 @@ int ripngd_instance_offset_list_create(struct nb_cb_create_args *args) return NB_OK; ripng = nb_running_get_entry(args->dnode, NULL, true); - ifname = yang_dnode_get_string(args->dnode, "./interface"); + ifname = yang_dnode_get_string(args->dnode, "interface"); offset = ripng_offset_list_new(ripng, ifname); nb_running_set_entry(args->dnode, offset); @@ -278,7 +278,7 @@ int ripngd_instance_offset_list_destroy(struct nb_cb_destroy_args *args) if (args->event != NB_EV_APPLY) return NB_OK; - direct = yang_dnode_get_enum(args->dnode, "./direction"); + direct = yang_dnode_get_enum(args->dnode, "direction"); offset = nb_running_unset_entry(args->dnode); if (offset->direct[direct].alist_name) { @@ -369,6 +369,22 @@ int ripngd_instance_passive_interface_destroy(struct nb_cb_destroy_args *args) } /* + * XPath: /frr-ripng:ripng/instance/distribute-list + */ +int ripngd_instance_distribute_list_create(struct nb_cb_create_args *args) +{ + struct ripng *ripng; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + ripng = nb_running_get_entry(args->dnode, NULL, true); + group_distribute_list_create_helper(args, ripng->distribute_ctx); + + return NB_OK; +} + +/* * XPath: /frr-ripngd:ripngd/instance/redistribute */ int ripngd_instance_redistribute_create(struct nb_cb_create_args *args) @@ -380,7 +396,7 @@ int ripngd_instance_redistribute_create(struct nb_cb_create_args *args) return NB_OK; ripng = nb_running_get_entry(args->dnode, NULL, true); - type = yang_dnode_get_enum(args->dnode, "./protocol"); + type = yang_dnode_get_enum(args->dnode, "protocol"); ripng->redist[type].enabled = true; @@ -396,7 +412,7 @@ int ripngd_instance_redistribute_destroy(struct nb_cb_destroy_args *args) return NB_OK; ripng = nb_running_get_entry(args->dnode, NULL, true); - type = yang_dnode_get_enum(args->dnode, "./protocol"); + type = yang_dnode_get_enum(args->dnode, "protocol"); ripng->redist[type].enabled = false; if (ripng->redist[type].route_map.name) { @@ -420,7 +436,7 @@ void ripngd_instance_redistribute_apply_finish( int type; ripng = nb_running_get_entry(args->dnode, NULL, true); - type = yang_dnode_get_enum(args->dnode, "./protocol"); + type = yang_dnode_get_enum(args->dnode, "protocol"); if (ripng->enabled) ripng_redistribute_conf_update(ripng, type); diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c index 901b548..247bac4 100644 --- a/ripngd/ripng_peer.c +++ b/ripngd/ripng_peer.c @@ -15,6 +15,7 @@ #include "linklist.h" #include "frrevent.h" #include "memory.h" +#include "frrdistance.h" #include "ripngd/ripngd.h" #include "ripngd/ripng_nexthop.h" diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c index b5f74be..3370546 100644 --- a/ripngd/ripng_routemap.c +++ b/ripngd/ripng_routemap.c @@ -386,7 +386,7 @@ static const struct route_map_rule_cmd route_set_tag_cmd = { void ripng_route_map_init(void) { - route_map_init(); + route_map_init_new(true); route_map_match_interface_hook(generic_match_add); route_map_no_match_interface_hook(generic_match_delete); diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 465b40b..80b9013 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -23,6 +23,7 @@ #include "lib_errors.h" #include "northbound_cli.h" #include "network.h" +#include "mgmt_be_client.h" #include "ripngd/ripngd.h" #include "ripngd/ripng_route.h" @@ -392,11 +393,10 @@ static void ripng_nexthop_rte(struct rte *rte, struct sockaddr_in6 *from, /* If ifp has same link-local address then return 1. */ static int ripng_lladdr_check(struct interface *ifp, struct in6_addr *addr) { - struct listnode *node; struct connected *connected; struct prefix *p; - for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) { + frr_each (if_connected, ifp->connected, connected) { p = connected->address; if (p->family == AF_INET6 @@ -2231,6 +2231,38 @@ DEFUN (show_ipv6_ripng_status, return CMD_SUCCESS; } +#include "ripngd/ripngd_clippy.c" + +/* + * XPath: /frr-ripngd:clear-ripng-route + */ +DEFPY_YANG (clear_ipv6_rip, + clear_ipv6_rip_cmd, + "clear ipv6 ripng [vrf WORD]", + CLEAR_STR + IPV6_STR + "Clear IPv6 RIP database\n" + VRF_CMD_HELP_STR) +{ + struct list *input; + int ret; + + input = list_new(); + if (vrf) { + struct yang_data *yang_vrf; + + yang_vrf = yang_data_new( + "/frr-ripngd:clear-ripng-route/input/vrf", vrf); + listnode_add(input, yang_vrf); + } + + ret = nb_cli_rpc(vty, "/frr-ripngd:clear-ripng-route", input, NULL); + + list_delete(&input); + + return ret; +} + /* Update ECMP routes to zebra when ECMP is disabled. */ void ripng_ecmp_disable(struct ripng *ripng) { @@ -2268,45 +2300,6 @@ void ripng_ecmp_disable(struct ripng *ripng) } } -/* RIPng configuration write function. */ -static int ripng_config_write(struct vty *vty) -{ - struct ripng *ripng; - int write = 0; - - RB_FOREACH(ripng, ripng_instance_head, &ripng_instances) { - char xpath[XPATH_MAXLEN]; - struct lyd_node *dnode; - - snprintf(xpath, sizeof(xpath), - "/frr-ripngd:ripngd/instance[vrf='%s']", - ripng->vrf_name); - - dnode = yang_dnode_get(running_config->dnode, xpath); - assert(dnode); - - nb_cli_show_dnode_cmds(vty, dnode, false); - - config_write_distribute(vty, ripng->distribute_ctx); - - vty_out(vty, "exit\n"); - - write = 1; - } - - return write; -} - -static int ripng_config_write(struct vty *vty); -/* RIPng node structure. */ -static struct cmd_node cmd_ripng_node = { - .name = "ripng", - .node = RIPNG_NODE, - .parent_node = CONFIG_NODE, - .prompt = "%s(config-router)# ", - .config_write = ripng_config_write, -}; - static void ripng_distribute_update(struct distribute_ctx *ctx, struct distribute *dist) { @@ -2674,8 +2667,6 @@ void ripng_vrf_init(void) { vrf_init(ripng_vrf_new, ripng_vrf_enable, ripng_vrf_disable, ripng_vrf_delete); - - vrf_cmd_init(NULL); } void ripng_vrf_terminate(void) @@ -2686,20 +2677,19 @@ void ripng_vrf_terminate(void) /* Initialize ripng structure and set commands. */ void ripng_init(void) { - /* Install RIPNG_NODE. */ - install_node(&cmd_ripng_node); - /* Install ripng commands. */ install_element(VIEW_NODE, &show_ipv6_ripng_cmd); install_element(VIEW_NODE, &show_ipv6_ripng_status_cmd); - - install_default(RIPNG_NODE); + install_element(ENABLE_NODE, &clear_ipv6_rip_cmd); ripng_if_init(); ripng_debug_init(); + /* Enable mgmt be debug */ + mgmt_be_client_lib_vty_init(); + /* Access list install. */ - access_list_init(); + access_list_init_new(true); access_list_add_hook(ripng_distribute_update_all_wrapper); access_list_delete_hook(ripng_distribute_update_all_wrapper); @@ -2713,6 +2703,4 @@ void ripng_init(void) route_map_add_hook(ripng_routemap_update); route_map_delete_hook(ripng_routemap_update); - - if_rmap_init(RIPNG_NODE); } diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h index 3a2bc0c..a316f2b 100644 --- a/ripngd/ripngd.h +++ b/ripngd/ripngd.h @@ -16,7 +16,6 @@ /* RIPng version and port number. */ #define RIPNG_V1 1 #define RIPNG_PORT_DEFAULT 521 -#define RIPNG_VTY_PORT 2603 #define RIPNG_MAX_PACKET_SIZE 1500 #define RIPNG_PRIORITY_DEFAULT 0 @@ -432,7 +431,6 @@ extern void ripng_ecmp_change(struct ripng *ripng); extern void ripng_vrf_init(void); extern void ripng_vrf_terminate(void); -extern void ripng_cli_init(void); extern uint32_t zebra_ecmp_count; diff --git a/ripngd/subdir.am b/ripngd/subdir.am index 162426c..a881144 100644 --- a/ripngd/subdir.am +++ b/ripngd/subdir.am @@ -9,7 +9,6 @@ man8 += $(MANBUILD)/frr-ripngd.8 endif ripngd_ripngd_SOURCES = \ - ripngd/ripng_cli.c \ ripngd/ripng_debug.c \ ripngd/ripng_interface.c \ ripngd/ripng_nexthop.c \ @@ -28,6 +27,7 @@ ripngd_ripngd_SOURCES = \ clippy_scan += \ ripngd/ripng_cli.c \ + ripngd/ripngd.c \ # end noinst_HEADERS += \ |