diff options
Diffstat (limited to 'ripd/rip_interface.c')
| -rw-r--r-- | ripd/rip_interface.c | 919 |
1 files changed, 111 insertions, 808 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index bbac1a0a00..96b1cd8938 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -35,6 +35,7 @@ #include "sockopt.h" #include "privs.h" #include "lib_errors.h" +#include "northbound_cli.h" #include "zebra/connected.h" @@ -66,7 +67,6 @@ vector rip_enable_interface; struct route_table *rip_enable_network; /* Vector to store passive-interface name. */ -static int passive_default; /* are we in passive-interface default mode? */ vector Vrip_passive_nondefault; /* Join to the RIP version 2 multicast group. */ @@ -158,34 +158,32 @@ static void rip_request_interface_send(struct interface *ifp, uint8_t version) for (ALL_LIST_ELEMENTS(ifp->connected, cnode, cnnode, connected)) { - if (connected->address->family == AF_INET) { - memset(&to, 0, sizeof(struct sockaddr_in)); - to.sin_port = htons(RIP_PORT_DEFAULT); - if (connected->destination) - /* use specified broadcast or peer - * destination addr */ - to.sin_addr = connected->destination->u - .prefix4; - else if (connected->address->prefixlen - < IPV4_MAX_PREFIXLEN) - /* calculate the appropriate broadcast - * address */ - to.sin_addr - .s_addr = ipv4_broadcast_addr( - connected->address->u.prefix4 - .s_addr, - connected->address->prefixlen); - else - /* do not know where to send the packet - */ - continue; - - if (IS_RIP_DEBUG_EVENT) - zlog_debug("SEND request to %s", - inet_ntoa(to.sin_addr)); - - rip_request_send(&to, ifp, version, connected); - } + if (connected->address->family != AF_INET) + continue; + + memset(&to, 0, sizeof(struct sockaddr_in)); + to.sin_port = htons(RIP_PORT_DEFAULT); + if (connected->destination) + /* use specified broadcast or peer + * destination addr */ + to.sin_addr = connected->destination->u.prefix4; + else if (connected->address->prefixlen + < IPV4_MAX_PREFIXLEN) + /* calculate the appropriate broadcast + * address */ + to.sin_addr.s_addr = ipv4_broadcast_addr( + connected->address->u.prefix4.s_addr, + connected->address->prefixlen); + else + /* do not know where to send the packet + */ + continue; + + if (IS_RIP_DEBUG_EVENT) + zlog_debug("SEND request to %s", + inet_ntoa(to.sin_addr)); + + rip_request_send(&to, ifp, version, connected); } } } @@ -194,6 +192,7 @@ static void rip_request_interface_send(struct interface *ifp, uint8_t version) static void rip_request_interface(struct interface *ifp) { struct rip_interface *ri; + int vsend; /* In default ripd doesn't send RIP_REQUEST to the loopback interface. */ @@ -207,17 +206,14 @@ static void rip_request_interface(struct interface *ifp) /* Fetch RIP interface information. */ ri = ifp->info; - /* If there is no version configuration in the interface, use rip's version setting. */ - { - int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ? rip->version_send - : ri->ri_send); - if (vsend & RIPv1) - rip_request_interface_send(ifp, RIPv1); - if (vsend & RIPv2) - rip_request_interface_send(ifp, RIPv2); - } + vsend = ((ri->ri_send == RI_RIP_UNSPEC) ? rip->version_send + : ri->ri_send); + if (vsend & RIPv1) + rip_request_interface_send(ifp, RIPv1); + if (vsend & RIPv2) + rip_request_interface_send(ifp, RIPv2); } #if 0 @@ -498,22 +494,21 @@ void rip_interfaces_clean(void) static void rip_interface_reset(struct rip_interface *ri) { - /* Default authentication type is simple password for Cisco - compatibility. */ - ri->auth_type = RIP_NO_AUTH; - ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE; + ri->auth_type = yang_get_default_enum("%s/authentication-scheme/mode", + RIP_IFACE); + ri->md5_auth_len = yang_get_default_enum( + "%s/authentication-scheme/md5-auth-length", RIP_IFACE); /* Set default split-horizon behavior. If the interface is Frame Relay or SMDS is enabled, the default value for split-horizon is off. But currently Zebra does detect Frame Relay or SMDS interface. So all interface is set to split horizon. */ - ri->split_horizon_default = RIP_SPLIT_HORIZON; - ri->split_horizon = ri->split_horizon_default; - - ri->ri_send = RI_RIP_UNSPEC; - ri->ri_receive = RI_RIP_UNSPEC; + ri->split_horizon = + yang_get_default_enum("%s/split-horizon", RIP_IFACE); - ri->v2_broadcast = 0; + ri->ri_send = yang_get_default_enum("%s/version-send", RIP_IFACE); + ri->ri_receive = yang_get_default_enum("%s/version-receive", RIP_IFACE); + ri->v2_broadcast = yang_get_default_bool("%s/v2-broadcast", RIP_IFACE); if (ri->auth_str) XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str); @@ -521,7 +516,6 @@ static void rip_interface_reset(struct rip_interface *ri) if (ri->key_chain) XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain); - ri->list[RIP_FILTER_IN] = NULL; ri->list[RIP_FILTER_OUT] = NULL; @@ -537,15 +531,6 @@ static void rip_interface_reset(struct rip_interface *ri) rip_interface_clean(ri); } -void rip_interfaces_reset(void) -{ - struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); - struct interface *ifp; - - FOR_ALL_INTERFACES (vrf, ifp) - rip_interface_reset(ifp->info); -} - int rip_if_down(struct interface *ifp) { struct route_node *rp; @@ -761,7 +746,7 @@ int rip_enable_network_lookup2(struct connected *connected) return -1; } /* Add RIP enable network. */ -static int rip_enable_network_add(struct prefix *p) +int rip_enable_network_add(struct prefix *p) { struct route_node *node; @@ -769,18 +754,18 @@ static int rip_enable_network_add(struct prefix *p) if (node->info) { route_unlock_node(node); - return -1; + return NB_ERR_INCONSISTENCY; } else node->info = (void *)1; /* XXX: One should find a better solution than a generic one */ rip_enable_apply_all(); - return 1; + return NB_OK; } /* Delete RIP enable network. */ -static int rip_enable_network_delete(struct prefix *p) +int rip_enable_network_delete(struct prefix *p) { struct route_node *node; @@ -797,9 +782,10 @@ static int rip_enable_network_delete(struct prefix *p) /* XXX: One should find a better solution than a generic one */ rip_enable_apply_all(); - return 1; + return NB_OK; } - return -1; + + return NB_ERR_INCONSISTENCY; } /* Check interface is enabled by ifname statement. */ @@ -816,31 +802,31 @@ static int rip_enable_if_lookup(const char *ifname) } /* Add interface to rip_enable_if. */ -static int rip_enable_if_add(const char *ifname) +int rip_enable_if_add(const char *ifname) { int ret; ret = rip_enable_if_lookup(ifname); if (ret >= 0) - return -1; + return NB_ERR_INCONSISTENCY; vector_set(rip_enable_interface, XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname)); rip_enable_apply_all(); /* TODOVJ */ - return 1; + return NB_OK; } /* Delete interface from rip_enable_if. */ -static int rip_enable_if_delete(const char *ifname) +int rip_enable_if_delete(const char *ifname) { int index; char *str; index = rip_enable_if_lookup(ifname); if (index < 0) - return -1; + return NB_ERR_INCONSISTENCY; str = vector_slot(rip_enable_interface, index); XFREE(MTYPE_RIP_INTERFACE_STRING, str); @@ -848,7 +834,7 @@ static int rip_enable_if_delete(const char *ifname) rip_enable_apply_all(); /* TODOVJ */ - return 1; + return NB_OK; } /* Join to multicast group and send request to the interface. */ @@ -959,25 +945,21 @@ void rip_enable_apply(struct interface *ifp) /* Update running status of the interface. */ if (ri->enable_network || ri->enable_interface) { - { - if (IS_RIP_DEBUG_EVENT) - zlog_debug("turn on %s", ifp->name); - - /* Add interface wake up thread. */ - thread_add_timer(master, rip_interface_wakeup, ifp, 1, - &ri->t_wakeup); - rip_connect_set(ifp, 1); - } - } else { - if (ri->running) { - /* Might as well clean up the route table as well - * rip_if_down sets to 0 ri->running, and displays "turn - *off %s" - **/ - rip_if_down(ifp); + if (IS_RIP_DEBUG_EVENT) + zlog_debug("turn on %s", ifp->name); + + /* Add interface wake up thread. */ + thread_add_timer(master, rip_interface_wakeup, ifp, 1, + &ri->t_wakeup); + rip_connect_set(ifp, 1); + } else if (ri->running) { + /* Might as well clean up the route table as well + * rip_if_down sets to 0 ri->running, and displays "turn + *off %s" + **/ + rip_if_down(ifp); - rip_connect_set(ifp, 0); - } + rip_connect_set(ifp, 0); } } @@ -1011,29 +993,29 @@ int rip_neighbor_lookup(struct sockaddr_in *from) } /* Add new RIP neighbor to the neighbor tree. */ -static int rip_neighbor_add(struct prefix_ipv4 *p) +int rip_neighbor_add(struct prefix_ipv4 *p) { struct route_node *node; node = route_node_get(rip->neighbor, (struct prefix *)p); if (node->info) - return -1; + return NB_ERR_INCONSISTENCY; node->info = rip->neighbor; - return 0; + return NB_OK; } /* Delete RIP neighbor from the neighbor tree. */ -static int rip_neighbor_delete(struct prefix_ipv4 *p) +int rip_neighbor_delete(struct prefix_ipv4 *p) { struct route_node *node; /* Lock for look up. */ node = route_node_lookup(rip->neighbor, (struct prefix *)p); if (!node) - return -1; + return NB_ERR_INCONSISTENCY; node->info = NULL; @@ -1043,7 +1025,7 @@ static int rip_neighbor_delete(struct prefix_ipv4 *p) /* Unlock real neighbor information lock. */ route_unlock_node(node); - return 0; + return NB_OK; } /* Clear all network and neighbor configuration. */ @@ -1085,11 +1067,14 @@ void rip_passive_interface_apply(struct interface *ifp) { struct rip_interface *ri; + if (rip == NULL) + return; + ri = ifp->info; ri->passive = ((rip_passive_nondefault_lookup(ifp->name) < 0) - ? passive_default - : !passive_default); + ? rip->passive_default + : !rip->passive_default); if (IS_RIP_DEBUG_ZEBRA) zlog_debug("interface %s: passive = %d", ifp->name, @@ -1106,27 +1091,35 @@ static void rip_passive_interface_apply_all(void) } /* Passive interface. */ -static int rip_passive_nondefault_set(struct vty *vty, const char *ifname) +int rip_passive_nondefault_set(const char *ifname) { if (rip_passive_nondefault_lookup(ifname) >= 0) - return CMD_WARNING_CONFIG_FAILED; + /* + * Don't return an error, this can happen after changing + * 'passive-default'. + */ + return NB_OK; vector_set(Vrip_passive_nondefault, XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname)); rip_passive_interface_apply_all(); - return CMD_SUCCESS; + return NB_OK; } -static int rip_passive_nondefault_unset(struct vty *vty, const char *ifname) +int rip_passive_nondefault_unset(const char *ifname) { int i; char *str; i = rip_passive_nondefault_lookup(ifname); if (i < 0) - return CMD_WARNING_CONFIG_FAILED; + /* + * Don't return an error, this can happen after changing + * 'passive-default'. + */ + return NB_OK; str = vector_slot(Vrip_passive_nondefault, i); XFREE(MTYPE_RIP_INTERFACE_STRING, str); @@ -1134,7 +1127,7 @@ static int rip_passive_nondefault_unset(struct vty *vty, const char *ifname) rip_passive_interface_apply_all(); - return CMD_SUCCESS; + return NB_OK; } /* Free all configured RIP passive-interface settings. */ @@ -1151,670 +1144,31 @@ void rip_passive_nondefault_clean(void) rip_passive_interface_apply_all(); } -/* RIP enable network or interface configuration. */ -DEFUN (rip_network, - rip_network_cmd, - "network <A.B.C.D/M|WORD>", - "Enable routing on an IP network\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Interface name\n") -{ - int idx_ipv4_word = 1; - int ret; - struct prefix_ipv4 p; - - ret = str2prefix_ipv4(argv[idx_ipv4_word]->arg, &p); - - if (ret) - ret = rip_enable_network_add((struct prefix *)&p); - else - ret = rip_enable_if_add(argv[idx_ipv4_word]->arg); - - if (ret < 0) { - vty_out(vty, "There is a same network configuration %s\n", - argv[idx_ipv4_word]->arg); - return CMD_WARNING_CONFIG_FAILED; - } - - return CMD_SUCCESS; -} - -/* RIP enable network or interface configuration. */ -DEFUN (no_rip_network, - no_rip_network_cmd, - "no network <A.B.C.D/M|WORD>", - NO_STR - "Enable routing on an IP network\n" - "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" - "Interface name\n") -{ - int idx_ipv4_word = 2; - int ret; - struct prefix_ipv4 p; - - ret = str2prefix_ipv4(argv[idx_ipv4_word]->arg, &p); - - if (ret) - ret = rip_enable_network_delete((struct prefix *)&p); - else - ret = rip_enable_if_delete(argv[idx_ipv4_word]->arg); - - if (ret < 0) { - vty_out(vty, "Can't find network configuration %s\n", - argv[idx_ipv4_word]->arg); - return CMD_WARNING_CONFIG_FAILED; - } - - return CMD_SUCCESS; -} - -/* RIP neighbor configuration set. */ -DEFUN (rip_neighbor, - rip_neighbor_cmd, - "neighbor A.B.C.D", - "Specify a neighbor router\n" - "Neighbor address\n") -{ - int idx_ipv4 = 1; - int ret; - struct prefix_ipv4 p; - - ret = str2prefix_ipv4(argv[idx_ipv4]->arg, &p); - - if (ret <= 0) { - vty_out(vty, "Please specify address by A.B.C.D\n"); - return CMD_WARNING_CONFIG_FAILED; - } - - rip_neighbor_add(&p); - - return CMD_SUCCESS; -} - -/* RIP neighbor configuration unset. */ -DEFUN (no_rip_neighbor, - no_rip_neighbor_cmd, - "no neighbor A.B.C.D", - NO_STR - "Specify a neighbor router\n" - "Neighbor address\n") -{ - int idx_ipv4 = 2; - int ret; - struct prefix_ipv4 p; - - ret = str2prefix_ipv4(argv[idx_ipv4]->arg, &p); - - if (ret <= 0) { - vty_out(vty, "Please specify address by A.B.C.D\n"); - return CMD_WARNING_CONFIG_FAILED; - } - - rip_neighbor_delete(&p); - - return CMD_SUCCESS; -} - -DEFUN (ip_rip_receive_version, - ip_rip_receive_version_cmd, - "ip rip receive version <(1-2)|none>", - IP_STR - "Routing Information Protocol\n" - "Advertisement reception\n" - "Version control\n" - "RIP version\n" - "None\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - int idx_type = 4; - struct rip_interface *ri; - - ri = ifp->info; - - switch (argv[idx_type]->arg[0]) { - case '1': - ri->ri_receive = RI_RIP_VERSION_1; - return CMD_SUCCESS; - case '2': - ri->ri_receive = RI_RIP_VERSION_2; - return CMD_SUCCESS; - case 'n': - ri->ri_receive = RI_RIP_VERSION_NONE; - return CMD_SUCCESS; - default: - break; - } - - return CMD_WARNING_CONFIG_FAILED; -} - -DEFUN (ip_rip_receive_version_1, - ip_rip_receive_version_1_cmd, - "ip rip receive version <1 2|2 1>", - IP_STR - "Routing Information Protocol\n" - "Advertisement reception\n" - "Version control\n" - "RIP version 1\n" - "RIP version 2\n" - "RIP version 2\n" - "RIP version 1\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - /* Version 1 and 2. */ - ri->ri_receive = RI_RIP_VERSION_1_AND_2; - return CMD_SUCCESS; -} - -DEFUN (no_ip_rip_receive_version, - no_ip_rip_receive_version_cmd, - "no ip rip receive version [(1-2)]", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Advertisement reception\n" - "Version control\n" - "RIP version\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - ri->ri_receive = RI_RIP_UNSPEC; - return CMD_SUCCESS; -} - - -DEFUN (ip_rip_send_version, - ip_rip_send_version_cmd, - "ip rip send version (1-2)", - IP_STR - "Routing Information Protocol\n" - "Advertisement transmission\n" - "Version control\n" - "RIP version\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - int idx_type = 4; - struct rip_interface *ri; - - ri = ifp->info; - - /* Version 1. */ - if (atoi(argv[idx_type]->arg) == 1) { - ri->ri_send = RI_RIP_VERSION_1; - return CMD_SUCCESS; - } - if (atoi(argv[idx_type]->arg) == 2) { - ri->ri_send = RI_RIP_VERSION_2; - return CMD_SUCCESS; - } - return CMD_WARNING_CONFIG_FAILED; -} - -DEFUN (ip_rip_send_version_1, - ip_rip_send_version_1_cmd, - "ip rip send version <1 2|2 1>", - IP_STR - "Routing Information Protocol\n" - "Advertisement transmission\n" - "Version control\n" - "RIP version 1\n" - "RIP version 2\n" - "RIP version 2\n" - "RIP version 1\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - /* Version 1 and 2. */ - ri->ri_send = RI_RIP_VERSION_1_AND_2; - return CMD_SUCCESS; -} - -DEFUN (no_ip_rip_send_version, - no_ip_rip_send_version_cmd, - "no ip rip send version [(1-2)]", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Advertisement transmission\n" - "Version control\n" - "RIP version\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - ri->ri_send = RI_RIP_UNSPEC; - return CMD_SUCCESS; -} - - -DEFUN (ip_rip_v2_broadcast, - ip_rip_v2_broadcast_cmd, - "ip rip v2-broadcast", - IP_STR - "Routing Information Protocol\n" - "Send ip broadcast v2 update\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - ri->v2_broadcast = 1; - return CMD_SUCCESS; -} - -DEFUN (no_ip_rip_v2_broadcast, - no_ip_rip_v2_broadcast_cmd, - "no ip rip v2-broadcast", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Send ip broadcast v2 update\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - ri->v2_broadcast = 0; - return CMD_SUCCESS; -} - -DEFUN (ip_rip_authentication_mode, - ip_rip_authentication_mode_cmd, - "ip rip authentication mode <md5|text> [auth-length <rfc|old-ripd>]", - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication mode\n" - "Keyed message digest\n" - "Clear text authentication\n" - "MD5 authentication data length\n" - "RFC compatible\n" - "Old ripd compatible\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - char *cryptmode = argv[4]->text; - char *authlen = (argc > 5) ? argv[6]->text : NULL; - struct rip_interface *ri; - int auth_type; - - ri = ifp->info; - - if (strmatch("md5", cryptmode)) - auth_type = RIP_AUTH_MD5; - else { - assert(strmatch("text", cryptmode)); - auth_type = RIP_AUTH_SIMPLE_PASSWORD; - } - - ri->auth_type = auth_type; - - if (argc > 5) { - if (auth_type != RIP_AUTH_MD5) { - vty_out(vty, - "auth length argument only valid for md5\n"); - return CMD_WARNING_CONFIG_FAILED; - } - if (strmatch("rfc", authlen)) - ri->md5_auth_len = RIP_AUTH_MD5_SIZE; - else { - assert(strmatch("old-ripd", authlen)); - ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE; - } - } - - return CMD_SUCCESS; -} - -DEFUN (no_ip_rip_authentication_mode, - no_ip_rip_authentication_mode_cmd, - "no ip rip authentication mode [<md5|text> [auth-length <rfc|old-ripd>]]", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication mode\n" - "Keyed message digest\n" - "Clear text authentication\n" - "MD5 authentication data length\n" - "RFC compatible\n" - "Old ripd compatible\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - ri->auth_type = RIP_NO_AUTH; - ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE; - - return CMD_SUCCESS; -} - -DEFUN (ip_rip_authentication_string, - ip_rip_authentication_string_cmd, - "ip rip authentication string LINE", - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication string\n" - "Authentication string\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - int idx_line = 4; - struct rip_interface *ri; - - ri = ifp->info; - - if (strlen(argv[idx_line]->arg) > 16) { - vty_out(vty, - "%% RIPv2 authentication string must be shorter than 16\n"); - return CMD_WARNING_CONFIG_FAILED; - } - - if (ri->key_chain) { - vty_out(vty, "%% key-chain configuration exists\n"); - return CMD_WARNING_CONFIG_FAILED; - } - - if (ri->auth_str) - XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str); - - ri->auth_str = XSTRDUP(MTYPE_RIP_INTERFACE_STRING, argv[idx_line]->arg); - - return CMD_SUCCESS; -} - -DEFUN (no_ip_rip_authentication_string, - no_ip_rip_authentication_string_cmd, - "no ip rip authentication string [LINE]", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication string\n" - "Authentication string\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - if (ri->auth_str) - XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str); - - return CMD_SUCCESS; -} - - -DEFUN (ip_rip_authentication_key_chain, - ip_rip_authentication_key_chain_cmd, - "ip rip authentication key-chain LINE", - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication key-chain\n" - "name of key-chain\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - int idx_line = 4; - struct rip_interface *ri; - - ri = ifp->info; - - if (ri->auth_str) { - vty_out(vty, "%% authentication string configuration exists\n"); - return CMD_WARNING_CONFIG_FAILED; - } - - if (ri->key_chain) - XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain); - - ri->key_chain = - XSTRDUP(MTYPE_RIP_INTERFACE_STRING, argv[idx_line]->arg); - - return CMD_SUCCESS; -} - -DEFUN (no_ip_rip_authentication_key_chain, - no_ip_rip_authentication_key_chain_cmd, - "no ip rip authentication key-chain [LINE]", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Authentication control\n" - "Authentication key-chain\n" - "name of key-chain\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - if (ri->key_chain) - XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain); - - return CMD_SUCCESS; -} - - -/* CHANGED: ip rip split-horizon - Cisco and Zebra's command is - ip split-horizon - */ -DEFUN (ip_rip_split_horizon, - ip_rip_split_horizon_cmd, - "ip rip split-horizon", - IP_STR - "Routing Information Protocol\n" - "Perform split horizon\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - ri->split_horizon = RIP_SPLIT_HORIZON; - return CMD_SUCCESS; -} - -DEFUN (ip_rip_split_horizon_poisoned_reverse, - ip_rip_split_horizon_poisoned_reverse_cmd, - "ip rip split-horizon poisoned-reverse", - IP_STR - "Routing Information Protocol\n" - "Perform split horizon\n" - "With poisoned-reverse\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - ri->split_horizon = RIP_SPLIT_HORIZON_POISONED_REVERSE; - return CMD_SUCCESS; -} - -/* CHANGED: no ip rip split-horizon - Cisco and Zebra's command is - no ip split-horizon - */ -DEFUN (no_ip_rip_split_horizon, - no_ip_rip_split_horizon_cmd, - "no ip rip split-horizon", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Perform split horizon\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - ri->split_horizon = RIP_NO_SPLIT_HORIZON; - return CMD_SUCCESS; -} - -DEFUN (no_ip_rip_split_horizon_poisoned_reverse, - no_ip_rip_split_horizon_poisoned_reverse_cmd, - "no ip rip split-horizon poisoned-reverse", - NO_STR - IP_STR - "Routing Information Protocol\n" - "Perform split horizon\n" - "With poisoned-reverse\n") -{ - VTY_DECLVAR_CONTEXT(interface, ifp); - struct rip_interface *ri; - - ri = ifp->info; - - switch (ri->split_horizon) { - case RIP_SPLIT_HORIZON_POISONED_REVERSE: - ri->split_horizon = RIP_SPLIT_HORIZON; - default: - break; - } - - return CMD_SUCCESS; -} - -DEFUN (rip_passive_interface, - rip_passive_interface_cmd, - "passive-interface <IFNAME|default>", - "Suppress routing updates on an interface\n" - "Interface name\n" - "default for all interfaces\n") -{ - if (argv[1]->type == WORD_TKN) { // user passed 'default' - passive_default = 1; - rip_passive_nondefault_clean(); - return CMD_SUCCESS; - } - if (passive_default) - return rip_passive_nondefault_unset(vty, argv[1]->arg); - else - return rip_passive_nondefault_set(vty, argv[1]->arg); -} - -DEFUN (no_rip_passive_interface, - no_rip_passive_interface_cmd, - "no passive-interface <IFNAME|default>", - NO_STR - "Suppress routing updates on an interface\n" - "Interface name\n" - "default for all interfaces\n") -{ - if (argv[2]->type == WORD_TKN) { - passive_default = 0; - rip_passive_nondefault_clean(); - return CMD_SUCCESS; - } - if (passive_default) - return rip_passive_nondefault_set(vty, argv[2]->arg); - else - return rip_passive_nondefault_unset(vty, argv[2]->arg); -} - /* Write rip configuration of each interface. */ static int rip_interface_config_write(struct vty *vty) { struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp; + int write = 0; FOR_ALL_INTERFACES (vrf, ifp) { - struct rip_interface *ri; - - ri = ifp->info; + struct lyd_node *dnode; - /* Do not display the interface if there is no - * configuration about it. - **/ - if ((!ifp->desc) - && (ri->split_horizon == ri->split_horizon_default) - && (ri->ri_send == RI_RIP_UNSPEC) - && (ri->ri_receive == RI_RIP_UNSPEC) - && (ri->auth_type != RIP_AUTH_MD5) && (!ri->v2_broadcast) - && (ri->md5_auth_len != RIP_AUTH_MD5_SIZE) - && (!ri->auth_str) && (!ri->key_chain)) + dnode = yang_dnode_get( + running_config->dnode, + "/frr-interface:lib/interface[name='%s'][vrf='%s']", + ifp->name, vrf->name); + if (dnode == NULL) continue; - vty_frame(vty, "interface %s\n", ifp->name); - - if (ifp->desc) - vty_out(vty, " description %s\n", ifp->desc); - - /* Split horizon. */ - if (ri->split_horizon != ri->split_horizon_default) { - switch (ri->split_horizon) { - case RIP_SPLIT_HORIZON: - vty_out(vty, " ip rip split-horizon\n"); - break; - case RIP_SPLIT_HORIZON_POISONED_REVERSE: - vty_out(vty, - " ip rip split-horizon poisoned-reverse\n"); - break; - case RIP_NO_SPLIT_HORIZON: - default: - vty_out(vty, " no ip rip split-horizon\n"); - break; - } - } - - /* RIP version setting. */ - if (ri->ri_send != RI_RIP_UNSPEC) - vty_out(vty, " ip rip send version %s\n", - lookup_msg(ri_version_msg, ri->ri_send, NULL)); - - if (ri->ri_receive != RI_RIP_UNSPEC) - vty_out(vty, " ip rip receive version %s \n", - lookup_msg(ri_version_msg, ri->ri_receive, - NULL)); - - if (ri->v2_broadcast) - vty_out(vty, " ip rip v2-broadcast\n"); - - /* RIP authentication. */ - if (ri->auth_type == RIP_AUTH_SIMPLE_PASSWORD) - vty_out(vty, " ip rip authentication mode text\n"); - - if (ri->auth_type == RIP_AUTH_MD5) { - vty_out(vty, " ip rip authentication mode md5"); - if (ri->md5_auth_len == RIP_AUTH_MD5_COMPAT_SIZE) - vty_out(vty, " auth-length old-ripd"); - else - vty_out(vty, " auth-length rfc"); - vty_out(vty, "\n"); - } - - if (ri->auth_str) - vty_out(vty, " ip rip authentication string %s\n", - ri->auth_str); - - if (ri->key_chain) - vty_out(vty, " ip rip authentication key-chain %s\n", - ri->key_chain); - - vty_endframe(vty, "!\n"); + write = 1; + nb_cli_show_dnode_cmds(vty, dnode, false); } - return 0; + + return write; } -int config_write_rip_network(struct vty *vty, int config_mode) +int rip_show_network_config(struct vty *vty) { unsigned int i; char *ifname; @@ -1824,34 +1178,19 @@ int config_write_rip_network(struct vty *vty, int config_mode) for (node = route_top(rip_enable_network); node; node = route_next(node)) if (node->info) - vty_out(vty, "%s%s/%d\n", - config_mode ? " network " : " ", + vty_out(vty, " %s/%u\n", inet_ntoa(node->p.u.prefix4), node->p.prefixlen); /* Interface name RIP enable statement. */ for (i = 0; i < vector_active(rip_enable_interface); i++) if ((ifname = vector_slot(rip_enable_interface, i)) != NULL) - vty_out(vty, "%s%s\n", - config_mode ? " network " : " ", ifname); + vty_out(vty, " %s\n", ifname); /* RIP neighbors listing. */ for (node = route_top(rip->neighbor); node; node = route_next(node)) if (node->info) - vty_out(vty, "%s%s\n", - config_mode ? " neighbor " : " ", - inet_ntoa(node->p.u.prefix4)); - - /* RIP passive interface listing. */ - if (config_mode) { - if (passive_default) - vty_out(vty, " passive-interface default\n"); - for (i = 0; i < vector_active(Vrip_passive_nondefault); i++) - if ((ifname = vector_slot(Vrip_passive_nondefault, i)) - != NULL) - vty_out(vty, " %spassive-interface %s\n", - (passive_default ? "no " : ""), ifname); - } + vty_out(vty, " %s\n", inet_ntoa(node->p.u.prefix4)); return 0; } @@ -1870,6 +1209,7 @@ static int rip_interface_new_hook(struct interface *ifp) /* Called when interface structure deleted. */ static int rip_interface_delete_hook(struct interface *ifp) { + rip_interface_reset(ifp->info); XFREE(MTYPE_RIP_INTERFACE, ifp->info); ifp->info = NULL; return 0; @@ -1892,41 +1232,4 @@ void rip_if_init(void) /* Install interface node. */ install_node(&interface_node, rip_interface_config_write); if_cmd_init(); - - /* Install commands. */ - install_element(RIP_NODE, &rip_network_cmd); - install_element(RIP_NODE, &no_rip_network_cmd); - install_element(RIP_NODE, &rip_neighbor_cmd); - install_element(RIP_NODE, &no_rip_neighbor_cmd); - - install_element(RIP_NODE, &rip_passive_interface_cmd); - install_element(RIP_NODE, &no_rip_passive_interface_cmd); - - install_element(INTERFACE_NODE, &ip_rip_send_version_cmd); - install_element(INTERFACE_NODE, &ip_rip_send_version_1_cmd); - install_element(INTERFACE_NODE, &no_ip_rip_send_version_cmd); - - install_element(INTERFACE_NODE, &ip_rip_receive_version_cmd); - install_element(INTERFACE_NODE, &ip_rip_receive_version_1_cmd); - install_element(INTERFACE_NODE, &no_ip_rip_receive_version_cmd); - - install_element(INTERFACE_NODE, &ip_rip_v2_broadcast_cmd); - install_element(INTERFACE_NODE, &no_ip_rip_v2_broadcast_cmd); - - install_element(INTERFACE_NODE, &ip_rip_authentication_mode_cmd); - install_element(INTERFACE_NODE, &no_ip_rip_authentication_mode_cmd); - - install_element(INTERFACE_NODE, &ip_rip_authentication_key_chain_cmd); - install_element(INTERFACE_NODE, - &no_ip_rip_authentication_key_chain_cmd); - - install_element(INTERFACE_NODE, &ip_rip_authentication_string_cmd); - install_element(INTERFACE_NODE, &no_ip_rip_authentication_string_cmd); - - install_element(INTERFACE_NODE, &ip_rip_split_horizon_cmd); - install_element(INTERFACE_NODE, - &ip_rip_split_horizon_poisoned_reverse_cmd); - install_element(INTERFACE_NODE, &no_ip_rip_split_horizon_cmd); - install_element(INTERFACE_NODE, - &no_ip_rip_split_horizon_poisoned_reverse_cmd); } |
