summaryrefslogtreecommitdiffstats
path: root/babeld
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:31 +0000
commitacb594b1d825c6e12369cebb941968ec08c840ce (patch)
treed544788908e7353a4f117e2991f15f4236a0c963 /babeld
parentAdding upstream version 9.1. (diff)
downloadfrr-acb594b1d825c6e12369cebb941968ec08c840ce.tar.xz
frr-acb594b1d825c6e12369cebb941968ec08c840ce.zip
Adding upstream version 10.0.upstream/10.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'babeld')
-rw-r--r--babeld/babel_interface.c12
-rw-r--r--babeld/babel_interface.h1
-rw-r--r--babeld/babel_main.c33
-rw-r--r--babeld/babeld.c74
-rw-r--r--babeld/babeld.h1
-rw-r--r--babeld/kernel.c1
6 files changed, 92 insertions, 30 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c
index ceff472..c4349b5 100644
--- a/babeld/babel_interface.c
+++ b/babeld/babel_interface.c
@@ -695,6 +695,11 @@ interface_reset(struct interface *ifp)
babel_ifp->cost,
babel_ifp->ipv4 ? ", IPv4" : "");
+ if (babel_ifp->ipv4 != NULL){
+ free(babel_ifp->ipv4);
+ babel_ifp->ipv4 = NULL;
+ }
+
return 1;
}
@@ -734,12 +739,11 @@ 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) {
+ frr_each (if_connected, ifp->connected, connected) {
if (connected->address->family == AF_INET6
&& memcmp(&connected->address->u.prefix6, address,
IPV6_MAX_BYTELEN)
@@ -1345,5 +1349,9 @@ babel_interface_allocate (void)
static void
babel_interface_free (babel_interface_nfo *babel_ifp)
{
+ if (babel_ifp->ipv4){
+ free(babel_ifp->ipv4);
+ babel_ifp->ipv4 = NULL;
+ }
XFREE(MTYPE_BABEL_IF, babel_ifp);
}
diff --git a/babeld/babel_interface.h b/babeld/babel_interface.h
index 12fa6e2..a585e23 100644
--- a/babeld/babel_interface.h
+++ b/babeld/babel_interface.h
@@ -82,7 +82,6 @@ static inline int
if_up(struct interface *ifp)
{
return (if_is_operative(ifp) &&
- ifp->connected != NULL &&
CHECK_FLAG(babel_get_if_nfo(ifp)->flags, BABEL_IF_IS_UP));
}
diff --git a/babeld/babel_main.c b/babeld/babel_main.c
index b6126d5..10ab1b5 100644
--- a/babeld/babel_main.c
+++ b/babeld/babel_main.c
@@ -5,6 +5,8 @@ Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
/* include zebra library */
#include <zebra.h>
+#include <fcntl.h>
+
#include "getopt.h"
#include "if.h"
#include "log.h"
@@ -56,7 +58,6 @@ unsigned char protocol_group[16]; /* babel's link-local multicast address */
int protocol_port; /* babel's port */
int protocol_socket = -1; /* socket: communicate with others babeld */
-static const char babel_config_default[] = SYSCONFDIR BABEL_DEFAULT_CONFIG;
static char *babel_vty_addr = NULL;
static int babel_vty_port = BABEL_VTY_PORT;
@@ -124,18 +125,20 @@ static const struct frr_yang_module_info *const babeld_yang_modules[] = {
&frr_vrf_info,
};
+/* clang-format off */
FRR_DAEMON_INFO(babeld, BABELD,
- .vty_port = BABEL_VTY_PORT,
- .proghelp = "Implementation of the BABEL routing protocol.",
+ .vty_port = BABEL_VTY_PORT,
+ .proghelp = "Implementation of the BABEL routing protocol.",
- .signals = babel_signals,
- .n_signals = array_size(babel_signals),
+ .signals = babel_signals,
+ .n_signals = array_size(babel_signals),
- .privs = &babeld_privs,
+ .privs = &babeld_privs,
- .yang_modules = babeld_yang_modules,
- .n_yang_modules = array_size(babeld_yang_modules),
+ .yang_modules = babeld_yang_modules,
+ .n_yang_modules = array_size(babeld_yang_modules),
);
+/* clang-format on */
int
main(int argc, char **argv)
@@ -169,8 +172,8 @@ main(int argc, char **argv)
}
}
- snprintf(state_file, sizeof(state_file), "%s/%s",
- frr_vtydir, "babel-state");
+ snprintf(state_file, sizeof(state_file), "%s/%s", frr_runstatedir,
+ "babel-state");
/* create the threads handler */
master = frr_init ();
@@ -182,8 +185,10 @@ main(int argc, char **argv)
change_smoothing_half_life(BABEL_DEFAULT_SMOOTHING_HALF_LIFE);
/* init some quagga's dependencies, and babeld's commands */
- if_zapi_callbacks(babel_ifp_create, babel_ifp_up,
- babel_ifp_down, babel_ifp_destroy);
+ hook_register_prio(if_real, 0, babel_ifp_create);
+ hook_register_prio(if_up, 0, babel_ifp_up);
+ hook_register_prio(if_down, 0, babel_ifp_down);
+ hook_register_prio(if_unreal, 0, babel_ifp_destroy);
babeld_quagga_init();
/* init zebra client's structure and it's commands */
/* this replace kernel_setup && kernel_setup_socket */
@@ -306,6 +311,8 @@ babel_exit_properly(void)
babel_save_state_file();
debugf(BABEL_DEBUG_COMMON, "Remove pid file.");
debugf(BABEL_DEBUG_COMMON, "Done.");
+
+ vrf_terminate();
frr_fini();
exit(0);
@@ -360,7 +367,7 @@ show_babel_main_configuration (struct vty *vty)
"id = %s\n"
"kernel_metric = %d\n",
state_file,
- babeld_di.config_file ? babeld_di.config_file : babel_config_default,
+ babeld_di.config_file,
format_address(protocol_group),
protocol_port,
babel_vty_addr ? babel_vty_addr : "None",
diff --git a/babeld/babeld.c b/babeld/babeld.c
index ebf8474..6f0a5a7 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -242,7 +242,7 @@ babel_get_myid(void)
/* We failed to get a global EUI64 from the interfaces we were given.
Let's try to find an interface with a MAC address. */
for(i = 1; i < 256; i++) {
- char buf[INTERFACE_NAMSIZ], *ifname;
+ char buf[IFNAMSIZ], *ifname;
unsigned char eui[8];
ifname = if_indextoname(i, buf);
if(ifname == NULL)
@@ -696,9 +696,8 @@ DEFPY (babel_set_smoothing_half_life,
DEFUN (babel_distribute_list,
babel_distribute_list_cmd,
- "distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
+ "distribute-list ACCESSLIST4_NAME <in|out> [WORD]",
"Filter networks in routing updates\n"
- "Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
@@ -710,16 +709,26 @@ DEFUN (babel_distribute_list,
if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;
- return distribute_list_parser(prefix, true, argv[2 + prefix]->text,
+ return distribute_list_parser(babel_routing_process->distribute_ctx,
+ prefix, true, argv[2 + prefix]->text,
argv[1 + prefix]->arg, ifname);
}
+ALIAS (babel_distribute_list,
+ babel_distribute_list_prefix_cmd,
+ "distribute-list prefix PREFIXLIST4_NAME <in|out> [WORD]",
+ "Filter networks in routing updates\n"
+ "Specify a prefix list\n"
+ "Prefix-list name\n"
+ "Filter incoming routing updates\n"
+ "Filter outgoing routing updates\n"
+ "Interface name\n")
+
DEFUN (babel_no_distribute_list,
babel_no_distribute_list_cmd,
- "no distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
+ "no distribute-list ACCESSLIST4_NAME <in|out> [WORD]",
NO_STR
"Filter networks in routing updates\n"
- "Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
@@ -731,17 +740,28 @@ DEFUN (babel_no_distribute_list,
if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;
- return distribute_list_no_parser(vty, prefix, true,
+ return distribute_list_no_parser(babel_routing_process->distribute_ctx,
+ vty, prefix, true,
argv[3 + prefix]->text,
argv[2 + prefix]->arg, ifname);
}
+ALIAS (babel_no_distribute_list,
+ babel_no_distribute_list_prefix_cmd,
+ "no distribute-list prefix PREFIXLIST4_NAME <in|out> [WORD]",
+ NO_STR
+ "Filter networks in routing updates\n"
+ "Specify a prefix list\n"
+ "Prefix-list name\n"
+ "Filter incoming routing updates\n"
+ "Filter outgoing routing updates\n"
+ "Interface name\n")
+
DEFUN (babel_ipv6_distribute_list,
babel_ipv6_distribute_list_cmd,
- "ipv6 distribute-list [prefix] ACCESSLIST6_NAME <in|out> [WORD]",
+ "ipv6 distribute-list ACCESSLIST6_NAME <in|out> [WORD]",
"IPv6\n"
"Filter networks in routing updates\n"
- "Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
@@ -753,17 +773,28 @@ DEFUN (babel_ipv6_distribute_list,
if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;
- return distribute_list_parser(prefix, false, argv[3 + prefix]->text,
+ return distribute_list_parser(babel_routing_process->distribute_ctx,
+ prefix, false, argv[3 + prefix]->text,
argv[2 + prefix]->arg, ifname);
}
+ALIAS (babel_ipv6_distribute_list,
+ babel_ipv6_distribute_list_prefix_cmd,
+ "ipv6 distribute-list prefix PREFIXLIST6_NAME <in|out> [WORD]",
+ "IPv6\n"
+ "Filter networks in routing updates\n"
+ "Specify a prefix list\n"
+ "Prefix-list name\n"
+ "Filter incoming routing updates\n"
+ "Filter outgoing routing updates\n"
+ "Interface name\n")
+
DEFUN (babel_no_ipv6_distribute_list,
babel_no_ipv6_distribute_list_cmd,
- "no ipv6 distribute-list [prefix] ACCESSLIST6_NAME <in|out> [WORD]",
+ "no ipv6 distribute-list ACCESSLIST6_NAME <in|out> [WORD]",
NO_STR
"IPv6\n"
"Filter networks in routing updates\n"
- "Specify a prefix\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
@@ -775,11 +806,24 @@ DEFUN (babel_no_ipv6_distribute_list,
if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;
- return distribute_list_no_parser(vty, prefix, false,
+ return distribute_list_no_parser(babel_routing_process->distribute_ctx,
+ vty, prefix, false,
argv[4 + prefix]->text,
argv[3 + prefix]->arg, ifname);
}
+ALIAS (babel_no_ipv6_distribute_list,
+ babel_no_ipv6_distribute_list_prefix_cmd,
+ "no ipv6 distribute-list prefix PREFIXLIST6_NAME <in|out> [WORD]",
+ NO_STR
+ "IPv6\n"
+ "Filter networks in routing updates\n"
+ "Specify a prefix list\n"
+ "Prefix-list name\n"
+ "Filter incoming routing updates\n"
+ "Filter outgoing routing updates\n"
+ "Interface name\n")
+
void
babeld_quagga_init(void)
{
@@ -797,9 +841,13 @@ babeld_quagga_init(void)
install_element(BABEL_NODE, &babel_set_smoothing_half_life_cmd);
install_element(BABEL_NODE, &babel_distribute_list_cmd);
+ install_element(BABEL_NODE, &babel_distribute_list_prefix_cmd);
install_element(BABEL_NODE, &babel_no_distribute_list_cmd);
+ install_element(BABEL_NODE, &babel_no_distribute_list_prefix_cmd);
install_element(BABEL_NODE, &babel_ipv6_distribute_list_cmd);
+ install_element(BABEL_NODE, &babel_ipv6_distribute_list_prefix_cmd);
install_element(BABEL_NODE, &babel_no_ipv6_distribute_list_cmd);
+ install_element(BABEL_NODE, &babel_no_ipv6_distribute_list_prefix_cmd);
vrf_cmd_init(NULL);
diff --git a/babeld/babeld.h b/babeld/babeld.h
index 619550f..5573719 100644
--- a/babeld/babeld.h
+++ b/babeld/babeld.h
@@ -53,7 +53,6 @@ Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
#endif
-#define BABEL_VTY_PORT 2609
#define BABEL_DEFAULT_CONFIG "babeld.conf"
/* Values in milliseconds */
diff --git a/babeld/kernel.c b/babeld/kernel.c
index 4fe5bcf..aed6dc9 100644
--- a/babeld/kernel.c
+++ b/babeld/kernel.c
@@ -11,6 +11,7 @@ Copyright 2011, 2012 by Matthieu Boutier and Juliusz Chroboczek
#include <sys/time.h>
#include <sys/param.h>
#include <time.h>
+#include <fcntl.h>
#include "babeld.h"