From 5734509c0545ebd95a5b8e3f22a911c1a39ffa1b Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Sun, 25 Dec 2011 17:52:09 +0100 Subject: babeld: Initial import, for Babel routing protocol. * Initial import of the Babel routing protocol, ported to Quagga. * LICENCE: Update the original LICENCE file to include all known potentially applicable copyright claims. Ask that any future contributors to babeld/ grant MIT/X11 licence to their work. * *.{c,h}: Add GPL headers, in according with the SFLC guidance on dealing with potentially mixed GPL/other licensed work, at: https://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html --- babeld/babel_interface.c | 778 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 778 insertions(+) create mode 100644 babeld/babel_interface.c (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c new file mode 100644 index 00000000..0130f26b --- /dev/null +++ b/babeld/babel_interface.c @@ -0,0 +1,778 @@ +/* + * This file is free software: you may copy, redistribute and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 2 of the License, or (at your + * option) any later version. + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + +Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "memory.h" +#include "log.h" +#include "command.h" +#include "prefix.h" +#include "vector.h" + +#include "babel_main.h" +#include "util.h" +#include "kernel.h" +#include "babel_interface.h" +#include "message.h" +#include "route.h" +#include "babel_zebra.h" + + +static int babel_enable_if_lookup (const char *ifname); +static int babel_enable_if_add (const char *ifname); +static int babel_enable_if_delete (const char *ifname); +static int interface_recalculate(struct interface *ifp); +static int interface_reset(struct interface *ifp); +static int babel_if_new_hook (struct interface *ifp); +static int babel_if_delete_hook (struct interface *ifp); +static int interface_config_write (struct vty *vty); +static babel_interface_nfo * babel_interface_allocate (); +static void babel_interface_free (babel_interface_nfo *bi); + + +static vector babel_enable_if; /* enable interfaces (by cmd). */ +static struct cmd_node babel_interface_node = /* babeld's interface node. */ +{ + INTERFACE_NODE, + "%s(config-if)# ", + 1 /* VTYSH */ +}; + + +int +babel_interface_up (int cmd, struct zclient *client, zebra_size_t length) +{ + struct stream *s = NULL; + struct interface *ifp = NULL; + + debugf(BABEL_DEBUG_IF, "receive a 'interface up'"); + + s = zclient->ibuf; + ifp = zebra_interface_state_read(s); + + if (ifp == NULL) { + return 0; + } + + interface_recalculate(ifp); + return 0; +} + +int +babel_interface_down (int cmd, struct zclient *client, zebra_size_t length) +{ + struct stream *s = NULL; + struct interface *ifp = NULL; + + debugf(BABEL_DEBUG_IF, "receive a 'interface down'"); + + s = zclient->ibuf; + ifp = zebra_interface_state_read(s); + + if (ifp == NULL) { + return 0; + } + + interface_reset(ifp); + return 0; +} + +int +babel_interface_add (int cmd, struct zclient *client, zebra_size_t length) +{ + struct interface *ifp = NULL; + + debugf(BABEL_DEBUG_IF, "receive a 'interface add'"); + + /* read and add the interface in the iflist. */ + ifp = zebra_interface_add_read (zclient->ibuf); + + if (ifp == NULL) { + return 0; + } + + interface_recalculate(ifp); + + return 0; +} + +int +babel_interface_delete (int cmd, struct zclient *client, zebra_size_t length) +{ + debugf(BABEL_DEBUG_IF, "receive a 'interface delete'"); + return 0; +} + +int +babel_interface_address_add (int cmd, struct zclient *client, + zebra_size_t length) +{ + babel_interface_nfo *babel_ifp; + struct connected *ifc; + struct prefix *prefix; + + debugf(BABEL_DEBUG_IF, "receive a 'interface address add'"); + + ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, + zclient->ibuf); + + if (ifc == NULL) + return 0; + + prefix = ifc->address; + + if (prefix->family == AF_INET) { + flush_interface_routes(ifc->ifp, 0); + babel_ifp = babel_get_if_nfo(ifc->ifp); + if (babel_ifp->ipv4 == NULL) { + babel_ifp->ipv4 = malloc(4); + if (babel_ifp->ipv4 == NULL) { + zlog_err("not einough memory"); + } else { + memcpy(babel_ifp->ipv4, &prefix->u.prefix4, 4); + } + } + } + + send_request(ifc->ifp, NULL, 0); + send_update(ifc->ifp, 0, NULL, 0); + + return 0; +} + +int +babel_interface_address_delete (int cmd, struct zclient *client, + zebra_size_t length) +{ + babel_interface_nfo *babel_ifp; + struct connected *ifc; + struct prefix *prefix; + + debugf(BABEL_DEBUG_IF, "receive a 'interface address add'"); + + ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, + zclient->ibuf); + + if (ifc == NULL) + return 0; + + prefix = ifc->address; + + if (prefix->family == AF_INET) { + flush_interface_routes(ifc->ifp, 0); + babel_ifp = babel_get_if_nfo(ifc->ifp); + if (babel_ifp->ipv4 != NULL + && memcmp(babel_ifp->ipv4, &prefix->u.prefix4, 4) == 0) { + free(babel_ifp->ipv4); + babel_ifp->ipv4 = NULL; + } + } + + send_request(ifc->ifp, NULL, 0); + send_update(ifc->ifp, 0, NULL, 0); + + return 0; +} + +/* Lookup function. */ +static int +babel_enable_if_lookup (const char *ifname) +{ + unsigned int i; + char *str; + + for (i = 0; i < vector_active (babel_enable_if); i++) + if ((str = vector_slot (babel_enable_if, i)) != NULL) + if (strcmp (str, ifname) == 0) + return i; + return -1; +} + +/* Add interface to babel_enable_if. */ +static int +babel_enable_if_add (const char *ifname) +{ + int ret; + struct interface *ifp = NULL; + + ret = babel_enable_if_lookup (ifname); + if (ret >= 0) + return -1; + + vector_set (babel_enable_if, strdup (ifname)); + + ifp = if_lookup_by_name(ifname); + if (ifp != NULL) + babel_get_if_nfo(ifp)->flags |= BABEL_IF_IS_ENABLE; + + return 1; +} + +/* Delete interface from babel_enable_if. */ +static int +babel_enable_if_delete (const char *ifname) +{ + int babel_enable_if_index; + char *str; + struct interface *ifp = NULL; + + babel_enable_if_index = babel_enable_if_lookup (ifname); + if (babel_enable_if_index < 0) + return -1; + + str = vector_slot (babel_enable_if, babel_enable_if_index); + free (str); + vector_unset (babel_enable_if, babel_enable_if_index); + + ifp = if_lookup_by_name(ifname); + if (ifp != NULL) + babel_get_if_nfo(ifp)->flags &= ~BABEL_IF_IS_ENABLE; + + return 1; +} + + +/* [Babel Command] Babel enable on specified interface or matched network. */ +DEFUN (babel_network, + babel_network_cmd, + "network IF_OR_ADDR", + "Babel enable on specified interface or network.\n" + "Interface or address") +{ + int ret; + struct prefix p; + + ret = str2prefix (argv[0], &p); + + /* Given string is: */ + if (ret) /* an IPv4 or v6 network */ + return CMD_ERR_NO_MATCH; /* not implemented yet */ + else /* an interface name */ + ret = babel_enable_if_add (argv[0]); + + if (ret < 0) { + vty_out (vty, "There is same network configuration %s%s", argv[0], + VTY_NEWLINE); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + +/* [Babel Command] Babel enable on specified interface or matched network. */ +DEFUN (no_babel_network, + no_babel_network_cmd, + "no network IF_OR_ADDR", + NO_STR + "Babel enable on specified interface or network.\n" + "Interface or address") +{ + int ret; + struct prefix p; + + ret = str2prefix (argv[0], &p); + + /* Given string is: */ + if (ret) /* an IPv4 or v6 network */ + return CMD_ERR_NO_MATCH; /* not implemented yet */ + else /* an interface name */ + ret = babel_enable_if_delete (argv[0]); + + if (ret < 0) { + vty_out (vty, "can't find network %s%s", argv[0], + VTY_NEWLINE); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + +/* [Interface Command] Tell the interface is wire. */ +DEFUN (babel_set_wired, + babel_set_wired_cmd, + "wired", + "Set this interface as wired (default: wireless).\n" + "No attributes") +{ + struct interface *ifp; + babel_interface_nfo *babel_ifp; + + ifp = vty->index; + babel_ifp = babel_get_if_nfo(ifp); + + assert (babel_ifp != NULL); + babel_ifp->flags |= BABEL_IF_WIRED; + return CMD_SUCCESS; +} + +/* [Interface Command] Tell the interface is wireless (default). */ +DEFUN (babel_set_wireless, + babel_set_wireless_cmd, + "wireless", + NO_STR + "Set this interface as wireless (is default).\n" + "No attributes") +{ + struct interface *ifp; + babel_interface_nfo *babel_ifp; + + ifp = vty->index; + babel_ifp = babel_get_if_nfo(ifp); + + assert (babel_ifp != NULL); + babel_ifp->flags &= ~BABEL_IF_WIRED; + return CMD_SUCCESS; +} + +/* [Interface Command] Enable split horizon. */ +DEFUN (babel_split_horizon, + babel_split_horizon_cmd, + "babel split-horizon", + IPV6_STR + "Routing Information Protocol\n" + "Perform split horizon\n") +{ + struct interface *ifp; + babel_interface_nfo *babel_ifp; + + ifp = vty->index; + babel_ifp = babel_get_if_nfo(ifp); + + assert (babel_ifp != NULL); + babel_ifp->flags |= BABEL_IF_SPLIT_HORIZON; + return CMD_SUCCESS; +} + +/* [Interface Command] Disable split horizon (default). */ +DEFUN (no_babel_split_horizon, + no_babel_split_horizon_cmd, + "no babel split-horizon", + NO_STR + IPV6_STR + "Routing Information Protocol\n" + "Perform split horizon\n") +{ + struct interface *ifp; + babel_interface_nfo *babel_ifp; + + ifp = vty->index; + babel_ifp = babel_get_if_nfo(ifp); + + assert (babel_ifp != NULL); + babel_ifp->flags &= ~BABEL_IF_SPLIT_HORIZON; + return CMD_SUCCESS; +} + +/* [Interface Command]. */ +DEFUN (babel_set_hello_interval, + babel_set_hello_interval_cmd, + "hello interval <5-1000000>", + "Set interface's hello interval (default: 4000).\n" + "Value in miliseconds\n") +{ + struct interface *ifp; + babel_interface_nfo *babel_ifp; + + int interval = atoi(argv[1]); + + ifp = vty->index; + babel_ifp = babel_get_if_nfo(ifp); + + assert (babel_ifp != NULL); + babel_ifp->hello_interval = interval; + return CMD_SUCCESS; +} + +/* [Interface Command]. */ +DEFUN (babel_passive_interface, + babel_passive_interface_cmd, + "passive-interface", + "The daemon will only announce redistributed routes\n" + "Interface name\n") +{ + if (allow_duplicates) { + return CMD_WARNING; + } + parasitic = -1; + return CMD_SUCCESS; +} + +/* [Interface Command]. */ +DEFUN (no_babel_passive_interface, + no_babel_passive_interface_cmd, + "no passive-interface", + NO_STR + "The daemon will announce all (filtred) routes\n" + "Interface name\n") +{ + parasitic = 0; + return CMD_SUCCESS; +} + + +int +interface_idle(babel_interface_nfo *babel_ifp) +{ + return (idle_hello_interval > 0 && + babel_ifp->activity_time < babel_now.tv_sec - idle_time); +} + +/* This should be no more than half the hello interval, so that hellos + aren't sent late. The result is in milliseconds. */ +unsigned +jitter(babel_interface_nfo *babel_ifp, int urgent) +{ + unsigned interval = babel_ifp->hello_interval; + if(urgent) + interval = MIN(interval, 100); + else + interval = MIN(interval, 4000); + return roughly(interval) / 4; +} + +unsigned +update_jitter(babel_interface_nfo *babel_ifp, int urgent) +{ + unsigned interval = babel_ifp->hello_interval; + if(urgent) + interval = MIN(interval, 100); + else + interval = MIN(interval, 4000); + return roughly(interval); +} + +/* calculate babeld's specific datas of an interface (change when the interface + change) */ +static int +interface_recalculate(struct interface *ifp) +{ + babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp); + unsigned char *tmp = NULL; + int mtu, rc; + struct ipv6_mreq mreq; + + mtu = MIN(ifp->mtu, ifp->mtu6); + + /* We need to be able to fit at least two messages into a packet, + so MTUs below 116 require lower layer fragmentation. */ + /* In IPv6, the minimum MTU is 1280, and every host must be able + to reassemble up to 1500 bytes, but I'd rather not rely on this. */ + if(mtu < 128) { + debugf(BABEL_DEBUG_IF, "Suspiciously low MTU %d on interface %s (%d).", + mtu, ifp->name, ifp->ifindex); + mtu = 128; + } + + /* 40 for IPv6 header, 8 for UDP header, 12 for good luck. */ + babel_ifp->bufsize = mtu - sizeof(packet_header) - 60; + tmp = babel_ifp->sendbuf; + babel_ifp->sendbuf = realloc(babel_ifp->sendbuf, babel_ifp->bufsize); + if(babel_ifp->sendbuf == NULL) { + fprintf(stderr, "Couldn't reallocate sendbuf.\n"); + free(tmp); + babel_ifp->bufsize = 0; + return -1; + } + tmp = NULL; + + resize_receive_buffer(mtu); + + if(!(babel_ifp->flags & BABEL_IF_WIRED)) { /* if (wired) */ + babel_ifp->cost = 96; + babel_ifp->flags &= ~BABEL_IF_LQ; + } else { + babel_ifp->cost = 256; + babel_ifp->flags |= BABEL_IF_LQ; + } + + babel_ifp->activity_time = babel_now.tv_sec; + /* Since the interface was marked as active above, the + idle_hello_interval cannot be the one being used here. */ + babel_ifp->update_interval = babel_ifp->hello_interval * 4; + + memset(&mreq, 0, sizeof(mreq)); + memcpy(&mreq.ipv6mr_multiaddr, protocol_group, 16); + mreq.ipv6mr_interface = ifp->ifindex; + + rc = setsockopt(protocol_socket, IPPROTO_IPV6, IPV6_JOIN_GROUP, + (char*)&mreq, sizeof(mreq)); + if(rc < 0) { + zlog_err("setsockopt(IPV6_JOIN_GROUP) on interface '%s': %s", + ifp->name, safe_strerror(errno)); + /* This is probably due to a missing link-local address, + so down this interface, and wait until the main loop + tries to up it again. */ + interface_reset(ifp); + return -1; + } + + set_timeout(&babel_ifp->hello_timeout, babel_ifp->hello_interval); + set_timeout(&babel_ifp->update_timeout, babel_ifp->update_interval); + send_hello(ifp); + send_request(ifp, NULL, 0); + + update_interface_metric(ifp); + + debugf(BABEL_DEBUG_COMMON, + "Upped network %s (%s, cost=%d%s).", + ifp->name, + (babel_ifp->flags & BABEL_IF_WIRED) ? "wired" : "wireless", + babel_ifp->cost, + babel_ifp->ipv4 ? ", IPv4" : ""); + + if(rc > 0) + send_update(ifp, 0, NULL, 0); + + /* Check and set if interface is enable. */ + if (babel_enable_if_lookup(ifp->name) >= 0) { + babel_ifp->flags |= BABEL_IF_IS_ENABLE; + } else { + babel_ifp->flags &= ~BABEL_IF_IS_ENABLE; + } + + return 1; +} + +/* Reset the interface as it was new: it's not removed from the interface list, + and may be considered as a upped interface. */ +static int +interface_reset(struct interface *ifp) +{ + int rc; + struct ipv6_mreq mreq; + babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp); + + flush_interface_routes(ifp, 0); + babel_ifp->buffered = 0; + babel_ifp->bufsize = 0; + free(babel_ifp->sendbuf); + babel_ifp->num_buffered_updates = 0; + babel_ifp->update_bufsize = 0; + if(babel_ifp->buffered_updates) + free(babel_ifp->buffered_updates); + babel_ifp->buffered_updates = NULL; + babel_ifp->sendbuf = NULL; + + if(ifp->ifindex > 0) { + memset(&mreq, 0, sizeof(mreq)); + memcpy(&mreq.ipv6mr_multiaddr, protocol_group, 16); + mreq.ipv6mr_interface = ifp->ifindex; + rc = setsockopt(protocol_socket, IPPROTO_IPV6, IPV6_LEAVE_GROUP, + (char*)&mreq, sizeof(mreq)); + if(rc < 0) + zlog_err("setsockopt(IPV6_LEAVE_GROUP) on interface '%s': %s", + ifp->name, safe_strerror(errno)); + } + + update_interface_metric(ifp); + + debugf(BABEL_DEBUG_COMMON,"Upped network %s (%s, cost=%d%s).", + ifp->name, + (babel_ifp->flags & BABEL_IF_WIRED) ? "wired" : "wireless", + babel_ifp->cost, + babel_ifp->ipv4 ? ", IPv4" : ""); + + return 1; +} + +/* Send retraction to all, and reset all interfaces statistics. */ +void +babel_interface_close_all(void) +{ + struct interface *ifp = NULL; + struct listnode *linklist_node = NULL; + + FOR_ALL_INTERFACES(ifp, linklist_node) { + if(!if_up(ifp)) + continue; + send_wildcard_retraction(ifp); + /* Make sure that we expire quickly from our neighbours' + association caches. */ + send_hello_noupdate(ifp, 10); + flushbuf(ifp); + usleep(roughly(1000)); + gettime(&babel_now); + } + FOR_ALL_INTERFACES(ifp, linklist_node) { + if(!if_up(ifp)) + continue; + /* Make sure they got it. */ + send_wildcard_retraction(ifp); + send_hello_noupdate(ifp, 1); + flushbuf(ifp); + usleep(roughly(10000)); + gettime(&babel_now); + interface_reset(ifp); + } +} + +/* return "true" if address is one of our ipv6 addresses */ +int +is_interface_ll_address(struct interface *ifp, const unsigned char *address) +{ + struct connected *connected; + struct listnode *node; + + if(!if_up(ifp)) + return 0; + + FOR_ALL_INTERFACES_ADDRESSES(ifp, connected, node) { + if(connected->address->family == AF_INET6 && + memcmp(&connected->address->u.prefix6, address, 16) == 0) + return 1; + } + + return 0; +} + + +void +babel_if_init () +{ + /* initialize interface list */ + if_init(); + if_add_hook (IF_NEW_HOOK, babel_if_new_hook); + if_add_hook (IF_DELETE_HOOK, babel_if_delete_hook); + + babel_enable_if = vector_init (1); + + /* install interface node and commands */ + install_element (CONFIG_NODE, &interface_cmd); + install_element (CONFIG_NODE, &no_interface_cmd); + install_node (&babel_interface_node, interface_config_write); + install_default(INTERFACE_NODE); + install_element(INTERFACE_NODE, &interface_cmd); + install_element(INTERFACE_NODE, &no_interface_cmd); + + install_element(BABEL_NODE, &babel_network_cmd); + install_element(BABEL_NODE, &no_babel_network_cmd); + install_element(INTERFACE_NODE, &babel_split_horizon_cmd); + install_element(INTERFACE_NODE, &no_babel_split_horizon_cmd); + install_element(INTERFACE_NODE, &babel_set_wired_cmd); + install_element(INTERFACE_NODE, &babel_set_wireless_cmd); + install_element(INTERFACE_NODE, &babel_set_hello_interval_cmd); + install_element(INTERFACE_NODE, &babel_passive_interface_cmd); + install_element(INTERFACE_NODE, &no_babel_passive_interface_cmd); +} + +/* hooks: functions called respectively when struct interface is + created or deleted. */ +static int +babel_if_new_hook (struct interface *ifp) +{ + ifp->info = babel_interface_allocate(); + return 0; +} + +static int +babel_if_delete_hook (struct interface *ifp) +{ + babel_interface_free(ifp->info); + ifp->info = NULL; + return 0; +} + +/* Configuration write function for babeld. */ +static int +interface_config_write (struct vty *vty) +{ + struct listnode *node; + struct interface *ifp; + babel_interface_nfo *babel_ifp; + int write = 0; + + for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) { + babel_ifp = babel_get_if_nfo(ifp); + + /* Do not display the interface if there is no configuration about it */ + if (ifp->desc == NULL) + continue; + + vty_out (vty, "interface %s%s", ifp->name, + VTY_NEWLINE); + if (ifp->desc) + vty_out (vty, " description %s%s", ifp->desc, + VTY_NEWLINE); + + /* TODO: to be completed... */ + + vty_out (vty, "!%s", VTY_NEWLINE); + + write++; + } + return write; +} + +/* functions to allocate or free memory for a babel_interface_nfo, filling + needed fields */ +static babel_interface_nfo * +babel_interface_allocate () +{ + babel_interface_nfo *babel_ifp; + babel_ifp = XMALLOC(MTYPE_BABEL_IF, sizeof(babel_interface_nfo)); + if(babel_ifp == NULL) + return NULL; + + /* Here are set the default values for an interface. */ + memset(babel_ifp, 0, sizeof(babel_interface_nfo)); + /* All flags are unset */ + babel_ifp->activity_time = babel_now.tv_sec; + babel_ifp->bucket_time = babel_now.tv_sec; + babel_ifp->bucket = BUCKET_TOKENS_MAX; + babel_ifp->hello_seqno = (random() & 0xFFFF); + babel_ifp->hello_interval = BABELD_DEFAULT_HELLO_INTERVAL; + + return babel_ifp; +} + +static void +babel_interface_free (babel_interface_nfo *babel_ifp) +{ + XFREE(MTYPE_BABEL_IF, babel_ifp); +} -- cgit v1.2.1 From 3dbda0ceebe369a1071600fe7d8d8ecf45f1027c Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Sun, 8 Jan 2012 16:52:36 +0400 Subject: babeld: address some compilation warnings Including system headers is not necessary with zebra.h included and sometimes results in "__ASSERT_FUNCTION redefined" compilation warning. * babeld.c * babel_distribute_update_interface(): make static * babel_interface.c * interface_config_write(): unused 'babel_ifp' * don't include system headers * message.c * send_request(): unused 'babel_ifp' * send_multihop_request(): idem * don't include system headers * route.c: don't include system headers * xroute.c: idem * source.h: newline at EOF * message.h: idem --- babeld/babel_interface.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 0130f26b..ff9c5eb4 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -37,17 +37,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include "memory.h" #include "log.h" @@ -724,12 +713,9 @@ interface_config_write (struct vty *vty) { struct listnode *node; struct interface *ifp; - babel_interface_nfo *babel_ifp; int write = 0; for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) { - babel_ifp = babel_get_if_nfo(ifp); - /* Do not display the interface if there is no configuration about it */ if (ifp->desc == NULL) continue; -- cgit v1.2.1 From c7c53fa88ccdbc2d48cf7327c9e4f33cdc517a8a Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Sun, 8 Jan 2012 16:43:08 +0100 Subject: babeld: address some other compilation warnings. --- babeld/babel_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index ff9c5eb4..4bd4499a 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -61,7 +61,7 @@ static int interface_reset(struct interface *ifp); static int babel_if_new_hook (struct interface *ifp); static int babel_if_delete_hook (struct interface *ifp); static int interface_config_write (struct vty *vty); -static babel_interface_nfo * babel_interface_allocate (); +static babel_interface_nfo * babel_interface_allocate (void); static void babel_interface_free (babel_interface_nfo *bi); @@ -738,7 +738,7 @@ interface_config_write (struct vty *vty) /* functions to allocate or free memory for a babel_interface_nfo, filling needed fields */ static babel_interface_nfo * -babel_interface_allocate () +babel_interface_allocate (void) { babel_interface_nfo *babel_ifp; babel_ifp = XMALLOC(MTYPE_BABEL_IF, sizeof(babel_interface_nfo)); -- cgit v1.2.1 From d4e46e681434e768b870679b998eb1ac7635fdfc Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Tue, 17 Jan 2012 19:25:03 +0400 Subject: babeld: implement "show babel interface" command * babel_interface.c * show_babel_interface_sub(): new function to process one ifp * show_babel_interface(): new function, VTY wrapper * babel_if_init(): update respectively --- babeld/babel_interface.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 4bd4499a..df68afba 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -660,6 +660,62 @@ is_interface_ll_address(struct interface *ifp, const unsigned char *address) return 0; } +static void +show_babel_interface_sub (struct vty *vty, struct interface *ifp) +{ + int is_up; + babel_interface_nfo *babel_ifp; + + vty_out (vty, "%s is %s%s", ifp->name, + ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); + vty_out (vty, " ifindex %u, MTU %u bytes %s%s", + ifp->ifindex, ifp->mtu, if_flag_dump(ifp->flags), VTY_NEWLINE); + + if (babel_enable_if_lookup (ifp->name) < 0) + { + vty_out (vty, " Babel protocol is not enabled on this interface%s", VTY_NEWLINE); + return; + } + if (!is_up) + { + vty_out (vty, " Babel protocol is enabled, but not running on this interface%s", VTY_NEWLINE); + return; + } + babel_ifp = babel_get_if_nfo (ifp); + vty_out (vty, " Babel protocol is running on this interface%s", VTY_NEWLINE); + vty_out (vty, " Operating mode is \"%s\"%s", + CHECK_FLAG (babel_ifp->flags, BABEL_IF_WIRED) ? "wired" : "wireless", VTY_NEWLINE); + vty_out (vty, " Split horizon mode is %s%s", + CHECK_FLAG (babel_ifp->flags, BABEL_IF_SPLIT_HORIZON) ? "On" : "Off", VTY_NEWLINE); + vty_out (vty, " Hello interval is %u ms%s", babel_ifp->hello_interval, VTY_NEWLINE); +} + +DEFUN (show_babel_interface, + show_babel_interface_cmd, + "show babel interface [INTERFACE]", + SHOW_STR + IP_STR + "Babel information\n" + "Interface information\n" + "Interface name\n") +{ + struct interface *ifp; + struct listnode *node; + + if (argc == 0) + { + for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) + show_babel_interface_sub (vty, ifp); + return CMD_SUCCESS; + } + if ((ifp = if_lookup_by_name (argv[0])) == NULL) + { + vty_out (vty, "No such interface name%s", VTY_NEWLINE); + return CMD_WARNING; + } + show_babel_interface_sub (vty, ifp); + return CMD_SUCCESS; +} void babel_if_init () @@ -688,6 +744,10 @@ babel_if_init () install_element(INTERFACE_NODE, &babel_set_hello_interval_cmd); install_element(INTERFACE_NODE, &babel_passive_interface_cmd); install_element(INTERFACE_NODE, &no_babel_passive_interface_cmd); + + /* "show babel ..." commands */ + install_element (VIEW_NODE, &show_babel_interface_cmd); + install_element (ENABLE_NODE, &show_babel_interface_cmd); } /* hooks: functions called respectively when struct interface is -- cgit v1.2.1 From 4eedea551290906fc76f3a0c908ae759e78bb68a Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Tue, 17 Jan 2012 22:46:21 +0100 Subject: babeld: change fprintf(stderr) in term of zlog_err. --- babeld/babel_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index df68afba..b80bf94e 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -503,7 +503,7 @@ interface_recalculate(struct interface *ifp) tmp = babel_ifp->sendbuf; babel_ifp->sendbuf = realloc(babel_ifp->sendbuf, babel_ifp->bufsize); if(babel_ifp->sendbuf == NULL) { - fprintf(stderr, "Couldn't reallocate sendbuf.\n"); + zlog_err("Couldn't reallocate sendbuf."); free(tmp); babel_ifp->bufsize = 0; return -1; -- cgit v1.2.1 From 0ee8a1f1d61ce55642d9164625ab36700fe2c3a9 Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Wed, 18 Jan 2012 00:52:06 +0100 Subject: babeld: avoid segfault (bug 706). --- babeld/babel_interface.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index b80bf94e..edfa2b40 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -486,6 +486,13 @@ interface_recalculate(struct interface *ifp) int mtu, rc; struct ipv6_mreq mreq; + if (!if_is_operative(ifp) || !CHECK_FLAG(ifp->flags, IFF_RUNNING)) { + interface_reset(ifp); + return -1; + } + + babel_ifp->flags |= BABEL_IF_IS_UP; + mtu = MIN(ifp->mtu, ifp->mtu6); /* We need to be able to fit at least two messages into a packet, @@ -577,6 +584,9 @@ interface_reset(struct interface *ifp) struct ipv6_mreq mreq; babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp); + debugf(BABEL_DEBUG_IF, "interface reset: %s", ifp->name); + babel_ifp->flags &= ~BABEL_IF_IS_UP; + flush_interface_routes(ifp, 0); babel_ifp->buffered = 0; babel_ifp->bufsize = 0; -- cgit v1.2.1 From 297a55ba1ce58b281b825400abeca6c32b99db52 Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Wed, 18 Jan 2012 16:39:29 +0100 Subject: babeld: add command: "show_babel_neighbour". --- babeld/babel_interface.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index edfa2b40..bd32d263 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -51,6 +51,7 @@ THE SOFTWARE. #include "message.h" #include "route.h" #include "babel_zebra.h" +#include "neighbour.h" static int babel_enable_if_lookup (const char *ifname); @@ -727,6 +728,51 @@ DEFUN (show_babel_interface, return CMD_SUCCESS; } +static void +show_babel_neighbour_sub (struct vty *vty, struct neighbour *neigh) +{ + vty_out (vty, + "Neighbour %s dev %s reach %04x rxcost %d txcost %d %s.%s", + format_address(neigh->address), + neigh->ifp->name, + neigh->reach, + neighbour_rxcost(neigh), + neigh->txcost, + if_up(neigh->ifp) ? "" : " (down)", + VTY_NEWLINE); +} + +DEFUN (show_babel_neighbour, + show_babel_neighbour_cmd, + "show babel neighbour [INTERFACE]", + SHOW_STR + IP_STR + "Babel information\n" + "Print neighbours\n" + "Interface name\n") +{ + struct neighbour *neigh; + struct interface *ifp; + + if (argc == 0) { + FOR_ALL_NEIGHBOURS(neigh) { + show_babel_neighbour_sub(vty, neigh); + } + return CMD_SUCCESS; + } + if ((ifp = if_lookup_by_name (argv[0])) == NULL) + { + vty_out (vty, "No such interface name%s", VTY_NEWLINE); + return CMD_WARNING; + } + FOR_ALL_NEIGHBOURS(neigh) { + if(ifp->ifindex == neigh->ifp->ifindex) { + show_babel_neighbour_sub(vty, neigh); + } + } + return CMD_SUCCESS; +} + void babel_if_init () { @@ -758,6 +804,8 @@ babel_if_init () /* "show babel ..." commands */ install_element (VIEW_NODE, &show_babel_interface_cmd); install_element (ENABLE_NODE, &show_babel_interface_cmd); + install_element(VIEW_NODE, &show_babel_neighbour_cmd); + install_element(ENABLE_NODE, &show_babel_neighbour_cmd); } /* hooks: functions called respectively when struct interface is -- cgit v1.2.1 From 1f39f466e439f217dcbae741ddc23a5340a05ec9 Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Wed, 18 Jan 2012 20:01:31 +0100 Subject: babeld: add command: "show_babel_database". --- babeld/babel_interface.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index bd32d263..d4c84b35 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -52,6 +52,8 @@ THE SOFTWARE. #include "route.h" #include "babel_zebra.h" #include "neighbour.h" +#include "route.h" +#include "xroute.h" static int babel_enable_if_lookup (const char *ifname); @@ -773,6 +775,60 @@ DEFUN (show_babel_neighbour, return CMD_SUCCESS; } +static void +show_babel_routes_sub (struct vty *vty, struct babel_route *route) +{ + const unsigned char *nexthop = + memcmp(route->nexthop, route->neigh->address, 16) == 0 ? + NULL : route->nexthop; + + vty_out(vty, + "%s metric %d refmetric %d id %s seqno %d age %d " + "via %s neigh %s%s%s%s%s", + format_prefix(route->src->prefix, route->src->plen), + route_metric(route), route->refmetric, + format_eui64(route->src->id), + (int)route->seqno, + (int)(babel_now.tv_sec - route->time), + route->neigh->ifp->name, + format_address(route->neigh->address), + nexthop ? " nexthop " : "", + nexthop ? format_address(nexthop) : "", + route->installed ? " (installed)" : + route_feasible(route) ? " (feasible)" : "", + VTY_NEWLINE); +} + +static void +show_babel_xroutes_sub (struct vty *vty, struct xroute *xroute) +{ + vty_out(vty, "%s metric %d (exported)%s", + format_prefix(xroutes->prefix, xroute->plen), + xroutes->metric, + VTY_NEWLINE); +} + +DEFUN (show_babel_database, + show_babel_database_cmd, + "show babel database", + SHOW_STR + IP_STR + "Babel information\n" + "Database information\n" + "No attributes\n") +{ + int i; + + for(i = 0; i < numroutes; i++) { + show_babel_routes_sub(vty, &routes[i]); + } + for(i = 0; i < numxroutes; i++) { + show_babel_xroutes_sub(vty, &xroutes[i]); + } + + return CMD_SUCCESS; +} + void babel_if_init () { @@ -806,6 +862,8 @@ babel_if_init () install_element (ENABLE_NODE, &show_babel_interface_cmd); install_element(VIEW_NODE, &show_babel_neighbour_cmd); install_element(ENABLE_NODE, &show_babel_neighbour_cmd); + install_element(VIEW_NODE, &show_babel_database_cmd); + install_element(ENABLE_NODE, &show_babel_database_cmd); } /* hooks: functions called respectively when struct interface is -- cgit v1.2.1 From d3351d1ebf99591cf436035bb148e4ae0b351ffc Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Thu, 19 Jan 2012 22:36:56 +0100 Subject: babeld: add command: "show_babel_running_config". --- babeld/babel_interface.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index d4c84b35..3f580046 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -43,6 +43,7 @@ THE SOFTWARE. #include "command.h" #include "prefix.h" #include "vector.h" +#include "distribute.h" #include "babel_main.h" #include "util.h" @@ -829,6 +830,24 @@ DEFUN (show_babel_database, return CMD_SUCCESS; } +DEFUN (show_babel_running_config, + show_babel_running_config_cmd, + "show babel running-config", + SHOW_STR + IP_STR + "Babel information\n" + "Configuration information\n" + "No attributes\n") +{ + vty_out(vty, " -- Babel running configuration --%s", VTY_NEWLINE); + show_babel_main_configuration(vty); + show_babeld_configuration(vty); + vty_out(vty, " -- ditribution lists --%s", VTY_NEWLINE); + config_show_distribute(vty); + + return CMD_SUCCESS; +} + void babel_if_init () { @@ -864,6 +883,8 @@ babel_if_init () install_element(ENABLE_NODE, &show_babel_neighbour_cmd); install_element(VIEW_NODE, &show_babel_database_cmd); install_element(ENABLE_NODE, &show_babel_database_cmd); + install_element(VIEW_NODE, &show_babel_running_config_cmd); + install_element(ENABLE_NODE, &show_babel_running_config_cmd); } /* hooks: functions called respectively when struct interface is -- cgit v1.2.1 From 3f031ed536cf96d44015cf49d1f734d15d194f0a Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Wed, 18 Jan 2012 23:03:00 +0100 Subject: babeld: fix commands informations messages. --- babeld/babel_interface.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 3f580046..e403cce0 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -368,8 +368,8 @@ DEFUN (babel_split_horizon, babel_split_horizon_cmd, "babel split-horizon", IPV6_STR - "Routing Information Protocol\n" - "Perform split horizon\n") + "Perform split horizon\n" + "No attributes\n") { struct interface *ifp; babel_interface_nfo *babel_ifp; @@ -388,8 +388,8 @@ DEFUN (no_babel_split_horizon, "no babel split-horizon", NO_STR IPV6_STR - "Routing Information Protocol\n" - "Perform split horizon\n") + "Disable split horizon\n" + "No attributes\n") { struct interface *ifp; babel_interface_nfo *babel_ifp; @@ -427,7 +427,7 @@ DEFUN (babel_passive_interface, babel_passive_interface_cmd, "passive-interface", "The daemon will only announce redistributed routes\n" - "Interface name\n") + "No attributes\n") { if (allow_duplicates) { return CMD_WARNING; @@ -442,7 +442,7 @@ DEFUN (no_babel_passive_interface, "no passive-interface", NO_STR "The daemon will announce all (filtred) routes\n" - "Interface name\n") + "No attributes\n") { parasitic = 0; return CMD_SUCCESS; -- cgit v1.2.1 From c35fafdf887aa32c5be6ad738d3a3b0140cea6e8 Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Mon, 23 Jan 2012 23:46:32 +0100 Subject: babeld: babelz merge. Babelz is the last version of the stand-alone babel daemon. In particular, it use multiple channels to diminuate interferences. Please refer to this one for more details. --- babeld/babel_interface.c | 72 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 15 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index e403cce0..1c8c8868 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -456,6 +456,30 @@ interface_idle(babel_interface_nfo *babel_ifp) babel_ifp->activity_time < babel_now.tv_sec - idle_time); } +int +update_hello_interval(struct interface *ifp) +{ + int rc = 0; + unsigned short interval; + struct babel_interface *babel_ifp = babel_get_if_nfo(ifp); + + if(interface_idle(babel_ifp)) + interval = idle_hello_interval; + else if(IF_CONF(ifp, hello_interval) > 0) + interval = IF_CONF(ifp, hello_interval); + else if((ifp->flags & BABEL_IF_WIRED)) + interval = wired_hello_interval; + else + interval = wireless_hello_interval; + + if(babel_ifp->hello_interval != interval) { + babel_ifp->hello_interval = interval; + rc = 1; + } + + return rc; +} + /* This should be no more than half the hello interval, so that hellos aren't sent late. The result is in milliseconds. */ unsigned @@ -560,10 +584,11 @@ interface_recalculate(struct interface *ifp) update_interface_metric(ifp); debugf(BABEL_DEBUG_COMMON, - "Upped network %s (%s, cost=%d%s).", + "Upped interface %s (%s, cost=%d, channel=%d%s).", ifp->name, (babel_ifp->flags & BABEL_IF_WIRED) ? "wired" : "wireless", babel_ifp->cost, + babel_ifp->channel, babel_ifp->ipv4 ? ", IPv4" : ""); if(rc > 0) @@ -777,19 +802,41 @@ DEFUN (show_babel_neighbour, } static void -show_babel_routes_sub (struct vty *vty, struct babel_route *route) +show_babel_routes_sub (struct babel_route *route, void *closure) { + struct vty *vty = (struct vty*) closure; const unsigned char *nexthop = memcmp(route->nexthop, route->neigh->address, 16) == 0 ? NULL : route->nexthop; + char channels[100]; + + if(route->channels[0] == 0) + channels[0] = '\0'; + else { + int k, j = 0; + snprintf(channels, 100, " chan ("); + j = strlen(channels); + for(k = 0; k < DIVERSITY_HOPS; k++) { + if(route->channels[k] == 0) + break; + if(k > 0) + channels[j++] = ','; + snprintf(channels + j, 100 - j, "%d", route->channels[k]); + j = strlen(channels); + } + snprintf(channels + j, 100 - j, ")"); + if(k == 0) + channels[0] = '\0'; + } vty_out(vty, - "%s metric %d refmetric %d id %s seqno %d age %d " + "%s metric %d refmetric %d id %s seqno %d%s age %d " "via %s neigh %s%s%s%s%s", format_prefix(route->src->prefix, route->src->plen), route_metric(route), route->refmetric, format_eui64(route->src->id), (int)route->seqno, + channels, (int)(babel_now.tv_sec - route->time), route->neigh->ifp->name, format_address(route->neigh->address), @@ -801,11 +848,12 @@ show_babel_routes_sub (struct vty *vty, struct babel_route *route) } static void -show_babel_xroutes_sub (struct vty *vty, struct xroute *xroute) +show_babel_xroutes_sub (struct xroute *xroute, void *closure) { + struct vty *vty = (struct vty *) closure; vty_out(vty, "%s metric %d (exported)%s", - format_prefix(xroutes->prefix, xroute->plen), - xroutes->metric, + format_prefix(xroute->prefix, xroute->plen), + xroute->metric, VTY_NEWLINE); } @@ -818,15 +866,8 @@ DEFUN (show_babel_database, "Database information\n" "No attributes\n") { - int i; - - for(i = 0; i < numroutes; i++) { - show_babel_routes_sub(vty, &routes[i]); - } - for(i = 0; i < numxroutes; i++) { - show_babel_xroutes_sub(vty, &xroutes[i]); - } - + for_all_routes(show_babel_routes_sub, vty); + for_all_xroutes(show_babel_xroutes_sub, vty); return CMD_SUCCESS; } @@ -950,6 +991,7 @@ babel_interface_allocate (void) babel_ifp->bucket = BUCKET_TOKENS_MAX; babel_ifp->hello_seqno = (random() & 0xFFFF); babel_ifp->hello_interval = BABELD_DEFAULT_HELLO_INTERVAL; + babel_ifp->channel = BABEL_IF_CHANNEL_INTERFERING; return babel_ifp; } -- cgit v1.2.1 From 8c4e57a57562c9329b1de4c29ee921ab98182c6b Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Sat, 28 Jan 2012 00:29:51 +0100 Subject: babeld: fix interface bug, simplify code. Perhaps could it be able to free already free memory (so free(NULL)), in function interface_reset(). On other hand, it initiated untracked interfaces, raising (at least) inappropriate messages. Finally, I remove the BABEL_IF_IS_ENABLE flag, witch was not really usefull. Note the test if_up isn't weaker, because (...IS_UP => ...IS_ENABLE). --- babeld/babel_interface.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 1c8c8868..fafe009f 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -57,6 +57,8 @@ THE SOFTWARE. #include "xroute.h" +#define IS_ENABLE(ifp) (babel_enable_if_lookup(ifp->name) >= 0) + static int babel_enable_if_lookup (const char *ifname); static int babel_enable_if_add (const char *ifname); static int babel_enable_if_delete (const char *ifname); @@ -87,7 +89,7 @@ babel_interface_up (int cmd, struct zclient *client, zebra_size_t length) debugf(BABEL_DEBUG_IF, "receive a 'interface up'"); s = zclient->ibuf; - ifp = zebra_interface_state_read(s); + ifp = zebra_interface_state_read(s); /* it updates iflist */ if (ifp == NULL) { return 0; @@ -106,7 +108,7 @@ babel_interface_down (int cmd, struct zclient *client, zebra_size_t length) debugf(BABEL_DEBUG_IF, "receive a 'interface down'"); s = zclient->ibuf; - ifp = zebra_interface_state_read(s); + ifp = zebra_interface_state_read(s); /* it updates iflist */ if (ifp == NULL) { return 0; @@ -131,14 +133,30 @@ babel_interface_add (int cmd, struct zclient *client, zebra_size_t length) } interface_recalculate(ifp); - return 0; } int babel_interface_delete (int cmd, struct zclient *client, zebra_size_t length) { + struct interface *ifp; + struct stream *s; + debugf(BABEL_DEBUG_IF, "receive a 'interface delete'"); + + s = zclient->ibuf; + ifp = zebra_interface_state_read(s); /* it updates iflist */ + + if (ifp == NULL) + return 0; + + if (IS_ENABLE(ifp)) + interface_reset(ifp); + + /* To support pseudo interface do not free interface structure. */ + /* if_delete(ifp); */ + ifp->ifindex = IFINDEX_INTERNAL; + return 0; } @@ -242,7 +260,7 @@ babel_enable_if_add (const char *ifname) ifp = if_lookup_by_name(ifname); if (ifp != NULL) - babel_get_if_nfo(ifp)->flags |= BABEL_IF_IS_ENABLE; + interface_recalculate(ifp); return 1; } @@ -265,7 +283,7 @@ babel_enable_if_delete (const char *ifname) ifp = if_lookup_by_name(ifname); if (ifp != NULL) - babel_get_if_nfo(ifp)->flags &= ~BABEL_IF_IS_ENABLE; + interface_reset(ifp); return 1; } @@ -514,6 +532,9 @@ interface_recalculate(struct interface *ifp) int mtu, rc; struct ipv6_mreq mreq; + if (!IS_ENABLE(ifp)) + return -1; + if (!if_is_operative(ifp) || !CHECK_FLAG(ifp->flags, IFF_RUNNING)) { interface_reset(ifp); return -1; @@ -594,13 +615,6 @@ interface_recalculate(struct interface *ifp) if(rc > 0) send_update(ifp, 0, NULL, 0); - /* Check and set if interface is enable. */ - if (babel_enable_if_lookup(ifp->name) >= 0) { - babel_ifp->flags |= BABEL_IF_IS_ENABLE; - } else { - babel_ifp->flags &= ~BABEL_IF_IS_ENABLE; - } - return 1; } @@ -613,6 +627,9 @@ interface_reset(struct interface *ifp) struct ipv6_mreq mreq; babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp); + if (!(babel_ifp->flags & BABEL_IF_IS_UP)) + return 0; + debugf(BABEL_DEBUG_IF, "interface reset: %s", ifp->name); babel_ifp->flags &= ~BABEL_IF_IS_UP; -- cgit v1.2.1 From e19ed8c4516621be74b9a28c887185fc66b67430 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 7 Feb 2012 05:36:06 +0100 Subject: babeld: Fix typo in hello interval command. --- babeld/babel_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index fafe009f..a874289c 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -430,7 +430,7 @@ DEFUN (babel_set_hello_interval, struct interface *ifp; babel_interface_nfo *babel_ifp; - int interval = atoi(argv[1]); + int interval = atoi(argv[0]); ifp = vty->index; babel_ifp = babel_get_if_nfo(ifp); -- cgit v1.2.1 From 38846de1fd7fa9005933564de28360fb9bdf02bb Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 7 Feb 2012 05:43:36 +0100 Subject: babeld: Error handling and tweaks for babeld commands. --- babeld/babel_interface.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index a874289c..906f349e 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -429,13 +429,14 @@ DEFUN (babel_set_hello_interval, { struct interface *ifp; babel_interface_nfo *babel_ifp; + int interval; - int interval = atoi(argv[0]); + VTY_GET_INTEGER_RANGE("hello interval", interval, argv[0], 20, 10 * 0xFFFE); ifp = vty->index; babel_ifp = babel_get_if_nfo(ifp); - assert (babel_ifp != NULL); + babel_ifp->hello_interval = interval; return CMD_SUCCESS; } @@ -450,7 +451,7 @@ DEFUN (babel_passive_interface, if (allow_duplicates) { return CMD_WARNING; } - parasitic = -1; + parasitic = 1; return CMD_SUCCESS; } @@ -900,7 +901,7 @@ DEFUN (show_babel_running_config, vty_out(vty, " -- Babel running configuration --%s", VTY_NEWLINE); show_babel_main_configuration(vty); show_babeld_configuration(vty); - vty_out(vty, " -- ditribution lists --%s", VTY_NEWLINE); + vty_out(vty, " -- distribution lists --%s", VTY_NEWLINE); config_show_distribute(vty); return CMD_SUCCESS; -- cgit v1.2.1 From ec0c848047954158b4316d45586079cbb774a7fe Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 7 Feb 2012 05:44:41 +0100 Subject: babeld: Indentation fix. --- babeld/babel_interface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 906f349e..047a6ebf 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -935,9 +935,9 @@ babel_if_init () install_element(INTERFACE_NODE, &babel_passive_interface_cmd); install_element(INTERFACE_NODE, &no_babel_passive_interface_cmd); - /* "show babel ..." commands */ - install_element (VIEW_NODE, &show_babel_interface_cmd); - install_element (ENABLE_NODE, &show_babel_interface_cmd); + /* "show babel ..." commands */ + install_element(VIEW_NODE, &show_babel_interface_cmd); + install_element(ENABLE_NODE, &show_babel_interface_cmd); install_element(VIEW_NODE, &show_babel_neighbour_cmd); install_element(ENABLE_NODE, &show_babel_neighbour_cmd); install_element(VIEW_NODE, &show_babel_database_cmd); -- cgit v1.2.1 From 3c442e8802c260a0ce9787b5f432a7a2a093be25 Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Wed, 8 Feb 2012 23:30:46 +0100 Subject: babeld: fix wire{d,less} commands name. --- babeld/babel_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 047a6ebf..42a9e0ea 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -347,7 +347,7 @@ DEFUN (no_babel_network, /* [Interface Command] Tell the interface is wire. */ DEFUN (babel_set_wired, babel_set_wired_cmd, - "wired", + "babel wired", "Set this interface as wired (default: wireless).\n" "No attributes") { @@ -365,7 +365,7 @@ DEFUN (babel_set_wired, /* [Interface Command] Tell the interface is wireless (default). */ DEFUN (babel_set_wireless, babel_set_wireless_cmd, - "wireless", + "babel wireless", NO_STR "Set this interface as wireless (is default).\n" "No attributes") -- cgit v1.2.1 From 52d54422bdc0b70356d84a38a0ce15ba5dea03e0 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sat, 11 Feb 2012 13:08:00 +0100 Subject: Resynchronise with babeld-1.3.1. --- babeld/babel_interface.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 42a9e0ea..0f254ecc 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -467,38 +467,6 @@ DEFUN (no_babel_passive_interface, return CMD_SUCCESS; } - -int -interface_idle(babel_interface_nfo *babel_ifp) -{ - return (idle_hello_interval > 0 && - babel_ifp->activity_time < babel_now.tv_sec - idle_time); -} - -int -update_hello_interval(struct interface *ifp) -{ - int rc = 0; - unsigned short interval; - struct babel_interface *babel_ifp = babel_get_if_nfo(ifp); - - if(interface_idle(babel_ifp)) - interval = idle_hello_interval; - else if(IF_CONF(ifp, hello_interval) > 0) - interval = IF_CONF(ifp, hello_interval); - else if((ifp->flags & BABEL_IF_WIRED)) - interval = wired_hello_interval; - else - interval = wireless_hello_interval; - - if(babel_ifp->hello_interval != interval) { - babel_ifp->hello_interval = interval; - rc = 1; - } - - return rc; -} - /* This should be no more than half the hello interval, so that hellos aren't sent late. The result is in milliseconds. */ unsigned @@ -577,7 +545,6 @@ interface_recalculate(struct interface *ifp) babel_ifp->flags |= BABEL_IF_LQ; } - babel_ifp->activity_time = babel_now.tv_sec; /* Since the interface was marked as active above, the idle_hello_interval cannot be the one being used here. */ babel_ifp->update_interval = babel_ifp->hello_interval * 4; @@ -1004,7 +971,6 @@ babel_interface_allocate (void) /* Here are set the default values for an interface. */ memset(babel_ifp, 0, sizeof(babel_interface_nfo)); /* All flags are unset */ - babel_ifp->activity_time = babel_now.tv_sec; babel_ifp->bucket_time = babel_now.tv_sec; babel_ifp->bucket = BUCKET_TOKENS_MAX; babel_ifp->hello_seqno = (random() & 0xFFFF); -- cgit v1.2.1 From c428edba5fb151844d28fbb41fce1df466a74e42 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sat, 11 Feb 2012 14:02:10 +0100 Subject: babeld: vty commands (hello-interval, update-interval, resend-delay). --- babeld/babel_interface.c | 67 +++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 23 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 0f254ecc..bc58b7e3 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -293,7 +293,7 @@ babel_enable_if_delete (const char *ifname) DEFUN (babel_network, babel_network_cmd, "network IF_OR_ADDR", - "Babel enable on specified interface or network.\n" + "Enable Babel protocol on specified interface or network.\n" "Interface or address") { int ret; @@ -321,7 +321,7 @@ DEFUN (no_babel_network, no_babel_network_cmd, "no network IF_OR_ADDR", NO_STR - "Babel enable on specified interface or network.\n" + "Disable Babel protocol on specified interface or network.\n" "Interface or address") { int ret; @@ -348,8 +348,8 @@ DEFUN (no_babel_network, DEFUN (babel_set_wired, babel_set_wired_cmd, "babel wired", - "Set this interface as wired (default: wireless).\n" - "No attributes") + "Babel interface commands\n" + "Enable wired optimisations") { struct interface *ifp; babel_interface_nfo *babel_ifp; @@ -366,9 +366,8 @@ DEFUN (babel_set_wired, DEFUN (babel_set_wireless, babel_set_wireless_cmd, "babel wireless", - NO_STR - "Set this interface as wireless (is default).\n" - "No attributes") + "Babel interface commands\n" + "Disable wired optimiations (assume wireless)") { struct interface *ifp; babel_interface_nfo *babel_ifp; @@ -385,9 +384,8 @@ DEFUN (babel_set_wireless, DEFUN (babel_split_horizon, babel_split_horizon_cmd, "babel split-horizon", - IPV6_STR - "Perform split horizon\n" - "No attributes\n") + "Babel interface commands\n" + "Enable split horizon processing") { struct interface *ifp; babel_interface_nfo *babel_ifp; @@ -405,9 +403,8 @@ DEFUN (no_babel_split_horizon, no_babel_split_horizon_cmd, "no babel split-horizon", NO_STR - IPV6_STR - "Disable split horizon\n" - "No attributes\n") + "Babel interface commands\n" + "Disable split horizon processing") { struct interface *ifp; babel_interface_nfo *babel_ifp; @@ -423,15 +420,16 @@ DEFUN (no_babel_split_horizon, /* [Interface Command]. */ DEFUN (babel_set_hello_interval, babel_set_hello_interval_cmd, - "hello interval <5-1000000>", - "Set interface's hello interval (default: 4000).\n" - "Value in miliseconds\n") + "babel hello-interval <20-655340>", + "Babel interface commands\n" + "Time between scheduled hellos\n" + "Milliseconds\n") { struct interface *ifp; babel_interface_nfo *babel_ifp; int interval; - VTY_GET_INTEGER_RANGE("hello interval", interval, argv[0], 20, 10 * 0xFFFE); + VTY_GET_INTEGER_RANGE("milliseconds", interval, argv[0], 20, 10 * 0xFFFE); ifp = vty->index; babel_ifp = babel_get_if_nfo(ifp); @@ -441,12 +439,34 @@ DEFUN (babel_set_hello_interval, return CMD_SUCCESS; } +/* [Interface Command]. */ +DEFUN (babel_set_update_interval, + babel_set_update_interval_cmd, + "babel update-interval <20-655340>", + "Babel interface commands\n" + "Time between scheduled updates\n" + "Milliseconds\n") +{ + struct interface *ifp; + babel_interface_nfo *babel_ifp; + int interval; + + VTY_GET_INTEGER_RANGE("milliseconds", interval, argv[0], 20, 10 * 0xFFFE); + + ifp = vty->index; + babel_ifp = babel_get_if_nfo(ifp); + assert (babel_ifp != NULL); + + babel_ifp->update_interval = interval; + return CMD_SUCCESS; +} + /* [Interface Command]. */ DEFUN (babel_passive_interface, babel_passive_interface_cmd, - "passive-interface", - "The daemon will only announce redistributed routes\n" - "No attributes\n") + "babel passive-interface", + "Babel interface commands\n" + "Only announce redistributed routes on this interface\n") { if (allow_duplicates) { return CMD_WARNING; @@ -458,10 +478,10 @@ DEFUN (babel_passive_interface, /* [Interface Command]. */ DEFUN (no_babel_passive_interface, no_babel_passive_interface_cmd, - "no passive-interface", + "no babel passive-interface", NO_STR - "The daemon will announce all (filtred) routes\n" - "No attributes\n") + "Babel interface commands\n" + "Announce all routes on this interface\n") { parasitic = 0; return CMD_SUCCESS; @@ -899,6 +919,7 @@ babel_if_init () install_element(INTERFACE_NODE, &babel_set_wired_cmd); install_element(INTERFACE_NODE, &babel_set_wireless_cmd); install_element(INTERFACE_NODE, &babel_set_hello_interval_cmd); + install_element(INTERFACE_NODE, &babel_set_update_interval_cmd); install_element(INTERFACE_NODE, &babel_passive_interface_cmd); install_element(INTERFACE_NODE, &no_babel_passive_interface_cmd); -- cgit v1.2.1 From 9c298c7119c1dba6c589b8f4c358debd8e694b72 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sat, 11 Feb 2012 14:06:24 +0100 Subject: babeld: display update-interval and resend-delay in show commands" --- babeld/babel_interface.c | 1 + 1 file changed, 1 insertion(+) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index bc58b7e3..588fea70 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -732,6 +732,7 @@ show_babel_interface_sub (struct vty *vty, struct interface *ifp) vty_out (vty, " Split horizon mode is %s%s", CHECK_FLAG (babel_ifp->flags, BABEL_IF_SPLIT_HORIZON) ? "On" : "Off", VTY_NEWLINE); vty_out (vty, " Hello interval is %u ms%s", babel_ifp->hello_interval, VTY_NEWLINE); + vty_out (vty, " Update interval is %u ms%s", babel_ifp->update_interval, VTY_NEWLINE); } DEFUN (show_babel_interface, -- cgit v1.2.1 From a14ef5eeccc8c76c41830475bbe3c31c9e14faa5 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Sat, 11 Feb 2012 21:06:16 +0400 Subject: babeld: justify "running-config" meaning in CLI The primary focus of this commit is to make "show running-config" command display more current configuration, including some of the bits previously seen in the output of "show babel running-config". Besides that, the following commands were renamed for consistency with the syntax of other components: "debug *" to "debug babel *" (and moved to top level) "show babel running-config" to "show babel parameters" * babel_interface.c * show_babel_running_config(): rename to show_babel_parameters(), update syntax pattern, don't call show_babeld_configuration() * babel_if_init(): update respectively * babel_enable_if_config_write(): new VTY helper for static babel_enable_if * babel_interface.h: add extern declaration * babel_main.c: unset all debug options by default * show_babel_main_configuration(): remove debug options decoder * babel_zebra.c * babel_debug(): rename to debug_babel(), update syntax pattern * no_babel_debug(): rename to no_debug_babel(), update syntax pattern * babelz_zebra_init(): update respectively * debug_babel_config_write() new VTY helper for static debug_type * babel_zebra.h: add extern declaration * babeld.c * babel_config_write(): add the code to output "debug babel *", "router babel", "redistribute *" and "network *" statements * show_babeld_configuration(): dismiss * babeld.h: remove extern declaration * babeld.texi: update for renamed commands * babeld.conf.sample: idem, add debug statements block --- babeld/babel_interface.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 588fea70..404be7a2 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -877,9 +877,9 @@ DEFUN (show_babel_database, return CMD_SUCCESS; } -DEFUN (show_babel_running_config, - show_babel_running_config_cmd, - "show babel running-config", +DEFUN (show_babel_parameters, + show_babel_parameters_cmd, + "show babel parameters", SHOW_STR IP_STR "Babel information\n" @@ -888,7 +888,6 @@ DEFUN (show_babel_running_config, { vty_out(vty, " -- Babel running configuration --%s", VTY_NEWLINE); show_babel_main_configuration(vty); - show_babeld_configuration(vty); vty_out(vty, " -- distribution lists --%s", VTY_NEWLINE); config_show_distribute(vty); @@ -931,8 +930,8 @@ babel_if_init () install_element(ENABLE_NODE, &show_babel_neighbour_cmd); install_element(VIEW_NODE, &show_babel_database_cmd); install_element(ENABLE_NODE, &show_babel_database_cmd); - install_element(VIEW_NODE, &show_babel_running_config_cmd); - install_element(ENABLE_NODE, &show_babel_running_config_cmd); + install_element(VIEW_NODE, &show_babel_parameters_cmd); + install_element(ENABLE_NODE, &show_babel_parameters_cmd); } /* hooks: functions called respectively when struct interface is @@ -980,6 +979,22 @@ interface_config_write (struct vty *vty) return write; } +/* Output a "network" statement line for each of the enabled interfaces. */ +int +babel_enable_if_config_write (struct vty * vty) +{ + unsigned int i, lines = 0; + char *str; + + for (i = 0; i < vector_active (babel_enable_if); i++) + if ((str = vector_slot (babel_enable_if, i)) != NULL) + { + vty_out (vty, " network %s%s", str, VTY_NEWLINE); + lines++; + } + return lines; +} + /* functions to allocate or free memory for a babel_interface_nfo, filling needed fields */ static babel_interface_nfo * -- cgit v1.2.1 From cb4b13d945a4b44282e59fa2be9ceda752420a13 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Mon, 13 Feb 2012 22:13:37 +0400 Subject: babeld: drive interface_config_write() forward --- babeld/babel_interface.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 404be7a2..24f56f38 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -951,7 +951,8 @@ babel_if_delete_hook (struct interface *ifp) return 0; } -/* Configuration write function for babeld. */ +/* Output an "interface" section for each of the known interfaces with +babeld-specific statement lines where appropriate. */ static int interface_config_write (struct vty *vty) { @@ -960,20 +961,27 @@ interface_config_write (struct vty *vty) int write = 0; for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) { - /* Do not display the interface if there is no configuration about it */ - if (ifp->desc == NULL) - continue; - vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); if (ifp->desc) vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE); - - /* TODO: to be completed... */ - + if (IS_ENABLE (ifp)) + { + babel_interface_nfo *babel_ifp = babel_get_if_nfo (ifp); + /* wireless/no split-horizon is the default */ + if (CHECK_FLAG (babel_ifp->flags, BABEL_IF_WIRED)) + { + vty_out (vty, " babel wired%s", VTY_NEWLINE); + write++; + } + if (CHECK_FLAG (babel_ifp->flags, BABEL_IF_SPLIT_HORIZON)) + { + vty_out (vty, " babel split-horizon%s", VTY_NEWLINE); + write++; + } + } vty_out (vty, "!%s", VTY_NEWLINE); - write++; } return write; -- cgit v1.2.1 From 36329c02c36703cc2158c1c99b86045fed26d4ae Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 14 Feb 2012 08:49:57 +0100 Subject: babeld: remove remains of standalone babeld's configuration code. Standalone babeld has a configuration interface that is not used in Quagga. This removes a few bits of this code that survived the port to Quagga. --- babeld/babel_interface.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 24f56f38..2b5f9569 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -565,10 +565,6 @@ interface_recalculate(struct interface *ifp) babel_ifp->flags |= BABEL_IF_LQ; } - /* Since the interface was marked as active above, the - idle_hello_interval cannot be the one being used here. */ - babel_ifp->update_interval = babel_ifp->hello_interval * 4; - memset(&mreq, 0, sizeof(mreq)); memcpy(&mreq.ipv6mr_multiaddr, protocol_group, 16); mreq.ipv6mr_interface = ifp->ifindex; @@ -1019,7 +1015,8 @@ babel_interface_allocate (void) babel_ifp->bucket_time = babel_now.tv_sec; babel_ifp->bucket = BUCKET_TOKENS_MAX; babel_ifp->hello_seqno = (random() & 0xFFFF); - babel_ifp->hello_interval = BABELD_DEFAULT_HELLO_INTERVAL; + babel_ifp->hello_interval = BABEL_DEFAULT_HELLO_INTERVAL; + babel_ifp->update_interval = BABEL_DEFAULT_UPDATE_INTERVAL; babel_ifp->channel = BABEL_IF_CHANNEL_INTERFERING; return babel_ifp; -- cgit v1.2.1 From 260948cdd6030b332137dfa0580d5a9ba651b145 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 14 Feb 2012 09:09:32 +0100 Subject: babeld: set interface flags eagerly, not at interface up. --- babeld/babel_interface.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 2b5f9569..00d53bc6 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -288,7 +288,6 @@ babel_enable_if_delete (const char *ifname) return 1; } - /* [Babel Command] Babel enable on specified interface or matched network. */ DEFUN (babel_network, babel_network_cmd, @@ -344,6 +343,25 @@ DEFUN (no_babel_network, return CMD_SUCCESS; } +/* There are a number of interface parameters that must be changed when + an interface becomes wired/wireless. In Quagga, they cannot be + configured separately. */ + +static void +babel_set_wired_internal(babel_interface_nfo *babel_ifp, int wired) +{ + if(wired) { + babel_ifp->flags |= BABEL_IF_WIRED; + babel_ifp->cost = 96; + babel_ifp->flags &= ~BABEL_IF_LQ; + } else { + babel_ifp->flags &= ~BABEL_IF_WIRED; + babel_ifp->cost = 256; + babel_ifp->flags |= BABEL_IF_LQ; + } + +} + /* [Interface Command] Tell the interface is wire. */ DEFUN (babel_set_wired, babel_set_wired_cmd, @@ -358,7 +376,7 @@ DEFUN (babel_set_wired, babel_ifp = babel_get_if_nfo(ifp); assert (babel_ifp != NULL); - babel_ifp->flags |= BABEL_IF_WIRED; + babel_set_wired_internal(babel_ifp, 1); return CMD_SUCCESS; } @@ -376,7 +394,7 @@ DEFUN (babel_set_wireless, babel_ifp = babel_get_if_nfo(ifp); assert (babel_ifp != NULL); - babel_ifp->flags &= ~BABEL_IF_WIRED; + babel_set_wired_internal(babel_ifp, 0); return CMD_SUCCESS; } @@ -557,14 +575,6 @@ interface_recalculate(struct interface *ifp) resize_receive_buffer(mtu); - if(!(babel_ifp->flags & BABEL_IF_WIRED)) { /* if (wired) */ - babel_ifp->cost = 96; - babel_ifp->flags &= ~BABEL_IF_LQ; - } else { - babel_ifp->cost = 256; - babel_ifp->flags |= BABEL_IF_LQ; - } - memset(&mreq, 0, sizeof(mreq)); memcpy(&mreq.ipv6mr_multiaddr, protocol_group, 16); mreq.ipv6mr_interface = ifp->ifindex; @@ -1018,6 +1028,7 @@ babel_interface_allocate (void) babel_ifp->hello_interval = BABEL_DEFAULT_HELLO_INTERVAL; babel_ifp->update_interval = BABEL_DEFAULT_UPDATE_INTERVAL; babel_ifp->channel = BABEL_IF_CHANNEL_INTERFERING; + babel_set_wired_internal(babel_ifp, 0); return babel_ifp; } -- cgit v1.2.1 From cbde15513ba47f6e7f6d02fcafcfb12cd5b1df77 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Tue, 14 Feb 2012 15:12:03 +0400 Subject: babeld: 3 more timing statements in config text This commit makes the following lines visible in running-config text, when respective intervals are configured to non-default values: * babel hello-interval * babel update-interval * babel resend-delay --- babeld/babel_interface.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 00d53bc6..958b1b98 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -986,6 +986,16 @@ interface_config_write (struct vty *vty) vty_out (vty, " babel split-horizon%s", VTY_NEWLINE); write++; } + if (babel_ifp->hello_interval != BABEL_DEFAULT_HELLO_INTERVAL) + { + vty_out (vty, " babel hello-interval %u%s", babel_ifp->hello_interval, VTY_NEWLINE); + write++; + } + if (babel_ifp->update_interval != BABEL_DEFAULT_UPDATE_INTERVAL) + { + vty_out (vty, " babel update-interval %u%s", babel_ifp->update_interval, VTY_NEWLINE); + write++; + } } vty_out (vty, "!%s", VTY_NEWLINE); write++; -- cgit v1.2.1 From 6881f2698279f3c47a55e8969860eeac59e8c3d7 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 14 Feb 2012 15:43:34 +0100 Subject: babeld: remove "parasitic" mode. This is the functionality described in Appendix C of RFC 6126. Its main purpose is to avoid keeping a full source table, which makes it possible to implement a subset of Babel in just a few hundred lines of code. However, in Quagga the code for maintaining the source table is already there, and a parasitic implementation can be simulated using filtering -- so it makes little sense to keep the functionality. --- babeld/babel_interface.c | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'babeld/babel_interface.c') diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 958b1b98..ace28127 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -479,32 +479,6 @@ DEFUN (babel_set_update_interval, return CMD_SUCCESS; } -/* [Interface Command]. */ -DEFUN (babel_passive_interface, - babel_passive_interface_cmd, - "babel passive-interface", - "Babel interface commands\n" - "Only announce redistributed routes on this interface\n") -{ - if (allow_duplicates) { - return CMD_WARNING; - } - parasitic = 1; - return CMD_SUCCESS; -} - -/* [Interface Command]. */ -DEFUN (no_babel_passive_interface, - no_babel_passive_interface_cmd, - "no babel passive-interface", - NO_STR - "Babel interface commands\n" - "Announce all routes on this interface\n") -{ - parasitic = 0; - return CMD_SUCCESS; -} - /* This should be no more than half the hello interval, so that hellos aren't sent late. The result is in milliseconds. */ unsigned @@ -926,8 +900,6 @@ babel_if_init () install_element(INTERFACE_NODE, &babel_set_wireless_cmd); install_element(INTERFACE_NODE, &babel_set_hello_interval_cmd); install_element(INTERFACE_NODE, &babel_set_update_interval_cmd); - install_element(INTERFACE_NODE, &babel_passive_interface_cmd); - install_element(INTERFACE_NODE, &no_babel_passive_interface_cmd); /* "show babel ..." commands */ install_element(VIEW_NODE, &show_babel_interface_cmd); -- cgit v1.2.1