summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:32 +0000
commit35cadacd2bb9383686753731e31bd7e145fb2506 (patch)
tree4489adbde75a837989533837185b2b8369a0bf68 /ripd
parentAdding debian version 9.1-0.1. (diff)
downloadfrr-35cadacd2bb9383686753731e31bd7e145fb2506.tar.xz
frr-35cadacd2bb9383686753731e31bd7e145fb2506.zip
Merging upstream version 10.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--ripd/rip_cli.c394
-rw-r--r--ripd/rip_interface.c29
-rw-r--r--ripd/rip_main.c44
-rw-r--r--ripd/rip_nb.c82
-rw-r--r--ripd/rip_nb.h8
-rw-r--r--ripd/rip_nb_config.c37
-rw-r--r--ripd/rip_peer.c1
-rw-r--r--ripd/rip_routemap.c2
-rw-r--r--ripd/rip_snmp.c2
-rw-r--r--ripd/rip_zebra.c2
-rw-r--r--ripd/ripd.c94
-rw-r--r--ripd/ripd.h2
-rw-r--r--ripd/subdir.am2
13 files changed, 471 insertions, 228 deletions
diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c
index 097c708..4d4349b 100644
--- a/ripd/rip_cli.c
+++ b/ripd/rip_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_rip(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 rip");
@@ -82,6 +83,11 @@ void cli_show_router_rip(struct vty *vty, const struct lyd_node *dnode,
vty_out(vty, "\n");
}
+void cli_show_end_router_rip(struct vty *vty, const struct lyd_node *dnode)
+{
+ vty_out(vty, "exit\n");
+}
+
/*
* XPath: /frr-ripd:ripd/instance/allow-ecmp
*/
@@ -255,11 +261,11 @@ void cli_show_rip_distance_source(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults)
{
vty_out(vty, " distance %s %s",
- yang_dnode_get_string(dnode, "./distance"),
- yang_dnode_get_string(dnode, "./prefix"));
- if (yang_dnode_exists(dnode, "./access-list"))
+ yang_dnode_get_string(dnode, "distance"),
+ yang_dnode_get_string(dnode, "prefix"));
+ if (yang_dnode_exists(dnode, "access-list"))
vty_out(vty, " %s",
- yang_dnode_get_string(dnode, "./access-list"));
+ yang_dnode_get_string(dnode, "access-list"));
vty_out(vty, "\n");
}
@@ -273,8 +279,13 @@ DEFPY_YANG (rip_neighbor,
"Specify a neighbor router\n"
"Neighbor address\n")
{
- nb_cli_enqueue_change(vty, "./explicit-neighbor",
- no ? NB_OP_DESTROY : NB_OP_CREATE, neighbor_str);
+ char xpath[XPATH_MAXLEN];
+
+ snprintf(xpath, sizeof(xpath), "./explicit-neighbor[.='%s']",
+ neighbor_str);
+
+ nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE,
+ NULL);
return nb_cli_apply_changes(vty, NULL);
}
@@ -295,8 +306,12 @@ DEFPY_YANG (rip_network_prefix,
"Enable routing on an IP network\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\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);
}
@@ -317,8 +332,12 @@ DEFPY_YANG (rip_network_if,
"Enable routing on an IP 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);
}
@@ -362,12 +381,12 @@ void cli_show_rip_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");
@@ -412,17 +431,21 @@ DEFPY_YANG (rip_passive_interface,
bool passive_default =
yang_dnode_get_bool(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, "/passive-default");
+ char xpath[XPATH_MAXLEN];
+ enum nb_operation op;
if (passive_default) {
- nb_cli_enqueue_change(vty, "./non-passive-interface",
- no ? NB_OP_CREATE : NB_OP_DESTROY,
- ifname);
+ snprintf(xpath, sizeof(xpath),
+ "./non-passive-interface[.='%s']", ifname);
+ op = no ? NB_OP_CREATE : NB_OP_DESTROY;
} else {
- nb_cli_enqueue_change(vty, "./passive-interface",
- no ? NB_OP_DESTROY : NB_OP_CREATE,
- ifname);
+ snprintf(xpath, sizeof(xpath), "./passive-interface[.='%s']",
+ ifname);
+ op = no ? NB_OP_DESTROY : NB_OP_CREATE;
}
+ nb_cli_enqueue_change(vty, xpath, op, NULL);
+
return nb_cli_apply_changes(vty, NULL);
}
@@ -475,13 +498,13 @@ void cli_show_rip_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");
}
@@ -495,8 +518,12 @@ DEFPY_YANG (rip_route,
"RIP static route configuration\n"
"IP prefix <network>/<length>\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);
}
@@ -550,9 +577,9 @@ void cli_show_rip_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"));
}
/*
@@ -591,7 +618,7 @@ void cli_show_rip_version(struct vty *vty, const struct lyd_node *dnode,
* We have only one "version" command and three possible combinations of
* send/receive values.
*/
- switch (yang_dnode_get_enum(dnode, "./receive")) {
+ switch (yang_dnode_get_enum(dnode, "receive")) {
case RI_RIP_VERSION_1:
vty_out(vty, " version 1\n");
break;
@@ -912,7 +939,7 @@ void cli_show_ip_rip_authentication_scheme(struct vty *vty,
const struct lyd_node *dnode,
bool show_defaults)
{
- switch (yang_dnode_get_enum(dnode, "./mode")) {
+ switch (yang_dnode_get_enum(dnode, "mode")) {
case RIP_NO_AUTH:
vty_out(vty, " no ip rip authentication mode\n");
break;
@@ -922,8 +949,8 @@ void cli_show_ip_rip_authentication_scheme(struct vty *vty,
case RIP_AUTH_MD5:
vty_out(vty, " ip rip authentication mode md5");
if (show_defaults
- || !yang_dnode_is_default(dnode, "./md5-auth-length")) {
- if (yang_dnode_get_enum(dnode, "./md5-auth-length")
+ || !yang_dnode_is_default(dnode, "md5-auth-length")) {
+ if (yang_dnode_get_enum(dnode, "md5-auth-length")
== RIP_AUTH_MD5_SIZE)
vty_out(vty, " auth-length rfc");
else
@@ -1098,85 +1125,134 @@ void cli_show_ip_rip_bfd_profile(struct vty *vty, const struct lyd_node *dnode,
yang_dnode_get_string(dnode, NULL));
}
-/*
- * XPath: /frr-ripd:clear-rip-route
- */
-DEFPY_YANG (clear_ip_rip,
- clear_ip_rip_cmd,
- "clear ip rip [vrf WORD]",
- CLEAR_STR
- IP_STR
- "Clear IP RIP database\n"
- VRF_CMD_HELP_STR)
+DEFPY_YANG(
+ rip_distribute_list, rip_distribute_list_cmd,
+ "distribute-list ACCESSLIST4_NAME$name <in|out>$dir [WORD$ifname]",
+ "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-ripd:clear-rip-route/input/vrf",
- vrf);
- listnode_add(input, yang_vrf);
- }
-
- ret = nb_cli_rpc(vty, "/frr-ripd:clear-rip-route", input, NULL);
-
- list_delete(&input);
+ char xpath[XPATH_MAXLEN];
- return ret;
+ 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);
}
-DEFUN (rip_distribute_list,
- rip_distribute_list_cmd,
- "distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
- "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(
+ rip_distribute_list_prefix, rip_distribute_list_prefix_cmd,
+ "distribute-list prefix PREFIXLIST4_NAME$name <in|out>$dir [WORD$ifname]",
+ "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[1]->type == WORD_TKN) ? 1 : 0;
-
- if (argv[argc - 1]->type == VARIABLE_TKN)
- ifname = argv[argc - 1]->arg;
+ char xpath[XPATH_MAXLEN];
- return distribute_list_parser(prefix, true, argv[2 + prefix]->text,
- argv[1 + prefix]->arg, ifname);
+ 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 (rip_no_distribute_list,
- rip_no_distribute_list_cmd,
- "no distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
- NO_STR
- "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_rip_distribute_list,
+ no_rip_distribute_list_cmd,
+ "no distribute-list [ACCESSLIST4_NAME$name] <in|out>$dir [WORD$ifname]",
+ NO_STR
+ "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;
+ const struct lyd_node *value_node;
+ char xpath[XPATH_MAXLEN];
+
+ 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);
+}
- if (argv[argc - 1]->type == VARIABLE_TKN)
- ifname = argv[argc - 1]->arg;
+DEFPY_YANG(no_rip_distribute_list_prefix,
+ no_rip_distribute_list_prefix_cmd,
+ "no distribute-list prefix [PREFIXLIST4_NAME$name] <in|out>$dir [WORD$ifname]",
+ NO_STR
+ "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 struct lyd_node *value_node;
+ char xpath[XPATH_MAXLEN];
- return distribute_list_no_parser(vty, prefix, true,
- argv[3 + prefix]->text,
- argv[2 + 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);
}
+/* RIP node structure. */
+static struct cmd_node rip_node = {
+ .name = "rip",
+ .node = RIP_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-router)# ",
+ // .config_write = config_write_rip,
+};
+
void rip_cli_init(void)
{
+ install_node(&rip_node);
+
install_element(CONFIG_NODE, &router_rip_cmd);
install_element(CONFIG_NODE, &no_router_rip_cmd);
install_element(RIP_NODE, &rip_distribute_list_cmd);
- install_element(RIP_NODE, &rip_no_distribute_list_cmd);
+ install_element(RIP_NODE, &rip_distribute_list_prefix_cmd);
+ install_element(RIP_NODE, &no_rip_distribute_list_cmd);
+ install_element(RIP_NODE, &no_rip_distribute_list_prefix_cmd);
install_element(RIP_NODE, &rip_allow_ecmp_cmd);
install_element(RIP_NODE, &no_rip_allow_ecmp_cmd);
@@ -1200,6 +1276,7 @@ void rip_cli_init(void)
install_element(RIP_NODE, &no_rip_version_cmd);
install_element(RIP_NODE, &rip_bfd_default_profile_cmd);
install_element(RIP_NODE, &no_rip_bfd_default_profile_cmd);
+ install_default(RIP_NODE);
install_element(INTERFACE_NODE, &ip_rip_split_horizon_cmd);
install_element(INTERFACE_NODE, &ip_rip_v2_broadcast_cmd);
@@ -1218,5 +1295,128 @@ void rip_cli_init(void)
install_element(INTERFACE_NODE, &ip_rip_bfd_profile_cmd);
install_element(INTERFACE_NODE, &no_ip_rip_bfd_profile_cmd);
- install_element(ENABLE_NODE, &clear_ip_rip_cmd);
-}
+ if_rmap_init(RIP_NODE);
+}
+/* clang-format off */
+const struct frr_yang_module_info frr_ripd_cli_info = {
+ .name = "frr-ripd",
+ .ignore_cfg_cbs = true,
+ .nodes = {
+ {
+ .xpath = "/frr-ripd:ripd/instance",
+ .cbs.cli_show = cli_show_router_rip,
+ .cbs.cli_show_end = cli_show_end_router_rip,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/allow-ecmp",
+ .cbs.cli_show = cli_show_rip_allow_ecmp,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/default-information-originate",
+ .cbs.cli_show = cli_show_rip_default_information_originate,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/default-metric",
+ .cbs.cli_show = cli_show_rip_default_metric,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/distance/default",
+ .cbs.cli_show = cli_show_rip_distance,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/distance/source",
+ .cbs.cli_show = cli_show_rip_distance_source,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/explicit-neighbor",
+ .cbs.cli_show = cli_show_rip_neighbor,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/network",
+ .cbs.cli_show = cli_show_rip_network_prefix,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/interface",
+ .cbs.cli_show = cli_show_rip_network_interface,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/offset-list",
+ .cbs.cli_show = cli_show_rip_offset_list,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/passive-default",
+ .cbs.cli_show = cli_show_rip_passive_default,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/passive-interface",
+ .cbs.cli_show = cli_show_rip_passive_interface,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/non-passive-interface",
+ .cbs.cli_show = cli_show_rip_non_passive_interface,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/redistribute",
+ .cbs.cli_show = cli_show_rip_redistribute,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/if-route-maps/if-route-map",
+ .cbs.cli_show = cli_show_if_route_map,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/static-route",
+ .cbs.cli_show = cli_show_rip_route,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/timers",
+ .cbs.cli_show = cli_show_rip_timers,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/version",
+ .cbs.cli_show = cli_show_rip_version,
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/default-bfd-profile",
+ .cbs.cli_show = cli_show_ripd_instance_default_bfd_profile,
+ },
+ {
+ .xpath = "/frr-interface:lib/interface/frr-ripd:rip/split-horizon",
+ .cbs.cli_show = cli_show_ip_rip_split_horizon,
+ },
+ {
+ .xpath = "/frr-interface:lib/interface/frr-ripd:rip/v2-broadcast",
+ .cbs.cli_show = cli_show_ip_rip_v2_broadcast,
+ },
+ {
+ .xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-receive",
+ .cbs.cli_show = cli_show_ip_rip_receive_version,
+ },
+ {
+ .xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-send",
+ .cbs.cli_show = cli_show_ip_rip_send_version,
+ },
+ {
+ .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme",
+ .cbs.cli_show = cli_show_ip_rip_authentication_scheme,
+ },
+ {
+ .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-password",
+ .cbs.cli_show = cli_show_ip_rip_authentication_string,
+ },
+ {
+ .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain",
+ .cbs.cli_show = cli_show_ip_rip_authentication_key_chain,
+ },
+ {
+ .xpath = "/frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/enable",
+ .cbs.cli_show = cli_show_ip_rip_bfd_enable,
+ },
+ {
+ .xpath = "/frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/profile",
+ .cbs.cli_show = cli_show_ip_rip_bfd_profile,
+ },
+ {
+ .xpath = NULL,
+ },
+ }
+};
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 505290e..486d7b0 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -128,14 +128,12 @@ static void rip_request_interface_send(struct interface *ifp, uint8_t version)
/* RIPv1 and non multicast interface. */
if (if_is_pointopoint(ifp) || if_is_broadcast(ifp)) {
- struct listnode *cnode, *cnnode;
struct connected *connected;
if (IS_RIP_DEBUG_EVENT)
zlog_debug("broadcast request to %s", ifp->name);
- for (ALL_LIST_ELEMENTS(ifp->connected, cnode, cnnode,
- connected)) {
+ frr_each (if_connected, ifp->connected, connected) {
if (connected->address->family != AF_INET)
continue;
@@ -197,14 +195,13 @@ static void rip_request_interface(struct interface *ifp)
/* Multicast packet receive socket. */
static int rip_multicast_join(struct interface *ifp, int sock)
{
- struct listnode *cnode;
struct connected *ifc;
if (if_is_operative(ifp) && if_is_multicast(ifp)) {
if (IS_RIP_DEBUG_EVENT)
zlog_debug("multicast join at %s", ifp->name);
- for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) {
+ frr_each (if_connected, ifp->connected, ifc) {
struct prefix_ipv4 *p;
struct in_addr group;
@@ -228,14 +225,13 @@ static int rip_multicast_join(struct interface *ifp, int sock)
/* Leave from multicast group. */
static void rip_multicast_leave(struct interface *ifp, int sock)
{
- struct listnode *cnode;
struct connected *connected;
if (if_is_up(ifp) && if_is_multicast(ifp)) {
if (IS_RIP_DEBUG_EVENT)
zlog_debug("multicast leave from %s", ifp->name);
- for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
+ frr_each (if_connected, ifp->connected, connected) {
struct prefix_ipv4 *p;
struct in_addr group;
@@ -256,11 +252,10 @@ static void rip_multicast_leave(struct interface *ifp, int sock)
/* Is there and address on interface that I could use ? */
static int rip_if_ipv4_address_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;
@@ -279,10 +274,9 @@ int if_check_address(struct rip *rip, struct in_addr addr)
struct interface *ifp;
FOR_ALL_INTERFACES (rip->vrf, ifp) {
- struct listnode *cnode;
struct connected *connected;
- for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
+ frr_each (if_connected, ifp->connected, connected) {
struct prefix_ipv4 *p;
p = (struct prefix_ipv4 *)connected->address;
@@ -596,14 +590,13 @@ static int rip_enable_network_lookup_if(struct interface *ifp)
{
struct rip_interface *ri = ifp->info;
struct rip *rip = ri->rip;
- struct listnode *node, *nnode;
struct connected *connected;
struct prefix_ipv4 address;
if (!rip)
return -1;
- for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) {
+ frr_each (if_connected, ifp->connected, connected) {
struct prefix *p;
struct route_node *n;
@@ -780,14 +773,13 @@ static void rip_connect_set(struct interface *ifp, int set)
{
struct rip_interface *ri = ifp->info;
struct rip *rip = ri->rip;
- struct listnode *node, *nnode;
struct connected *connected;
struct prefix_ipv4 address;
struct nexthop nh;
memset(&nh, 0, sizeof(nh));
- for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) {
+ frr_each (if_connected, ifp->connected, connected) {
struct prefix *p;
p = connected->address;
@@ -1117,7 +1109,8 @@ void rip_if_init(void)
hook_register_prio(if_del, 0, rip_interface_delete_hook);
/* Install interface node. */
- if_cmd_init_default();
- if_zapi_callbacks(rip_ifp_create, rip_ifp_up,
- rip_ifp_down, rip_ifp_destroy);
+ hook_register_prio(if_real, 0, rip_ifp_create);
+ hook_register_prio(if_up, 0, rip_ifp_up);
+ hook_register_prio(if_down, 0, rip_ifp_down);
+ hook_register_prio(if_unreal, 0, rip_ifp_destroy);
}
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index ac358eb..845c507 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -22,6 +22,7 @@
#include "libfrr.h"
#include "routemap.h"
#include "bfd.h"
+#include "mgmt_be_client.h"
#include "ripd/ripd.h"
#include "ripd/rip_bfd.h"
@@ -53,6 +54,8 @@ struct zebra_privs_t ripd_privs = {
/* Master of threads. */
struct event_loop *master;
+struct mgmt_be_client *mgmt_be_client;
+
static struct frr_daemon_info ripd_di;
/* SIGHUP handler. */
@@ -67,12 +70,31 @@ static void sighup(void)
/* SIGINT handler. */
static void sigint(void)
{
+ struct vrf *vrf;
+
zlog_notice("Terminating on signal");
bfd_protocol_integration_set_shutdown(true);
+
+
+ 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;
+
+ rip_clean(vrf->info);
+ }
+
rip_vrf_terminate();
if_rmap_terminate();
rip_zclient_stop();
+
+ route_map_finish();
+
+ keychain_terminate();
frr_fini();
exit(0);
@@ -111,15 +133,23 @@ static const struct frr_yang_module_info *const ripd_yang_modules[] = {
&frr_vrf_info,
};
-FRR_DAEMON_INFO(ripd, RIP, .vty_port = RIP_VTY_PORT,
+/* clang-format off */
+FRR_DAEMON_INFO(ripd, RIP,
+ .vty_port = RIP_VTY_PORT,
+ .proghelp = "Implementation of the RIP routing protocol.",
- .proghelp = "Implementation of the RIP routing protocol.",
+ .signals = ripd_signals,
+ .n_signals = array_size(ripd_signals),
- .signals = ripd_signals, .n_signals = array_size(ripd_signals),
+ .privs = &ripd_privs,
- .privs = &ripd_privs, .yang_modules = ripd_yang_modules,
- .n_yang_modules = array_size(ripd_yang_modules),
+ .yang_modules = ripd_yang_modules,
+ .n_yang_modules = array_size(ripd_yang_modules),
+
+ /* mgmtd will load the per-daemon config file now */
+ .flags = FRR_NO_SPLIT_CONFIG,
);
+/* clang-format on */
#define DEPRECATED_OPTIONS ""
@@ -165,7 +195,9 @@ int main(int argc, char **argv)
/* RIP related initialization. */
rip_init();
rip_if_init();
- rip_cli_init();
+
+ mgmt_be_client = mgmt_be_client_create("ripd", NULL, 0, master);
+
rip_zclient_init(master);
rip_bfd_init(master);
diff --git a/ripd/rip_nb.c b/ripd/rip_nb.c
index d11f1e1..d5df591 100644
--- a/ripd/rip_nb.c
+++ b/ripd/rip_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 "ripd/rip_nb.h"
-#include "lib/if_rmap.h"
/* clang-format off */
const struct frr_yang_module_info frr_ripd_info = {
@@ -19,7 +20,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance",
.cbs = {
- .cli_show = cli_show_router_rip,
.create = ripd_instance_create,
.destroy = ripd_instance_destroy,
.get_keys = ripd_instance_get_keys,
@@ -30,35 +30,30 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/allow-ecmp",
.cbs = {
- .cli_show = cli_show_rip_allow_ecmp,
.modify = ripd_instance_allow_ecmp_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/default-information-originate",
.cbs = {
- .cli_show = cli_show_rip_default_information_originate,
.modify = ripd_instance_default_information_originate_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/default-metric",
.cbs = {
- .cli_show = cli_show_rip_default_metric,
.modify = ripd_instance_default_metric_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/distance/default",
.cbs = {
- .cli_show = cli_show_rip_distance,
.modify = ripd_instance_distance_default_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/distance/source",
.cbs = {
- .cli_show = cli_show_rip_distance_source,
.create = ripd_instance_distance_source_create,
.destroy = ripd_instance_distance_source_destroy,
},
@@ -79,7 +74,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/explicit-neighbor",
.cbs = {
- .cli_show = cli_show_rip_neighbor,
.create = ripd_instance_explicit_neighbor_create,
.destroy = ripd_instance_explicit_neighbor_destroy,
},
@@ -87,7 +81,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/network",
.cbs = {
- .cli_show = cli_show_rip_network_prefix,
.create = ripd_instance_network_create,
.destroy = ripd_instance_network_destroy,
},
@@ -95,7 +88,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/interface",
.cbs = {
- .cli_show = cli_show_rip_network_interface,
.create = ripd_instance_interface_create,
.destroy = ripd_instance_interface_destroy,
},
@@ -103,7 +95,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/offset-list",
.cbs = {
- .cli_show = cli_show_rip_offset_list,
.create = ripd_instance_offset_list_create,
.destroy = ripd_instance_offset_list_destroy,
},
@@ -123,14 +114,12 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/passive-default",
.cbs = {
- .cli_show = cli_show_rip_passive_default,
.modify = ripd_instance_passive_default_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/passive-interface",
.cbs = {
- .cli_show = cli_show_rip_passive_interface,
.create = ripd_instance_passive_interface_create,
.destroy = ripd_instance_passive_interface_destroy,
},
@@ -138,16 +127,53 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/non-passive-interface",
.cbs = {
- .cli_show = cli_show_rip_non_passive_interface,
.create = ripd_instance_non_passive_interface_create,
.destroy = ripd_instance_non_passive_interface_destroy,
},
},
{
+ .xpath = "/frr-ripd:ripd/instance/distribute-list",
+ .cbs = {
+ .create = ripd_instance_distribute_list_create,
+ .destroy = group_distribute_list_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/distribute-list/in/access-list",
+ .cbs = {
+ .modify = group_distribute_list_ipv4_modify,
+ .destroy = group_distribute_list_ipv4_destroy,
+ .cli_show = group_distribute_list_ipv4_cli_show,
+ }
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/distribute-list/out/access-list",
+ .cbs = {
+ .modify = group_distribute_list_ipv4_modify,
+ .destroy = group_distribute_list_ipv4_destroy,
+ .cli_show = group_distribute_list_ipv4_cli_show,
+ }
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/distribute-list/in/prefix-list",
+ .cbs = {
+ .modify = group_distribute_list_ipv4_modify,
+ .destroy = group_distribute_list_ipv4_destroy,
+ .cli_show = group_distribute_list_ipv4_cli_show,
+ }
+ },
+ {
+ .xpath = "/frr-ripd:ripd/instance/distribute-list/out/prefix-list",
+ .cbs = {
+ .modify = group_distribute_list_ipv4_modify,
+ .destroy = group_distribute_list_ipv4_destroy,
+ .cli_show = group_distribute_list_ipv4_cli_show,
+ }
+ },
+ {
.xpath = "/frr-ripd:ripd/instance/redistribute",
.cbs = {
.apply_finish = ripd_instance_redistribute_apply_finish,
- .cli_show = cli_show_rip_redistribute,
.create = ripd_instance_redistribute_create,
.destroy = ripd_instance_redistribute_destroy,
},
@@ -171,7 +197,6 @@ const struct frr_yang_module_info frr_ripd_info = {
.cbs = {
.create = ripd_instance_if_route_maps_if_route_map_create,
.destroy = ripd_instance_if_route_maps_if_route_map_destroy,
- .cli_show = cli_show_if_route_map,
}
},
{
@@ -191,7 +216,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/static-route",
.cbs = {
- .cli_show = cli_show_rip_route,
.create = ripd_instance_static_route_create,
.destroy = ripd_instance_static_route_destroy,
},
@@ -200,7 +224,6 @@ const struct frr_yang_module_info frr_ripd_info = {
.xpath = "/frr-ripd:ripd/instance/timers",
.cbs = {
.apply_finish = ripd_instance_timers_apply_finish,
- .cli_show = cli_show_rip_timers,
},
},
{
@@ -222,12 +245,6 @@ const struct frr_yang_module_info frr_ripd_info = {
},
},
{
- .xpath = "/frr-ripd:ripd/instance/version",
- .cbs = {
- .cli_show = cli_show_rip_version,
- },
- },
- {
.xpath = "/frr-ripd:ripd/instance/version/receive",
.cbs = {
.modify = ripd_instance_version_receive_modify,
@@ -244,44 +261,33 @@ const struct frr_yang_module_info frr_ripd_info = {
.cbs = {
.modify = ripd_instance_default_bfd_profile_modify,
.destroy = ripd_instance_default_bfd_profile_destroy,
- .cli_show = cli_show_ripd_instance_default_bfd_profile,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/split-horizon",
.cbs = {
- .cli_show = cli_show_ip_rip_split_horizon,
.modify = lib_interface_rip_split_horizon_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/v2-broadcast",
.cbs = {
- .cli_show = cli_show_ip_rip_v2_broadcast,
.modify = lib_interface_rip_v2_broadcast_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-receive",
.cbs = {
- .cli_show = cli_show_ip_rip_receive_version,
.modify = lib_interface_rip_version_receive_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-send",
.cbs = {
- .cli_show = cli_show_ip_rip_send_version,
.modify = lib_interface_rip_version_send_modify,
},
},
{
- .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme",
- .cbs = {
- .cli_show = cli_show_ip_rip_authentication_scheme,
- },
- },
- {
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/mode",
.cbs = {
.modify = lib_interface_rip_authentication_scheme_mode_modify,
@@ -297,7 +303,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-password",
.cbs = {
- .cli_show = cli_show_ip_rip_authentication_string,
.destroy = lib_interface_rip_authentication_password_destroy,
.modify = lib_interface_rip_authentication_password_modify,
},
@@ -305,7 +310,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain",
.cbs = {
- .cli_show = cli_show_ip_rip_authentication_key_chain,
.destroy = lib_interface_rip_authentication_key_chain_destroy,
.modify = lib_interface_rip_authentication_key_chain_modify,
},
@@ -320,14 +324,12 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/enable",
.cbs = {
- .cli_show = cli_show_ip_rip_bfd_enable,
.modify = lib_interface_rip_bfd_enable_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/profile",
.cbs = {
- .cli_show = cli_show_ip_rip_bfd_profile,
.modify = lib_interface_rip_bfd_profile_modify,
.destroy = lib_interface_rip_bfd_profile_destroy,
},
diff --git a/ripd/rip_nb.h b/ripd/rip_nb.h
index 9929e09..ee592da 100644
--- a/ripd/rip_nb.h
+++ b/ripd/rip_nb.h
@@ -7,7 +7,10 @@
#ifndef _FRR_RIP_NB_H_
#define _FRR_RIP_NB_H_
+#include "northbound.h"
+
extern const struct frr_yang_module_info frr_ripd_info;
+extern const struct frr_yang_module_info frr_ripd_cli_info;
/* Mandatory callbacks. */
int ripd_instance_create(struct nb_cb_create_args *args);
@@ -45,6 +48,8 @@ int ripd_instance_passive_interface_destroy(struct nb_cb_destroy_args *args);
int ripd_instance_non_passive_interface_create(struct nb_cb_create_args *args);
int ripd_instance_non_passive_interface_destroy(
struct nb_cb_destroy_args *args);
+int ripd_instance_distribute_list_create(struct nb_cb_create_args *args);
+int ripd_instance_distribute_list_destroy(struct nb_cb_destroy_args *args);
int ripd_instance_redistribute_create(struct nb_cb_create_args *args);
int ripd_instance_redistribute_destroy(struct nb_cb_destroy_args *args);
int ripd_instance_redistribute_route_map_modify(struct nb_cb_modify_args *args);
@@ -168,6 +173,7 @@ void ripd_instance_timers_apply_finish(struct nb_cb_apply_finish_args *args);
/* Optional 'cli_show' callbacks. */
void cli_show_router_rip(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults);
+void cli_show_end_router_rip(struct vty *vty, const struct lyd_node *dnode);
void cli_show_rip_allow_ecmp(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_default_information_originate(struct vty *vty,
@@ -235,4 +241,6 @@ void cli_show_ip_rip_bfd_profile(struct vty *vty, const struct lyd_node *dnode,
extern void ripd_notif_send_auth_type_failure(const char *ifname);
extern void ripd_notif_send_auth_failure(const char *ifname);
+extern void rip_cli_init(void);
+
#endif /* _FRR_RIP_NB_H_ */
diff --git a/ripd/rip_nb_config.c b/ripd/rip_nb_config.c
index 8d3b670..fb75337 100644
--- a/ripd/rip_nb_config.c
+++ b/ripd/rip_nb_config.c
@@ -35,7 +35,7 @@ int ripd_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);
/*
@@ -189,7 +189,7 @@ int ripd_instance_distance_source_create(struct nb_cb_create_args *args)
if (args->event != NB_EV_APPLY)
return NB_OK;
- yang_dnode_get_ipv4p(&prefix, args->dnode, "./prefix");
+ yang_dnode_get_ipv4p(&prefix, args->dnode, "prefix");
apply_mask_ipv4(&prefix);
/* Get RIP distance node. */
@@ -395,7 +395,7 @@ int ripd_instance_offset_list_create(struct nb_cb_create_args *args)
return NB_OK;
rip = 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 = rip_offset_list_new(rip, ifname);
nb_running_set_entry(args->dnode, offset);
@@ -411,7 +411,7 @@ int ripd_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) {
@@ -548,6 +548,23 @@ int ripd_instance_non_passive_interface_destroy(struct nb_cb_destroy_args *args)
return rip_passive_nondefault_unset(rip, ifname);
}
+
+/*
+ * XPath: /frr-ripd:ripd/instance/distribute-list
+ */
+int ripd_instance_distribute_list_create(struct nb_cb_create_args *args)
+{
+ struct rip *rip;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ rip = nb_running_get_entry(args->dnode, NULL, true);
+ group_distribute_list_create_helper(args, rip->distribute_ctx);
+
+ return NB_OK;
+}
+
/*
* XPath: /frr-ripd:ripd/instance/redistribute
*/
@@ -560,7 +577,7 @@ int ripd_instance_redistribute_create(struct nb_cb_create_args *args)
return NB_OK;
rip = nb_running_get_entry(args->dnode, NULL, true);
- type = yang_dnode_get_enum(args->dnode, "./protocol");
+ type = yang_dnode_get_enum(args->dnode, "protocol");
rip->redist[type].enabled = true;
@@ -576,7 +593,7 @@ int ripd_instance_redistribute_destroy(struct nb_cb_destroy_args *args)
return NB_OK;
rip = nb_running_get_entry(args->dnode, NULL, true);
- type = yang_dnode_get_enum(args->dnode, "./protocol");
+ type = yang_dnode_get_enum(args->dnode, "protocol");
rip->redist[type].enabled = false;
if (rip->redist[type].route_map.name) {
@@ -600,7 +617,7 @@ void ripd_instance_redistribute_apply_finish(
int type;
rip = 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 (rip->enabled)
rip_redistribute_conf_update(rip, type);
@@ -1123,12 +1140,12 @@ int lib_interface_rip_bfd_create(struct nb_cb_create_args *args)
ifp = nb_running_get_entry(args->dnode, NULL, true);
ri = ifp->info;
- ri->bfd.enabled = yang_dnode_get_bool(args->dnode, "./enable");
+ ri->bfd.enabled = yang_dnode_get_bool(args->dnode, "enable");
XFREE(MTYPE_RIP_BFD_PROFILE, ri->bfd.profile);
- if (yang_dnode_exists(args->dnode, "./profile"))
+ if (yang_dnode_exists(args->dnode, "profile"))
ri->bfd.profile = XSTRDUP(
MTYPE_RIP_BFD_PROFILE,
- yang_dnode_get_string(args->dnode, "./profile"));
+ yang_dnode_get_string(args->dnode, "profile"));
rip_bfd_interface_update(ri);
diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c
index 3e8ddec..7e848be 100644
--- a/ripd/rip_peer.c
+++ b/ripd/rip_peer.c
@@ -12,6 +12,7 @@
#include "frrevent.h"
#include "memory.h"
#include "table.h"
+#include "frrdistance.h"
#include "ripd/ripd.h"
#include "ripd/rip_bfd.h"
diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c
index 2ae8857..be17277 100644
--- a/ripd/rip_routemap.c
+++ b/ripd/rip_routemap.c
@@ -531,7 +531,7 @@ static const struct route_map_rule_cmd route_set_tag_cmd = {
/* Route-map init */
void rip_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/ripd/rip_snmp.c b/ripd/rip_snmp.c
index 0e5d4d5..f6a7a82 100644
--- a/ripd/rip_snmp.c
+++ b/ripd/rip_snmp.c
@@ -195,7 +195,7 @@ static int rip_snmp_ifaddr_del(struct connected *ifc)
if (!rn)
return 0;
i = rn->info;
- if (!strncmp(i->name, ifp->name, INTERFACE_NAMSIZ)) {
+ if (!strncmp(i->name, ifp->name, IFNAMSIZ)) {
rn->info = NULL;
route_unlock_node(rn);
route_unlock_node(rn);
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c
index 36b58cb..ce94e8e 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -14,6 +14,8 @@
#include "log.h"
#include "vrf.h"
#include "bfd.h"
+#include "frrdistance.h"
+
#include "ripd/ripd.h"
#include "ripd/rip_debug.h"
#include "ripd/rip_interface.h"
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 7bfcaad..e3220a9 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -6,6 +6,11 @@
#include <zebra.h>
+#ifdef CRYPTO_OPENSSL
+#include <openssl/evp.h>
+#include <openssl/hmac.h>
+#endif
+
#include "vrf.h"
#include "if.h"
#include "command.h"
@@ -29,8 +34,10 @@
#include "privs.h"
#include "lib_errors.h"
#include "northbound_cli.h"
+#include "mgmt_be_client.h"
#include "network.h"
#include "lib/printfrr.h"
+#include "frrdistance.h"
#include "ripd/ripd.h"
#include "ripd/rip_nb.h"
@@ -403,7 +410,6 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p,
static int rip_nexthop_check(struct rip *rip, struct in_addr *addr)
{
struct interface *ifp;
- struct listnode *cnode;
struct connected *ifc;
struct prefix *p;
@@ -411,7 +417,7 @@ static int rip_nexthop_check(struct rip *rip, struct in_addr *addr)
invalid nexthop. */
FOR_ALL_INTERFACES (rip->vrf, ifp) {
- for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) {
+ frr_each (if_connected, ifp->connected, ifc) {
p = ifc->address;
if (p->family == AF_INET
@@ -2212,8 +2218,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
}
if (!suppress && rinfo->type == ZEBRA_ROUTE_CONNECT) {
- for (ALL_LIST_ELEMENTS_RO(ifc->ifp->connected,
- listnode, tmp_ifc))
+ frr_each (if_connected, ifc->ifp->connected,
+ tmp_ifc)
if (prefix_match((struct prefix *)p,
tmp_ifc->address)) {
suppress = 1;
@@ -2322,8 +2328,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
if (rinfo->metric_out != RIP_METRIC_INFINITY &&
rinfo->type == ZEBRA_ROUTE_CONNECT) {
- for (ALL_LIST_ELEMENTS_RO(ifc->ifp->connected,
- listnode, tmp_ifc))
+ frr_each (if_connected, ifc->ifp->connected,
+ tmp_ifc)
if (prefix_match((struct prefix *)p,
tmp_ifc->address)) {
rinfo->metric_out =
@@ -2436,7 +2442,6 @@ static void rip_update_interface(struct connected *ifc, uint8_t version,
/* Update send to all interface and neighbor. */
static void rip_update_process(struct rip *rip, int route_type)
{
- struct listnode *ifnode, *ifnnode;
struct connected *connected;
struct interface *ifp;
struct rip_interface *ri;
@@ -2475,8 +2480,7 @@ static void rip_update_process(struct rip *rip, int route_type)
ifp->ifindex);
/* send update on each connected network */
- for (ALL_LIST_ELEMENTS(ifp->connected, ifnode, ifnnode,
- connected)) {
+ frr_each (if_connected, ifp->connected, connected) {
if (connected->address->family == AF_INET) {
if (vsend & RIPv1)
rip_update_interface(connected, RIPv1,
@@ -2767,7 +2771,6 @@ int rip_request_send(struct sockaddr_in *to, struct interface *ifp,
{
struct rte *rte;
struct rip_packet rip_packet;
- struct listnode *node, *nnode;
memset(&rip_packet, 0, sizeof(rip_packet));
@@ -2791,7 +2794,7 @@ int rip_request_send(struct sockaddr_in *to, struct interface *ifp,
}
/* send request on each connected network */
- for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) {
+ frr_each (if_connected, ifp->connected, connected) {
struct prefix_ipv4 *p;
p = (struct prefix_ipv4 *)connected->address;
@@ -3251,45 +3254,38 @@ DEFUN (show_ip_rip_status,
return CMD_SUCCESS;
}
-/* RIP configuration write function. */
-static int config_write_rip(struct vty *vty)
-{
- struct rip *rip;
- int write = 0;
-
- RB_FOREACH(rip, rip_instance_head, &rip_instances) {
- char xpath[XPATH_MAXLEN];
- struct lyd_node *dnode;
-
- snprintf(xpath, sizeof(xpath),
- "/frr-ripd:ripd/instance[vrf='%s']", rip->vrf_name);
+#include "ripd/ripd_clippy.c"
- dnode = yang_dnode_get(running_config->dnode, xpath);
- assert(dnode);
+/*
+ * XPath: /frr-ripd:clear-rip-route
+ */
+DEFPY_YANG (clear_ip_rip,
+ clear_ip_rip_cmd,
+ "clear ip rip [vrf WORD]",
+ CLEAR_STR
+ IP_STR
+ "Clear IP RIP database\n"
+ VRF_CMD_HELP_STR)
+{
+ struct list *input;
+ int ret;
- nb_cli_show_dnode_cmds(vty, dnode, false);
+ input = list_new();
+ if (vrf) {
+ struct yang_data *yang_vrf;
- /* Distribute configuration. */
- config_write_distribute(vty, rip->distribute_ctx);
+ yang_vrf = yang_data_new("/frr-ripd:clear-rip-route/input/vrf",
+ vrf);
+ listnode_add(input, yang_vrf);
+ }
- vty_out(vty, "exit\n");
+ ret = nb_cli_rpc(vty, "/frr-ripd:clear-rip-route", input, NULL);
- write = 1;
- }
+ list_delete(&input);
- return write;
+ return ret;
}
-static int config_write_rip(struct vty *vty);
-/* RIP node structure. */
-static struct cmd_node rip_node = {
- .name = "rip",
- .node = RIP_NODE,
- .parent_node = CONFIG_NODE,
- .prompt = "%s(config-router)# ",
- .config_write = config_write_rip,
-};
-
/* Distribute-list update functions. */
static void rip_distribute_update(struct distribute_ctx *ctx,
struct distribute *dist)
@@ -3651,8 +3647,6 @@ static int rip_vrf_disable(struct vrf *vrf)
void rip_vrf_init(void)
{
vrf_init(rip_vrf_new, rip_vrf_enable, rip_vrf_disable, rip_vrf_delete);
-
- vrf_cmd_init(NULL);
}
void rip_vrf_terminate(void)
@@ -3663,20 +3657,18 @@ void rip_vrf_terminate(void)
/* Allocate new rip structure and set default value. */
void rip_init(void)
{
- /* Install top nodes. */
- install_node(&rip_node);
-
/* Install rip commands. */
install_element(VIEW_NODE, &show_ip_rip_cmd);
install_element(VIEW_NODE, &show_ip_rip_status_cmd);
-
- install_default(RIP_NODE);
+ install_element(ENABLE_NODE, &clear_ip_rip_cmd);
/* Debug related init. */
rip_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(rip_distribute_update_all_wrapper);
access_list_delete_hook(rip_distribute_update_all_wrapper);
@@ -3690,6 +3682,4 @@ void rip_init(void)
route_map_add_hook(rip_routemap_update);
route_map_delete_hook(rip_routemap_update);
-
- if_rmap_init(RIP_NODE);
}
diff --git a/ripd/ripd.h b/ripd/ripd.h
index ac4a51f..08f7a24 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -51,7 +51,6 @@
/* RIP port number. */
#define RIP_PORT_DEFAULT 520
-#define RIP_VTY_PORT 2602
/* Default configuration file name. */
#define RIPD_DEFAULT_CONFIG "ripd.conf"
@@ -526,7 +525,6 @@ extern int offset_list_cmp(struct rip_offset_list *o1,
extern void rip_vrf_init(void);
extern void rip_vrf_terminate(void);
-extern void rip_cli_init(void);
extern struct zebra_privs_t ripd_privs;
extern struct rip_instance_head rip_instances;
diff --git a/ripd/subdir.am b/ripd/subdir.am
index c793a6d..7fb3726 100644
--- a/ripd/subdir.am
+++ b/ripd/subdir.am
@@ -14,7 +14,6 @@ endif
ripd_ripd_SOURCES = \
ripd/rip_bfd.c \
- ripd/rip_cli.c \
ripd/rip_debug.c \
ripd/rip_errors.c \
ripd/rip_interface.c \
@@ -34,6 +33,7 @@ ripd_ripd_SOURCES = \
clippy_scan += \
ripd/rip_bfd.c \
ripd/rip_cli.c \
+ ripd/ripd.c \
# end
noinst_HEADERS += \