summaryrefslogtreecommitdiffstats
path: root/babeld
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-11-17 07:11:26 +0100
committerDaniel Baumann <daniel@debian.org>2024-11-17 07:11:26 +0100
commitd5587ccda8edb748ca8bfd1f0ed92a801ac5bfc6 (patch)
tree705ea89e798053f9c227b85512bc9f5b437b0093 /babeld
parentReleasing debian version 10.1.1-3. (diff)
downloadfrr-d5587ccda8edb748ca8bfd1f0ed92a801ac5bfc6.tar.xz
frr-d5587ccda8edb748ca8bfd1f0ed92a801ac5bfc6.zip
Merging upstream version 10.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'babeld')
-rw-r--r--babeld/babel_interface.c28
-rw-r--r--babeld/babel_interface.h1
-rw-r--r--babeld/babel_main.c4
-rw-r--r--babeld/babeld.c9
-rw-r--r--babeld/babeld.h1
-rw-r--r--babeld/kernel.c8
-rw-r--r--babeld/message.c16
-rw-r--r--babeld/route.c2
-rw-r--r--babeld/util.c9
-rw-r--r--babeld/util.h8
10 files changed, 52 insertions, 34 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c
index c4349b50..b83c7b19 100644
--- a/babeld/babel_interface.c
+++ b/babeld/babel_interface.c
@@ -108,6 +108,7 @@ babel_interface_address_add (ZAPI_CALLBACK_ARGS)
if (prefix->family == AF_INET) {
flush_interface_routes(ifc->ifp, 0);
babel_ifp = babel_get_if_nfo(ifc->ifp);
+ assert (babel_ifp != NULL);
if (babel_ifp->ipv4 == NULL) {
babel_ifp->ipv4 = malloc(4);
if (babel_ifp->ipv4 == NULL) {
@@ -144,6 +145,7 @@ babel_interface_address_delete (ZAPI_CALLBACK_ARGS)
if (prefix->family == AF_INET) {
flush_interface_routes(ifc->ifp, 0);
babel_ifp = babel_get_if_nfo(ifc->ifp);
+ assert (babel_ifp != NULL);
if (babel_ifp->ipv4 != NULL
&& memcmp(babel_ifp->ipv4, &prefix->u.prefix4, IPV4_MAX_BYTELEN)
== 0) {
@@ -542,7 +544,10 @@ DEFPY (babel_set_channel,
unsigned
jitter(babel_interface_nfo *babel_ifp, int urgent)
{
- unsigned interval = babel_ifp->hello_interval;
+ unsigned interval;
+
+ assert (babel_ifp != NULL);
+ interval = babel_ifp->hello_interval;
if(urgent)
interval = MIN(interval, 100);
else
@@ -553,7 +558,10 @@ jitter(babel_interface_nfo *babel_ifp, int urgent)
unsigned
update_jitter(babel_interface_nfo *babel_ifp, int urgent)
{
- unsigned interval = babel_ifp->hello_interval;
+ unsigned interval;
+
+ assert (babel_ifp != NULL);
+ interval = babel_ifp->hello_interval;
if(urgent)
interval = MIN(interval, 100);
else
@@ -566,10 +574,11 @@ update_jitter(babel_interface_nfo *babel_ifp, int urgent)
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;
+ babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp);
+ assert (babel_ifp != NULL);
if (!IS_ENABLE(ifp))
return -1;
@@ -656,6 +665,7 @@ interface_reset(struct interface *ifp)
int rc;
struct ipv6_mreq mreq;
babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp);
+ assert (babel_ifp != NULL);
if (!CHECK_FLAG(babel_ifp->flags, BABEL_IF_IS_UP))
return 0;
@@ -777,6 +787,7 @@ show_babel_interface_sub (struct vty *vty, struct interface *ifp)
return;
}
babel_ifp = babel_get_if_nfo (ifp);
+ assert (babel_ifp != NULL);
vty_out (vty, " Babel protocol is running on this interface\n");
vty_out (vty, " Operating mode is \"%s\"\n",
CHECK_FLAG(babel_ifp->flags, BABEL_IF_WIRED) ? "wired" : "wireless");
@@ -1160,6 +1171,11 @@ DEFUN (show_babel_parameters,
return CMD_SUCCESS;
}
+void babel_if_terminate(void)
+{
+ vector_free(babel_enable_if);
+}
+
void
babel_if_init(void)
{
@@ -1228,6 +1244,7 @@ interface_config_write (struct vty *vty)
if (ifp->desc)
vty_out (vty, " description %s\n",ifp->desc);
babel_interface_nfo *babel_ifp = babel_get_if_nfo (ifp);
+ assert (babel_ifp != NULL);
/* wireless is the default*/
if (CHECK_FLAG (babel_ifp->flags, BABEL_IF_WIRED))
{
@@ -1330,10 +1347,11 @@ babel_interface_allocate (void)
{
babel_interface_nfo *babel_ifp;
babel_ifp = XCALLOC(MTYPE_BABEL_IF, sizeof(babel_interface_nfo));
+ assert (babel_ifp != NULL);
/* All flags are unset */
babel_ifp->bucket_time = babel_now.tv_sec;
babel_ifp->bucket = BUCKET_TOKENS_MAX;
- babel_ifp->hello_seqno = (frr_weak_random() & 0xFFFF);
+ babel_ifp->hello_seqno = CHECK_FLAG(frr_weak_random(), 0xFFFF);
babel_ifp->rtt_decay = BABEL_DEFAULT_RTT_DECAY;
babel_ifp->rtt_min = BABEL_DEFAULT_RTT_MIN;
babel_ifp->rtt_max = BABEL_DEFAULT_RTT_MAX;
@@ -1349,6 +1367,8 @@ babel_interface_allocate (void)
static void
babel_interface_free (babel_interface_nfo *babel_ifp)
{
+ assert (babel_ifp != NULL);
+
if (babel_ifp->ipv4){
free(babel_ifp->ipv4);
babel_ifp->ipv4 = NULL;
diff --git a/babeld/babel_interface.h b/babeld/babel_interface.h
index a585e23a..ab08ded9 100644
--- a/babeld/babel_interface.h
+++ b/babeld/babel_interface.h
@@ -94,6 +94,7 @@ struct buffered_update {
/* init function */
void babel_if_init(void);
+void babel_if_terminate(void);
/* Callback functions for zebra client */
int babel_interface_up (int, struct zclient *, zebra_size_t, vrf_id_t);
diff --git a/babeld/babel_main.c b/babeld/babel_main.c
index 10ab1b53..ddc75f71 100644
--- a/babeld/babel_main.c
+++ b/babeld/babel_main.c
@@ -305,9 +305,9 @@ babel_exit_properly(void)
/* Uninstall and flush all routes. */
debugf(BABEL_DEBUG_COMMON, "Uninstall routes.");
- flush_all_routes();
- babel_interface_close_all();
+ babel_clean_routing_process();
babel_zebra_close_connexion();
+ babel_if_terminate();
babel_save_state_file();
debugf(BABEL_DEBUG_COMMON, "Remove pid file.");
debugf(BABEL_DEBUG_COMMON, "Done.");
diff --git a/babeld/babeld.c b/babeld/babeld.c
index 6f0a5a7b..b562f0b7 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -204,7 +204,7 @@ static void babel_read_protocol(struct event *thread)
making these inits have sense. */
static void babel_init_routing_process(struct event *thread)
{
- myseqno = (frr_weak_random() & 0xFFFF);
+ myseqno = CHECK_FLAG(frr_weak_random(), 0xFFFF);
babel_get_myid();
babel_load_state_file();
debugf(BABEL_DEBUG_COMMON, "My ID is : %s.", format_eui64(myid));
@@ -299,8 +299,7 @@ babel_initial_noise(void)
}
/* Delete all the added babel routes, make babeld only speak to zebra. */
-static void
-babel_clean_routing_process(void)
+void babel_clean_routing_process(void)
{
flush_all_routes();
babel_interface_close_all();
@@ -444,8 +443,8 @@ babel_fill_with_next_timeout(struct timeval *tv)
#if (defined NO_DEBUG)
#define printIfMin(a,b,c,d)
#else
-#define printIfMin(a, b, c, d) \
- if (unlikely(debug & BABEL_DEBUG_TIMEOUT)) { \
+#define printIfMin(a, b, c, d) \
+ if (unlikely(CHECK_FLAG(debug, BABEL_DEBUG_TIMEOUT))) { \
printIfMin(a, b, c, d); \
}
diff --git a/babeld/babeld.h b/babeld/babeld.h
index 5573719a..17a0381d 100644
--- a/babeld/babeld.h
+++ b/babeld/babeld.h
@@ -98,5 +98,6 @@ extern int redistribute_filter(const unsigned char *prefix, unsigned short plen,
extern int resize_receive_buffer(int size);
extern void schedule_neighbours_check(int msecs, int override);
extern struct babel *babel_lookup(void);
+extern void babel_clean_routing_process(void);
#endif /* BABEL_BABELD_H */
diff --git a/babeld/kernel.c b/babeld/kernel.c
index aed6dc9c..4957b04e 100644
--- a/babeld/kernel.c
+++ b/babeld/kernel.c
@@ -92,13 +92,9 @@ kernel_route(enum babel_kernel_routes operation, const unsigned char *pref,
case ROUTE_MODIFY:
if(newmetric == metric && memcmp(newgate, gate, 16) == 0 &&
newifindex == ifindex)
- return 0;
- debugf(BABEL_DEBUG_ROUTE, "Modify route: delete old; add new.");
- rc = zebra_route(0, family, pref, plen, gate, ifindex, metric);
- if (rc < 0)
- return -1;
+ return 0;
- rc = zebra_route(1, family, pref, plen, newgate, newifindex,
+ rc = zebra_route(1, family, pref, plen, newgate, newifindex,
newmetric);
return rc;
}
diff --git a/babeld/message.c b/babeld/message.c
index 1b83eb9e..5a33d5c2 100644
--- a/babeld/message.c
+++ b/babeld/message.c
@@ -324,8 +324,8 @@ parse_request_subtlv(int ae, const unsigned char *a, int alen,
have_src_prefix = 1;
} else {
debugf(BABEL_DEBUG_COMMON,"Received unknown%s Route Request sub-TLV %d.",
- ((type & 0x80) != 0) ? " mandatory" : "", type);
- if((type & 0x80) != 0)
+ (CHECK_FLAG(type, 0x80) != 0) ? " mandatory" : "", type);
+ if(CHECK_FLAG(type, 0x80) != 0)
return -1;
}
@@ -588,7 +588,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
else
rc = -1;
if(rc < 0) {
- if(message[3] & 0x80)
+ if(CHECK_FLAG(message[3], 0x80))
have_v4_prefix = have_v6_prefix = 0;
goto fail;
}
@@ -596,7 +596,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
plen = message[4] + (message[2] == 1 ? 96 : 0);
- if(message[3] & 0x80) {
+ if(CHECK_FLAG(message[3], 0x80)) {
if(message[2] == 1) {
memcpy(v4_prefix, prefix, 16);
have_v4_prefix = 1;
@@ -605,7 +605,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
have_v6_prefix = 1;
}
}
- if(message[3] & 0x40) {
+ if(CHECK_FLAG(message[3], 0x40)) {
if(message[2] == 1) {
memset(router_id, 0, 4);
memcpy(router_id + 4, prefix + 12, 4);
@@ -620,8 +620,8 @@ parse_packet(const unsigned char *from, struct interface *ifp,
goto fail;
}
debugf(BABEL_DEBUG_COMMON,"Received update%s%s for %s from %s on %s.",
- (message[3] & 0x80) ? "/prefix" : "",
- (message[3] & 0x40) ? "/id" : "",
+ ((CHECK_FLAG(message[3], 0x80)) ? "/prefix" : ""),
+ ((CHECK_FLAG(message[3], 0x40)) ? "/id" : ""),
format_prefix(prefix, plen),
format_address(from), ifp->name);
@@ -1059,7 +1059,7 @@ void send_hello_noupdate(struct interface *ifp, unsigned interval)
babel_ifp->hello_seqno, interval, ifp->name);
start_message(ifp, MESSAGE_HELLO,
- (babel_ifp->flags & BABEL_IF_TIMESTAMPS) ? 12 : 6);
+ (CHECK_FLAG(babel_ifp->flags, BABEL_IF_TIMESTAMPS) ? 12 : 6));
babel_ifp->buffered_hello = babel_ifp->buffered - 2;
accumulate_short(ifp, 0);
accumulate_short(ifp, babel_ifp->hello_seqno);
diff --git a/babeld/route.c b/babeld/route.c
index 2c7e9237..466f4138 100644
--- a/babeld/route.c
+++ b/babeld/route.c
@@ -352,7 +352,7 @@ route_stream_done(struct route_stream *stream)
static int
metric_to_kernel(int metric)
{
- return metric < INFINITY ? kernel_metric : KERNEL_INFINITY;
+ return metric < INFINITY ? metric : KERNEL_INFINITY;
}
/* This is used to maintain the invariant that the installed route is at
diff --git a/babeld/util.c b/babeld/util.c
index 4facdabb..f5edb0ed 100644
--- a/babeld/util.c
+++ b/babeld/util.c
@@ -211,8 +211,8 @@ mask_prefix(unsigned char *restrict ret,
memset(ret, 0, 16);
memcpy(ret, prefix, plen / 8);
if(plen % 8 != 0)
- ret[plen / 8] =
- (prefix[plen / 8] & ((0xFF << (8 - (plen % 8))) & 0xFF));
+ ret[plen / 8] = CHECK_FLAG(prefix[plen / 8],
+ CHECK_FLAG((0xFF << (8 - (plen % 8))), 0xFF));
return ret;
}
@@ -353,12 +353,13 @@ martian_prefix(const unsigned char *prefix, int plen)
{
return
(plen >= 8 && prefix[0] == 0xFF) ||
- (plen >= 10 && prefix[0] == 0xFE && (prefix[1] & 0xC0) == 0x80) ||
+ (plen >= 10 && prefix[0] == 0xFE &&
+ (CHECK_FLAG(prefix[1], 0xC0) == 0x80)) ||
(plen >= 128 && memcmp(prefix, zeroes, 15) == 0 &&
(prefix[15] == 0 || prefix[15] == 1)) ||
(plen >= 96 && v4mapped(prefix) &&
((plen >= 104 && (prefix[12] == 127 || prefix[12] == 0)) ||
- (plen >= 100 && (prefix[12] & 0xE0) == 0xE0)));
+ (plen >= 100 && CHECK_FLAG(prefix[12], 0xE0) == 0xE0)));
}
int
diff --git a/babeld/util.h b/babeld/util.h
index ddc6a70d..2242032c 100644
--- a/babeld/util.h
+++ b/babeld/util.h
@@ -47,19 +47,19 @@ seqno_compare(unsigned short s1, unsigned short s2)
if(s1 == s2)
return 0;
else
- return ((s2 - s1) & 0x8000) ? 1 : -1;
+ return (CHECK_FLAG((s2 - s1), 0x8000)) ? 1 : -1;
}
static inline short
seqno_minus(unsigned short s1, unsigned short s2)
{
- return (short)((s1 - s2) & 0xFFFF);
+ return (short)(CHECK_FLAG((s1 - s2), 0xFFFF));
}
static inline unsigned short
seqno_plus(unsigned short s, int plus)
{
- return ((s + plus) & 0xFFFF);
+ return CHECK_FLAG((s + plus), 0xFFFF);
}
/* Returns a time in microseconds on 32 bits (thus modulo 2^32,
@@ -130,7 +130,7 @@ is_default(const unsigned char *prefix, int plen)
#define debugf(level, ...) \
do { \
- if (unlikely(debug & level)) \
+ if (unlikely(CHECK_FLAG(debug, level))) \
zlog_debug(__VA_ARGS__); \
} while (0)