1
0
mirror of https://gitlab.labs.nic.cz/labs/bird.git synced 2024-05-11 16:54:54 +00:00

Merge branch 'thread-next' into HEAD

This commit is contained in:
Maria Matejka
2023-11-02 14:43:15 +01:00
132 changed files with 6964 additions and 1362 deletions

View File

@@ -892,6 +892,7 @@ bird_thread_main(void *arg)
bird_thread_busy_update(thr, timeout);
account_to(&this_thread->idle);
birdloop_leave(thr->meta);
poll_retry:;
int rv = poll(pfd.pfd.data, pfd.pfd.used, timeout);
if (rv < 0)
@@ -902,6 +903,7 @@ poll_retry:;
}
account_to(&this_thread->overhead);
birdloop_enter(thr->meta);
/* Drain wakeup fd */
if (pfd.pfd.data[0].revents & POLLIN)

View File

@@ -278,6 +278,19 @@ times_update(void)
DBG("Time update collision: real_time");
}
btime
current_time_now(void)
{
struct timespec ts;
int rv;
rv = clock_gettime(CLOCK_MONOTONIC, &ts);
if (rv < 0)
die("clock_gettime: %m");
return ts.tv_sec S + ts.tv_nsec NS;
}
/**
* DOC: Sockets
*

View File

@@ -53,7 +53,7 @@
#include "nest/bird.h"
#include "nest/iface.h"
#include "nest/rt.h"
#include "nest/route.h"
#include "nest/protocol.h"
#include "filter/filter.h"
#include "conf/conf.h"

View File

@@ -197,12 +197,12 @@ log_commit(log_buffer *buf)
byte *begin = l->terminal ? buf->buf.start : buf->tm_pos;
off_t msg_len = buf->buf.pos - begin + 1;
do {
if (rf_write(rf, buf->tm_pos, msg_len))
if (rf_write(rf, begin, msg_len))
break;
log_lock();
rf = atomic_load_explicit(&l->rf, memory_order_acquire);
if (rf_write(rf, buf->tm_pos, msg_len))
if (rf_write(rf, begin, msg_len))
{
log_unlock();
break;
@@ -212,7 +212,7 @@ log_commit(log_buffer *buf)
log_unlock();
rf = atomic_load_explicit(&l->rf, memory_order_relaxed);
} while (!rf_write(rf, buf->tm_pos, msg_len));
} while (!rf_write(rf, begin, msg_len));
}
#ifdef HAVE_SYSLOG_H
else
@@ -251,6 +251,8 @@ log_prepare(log_buffer *buf, int class)
buffer_print(&buf->buf, " [%04x] <%s> ", THIS_THREAD_ID, class_names[class]);
}
else
buf->tm_pos = NULL;
buf->msg_pos = buf->buf.pos;
buf->class = class;
@@ -510,7 +512,7 @@ log_switch(int initial, list *logs, const char *new_syslog_name)
}
/* The filehandle is no longer needed */
if (l->rf != &rf_stderr)
if ((l->rf != &rf_stderr ) && (l->rf != dbg_rf))
{
log_lock();
rfree(l->rf);
@@ -606,8 +608,8 @@ log_switch(int initial, list *logs, const char *new_syslog_name)
/* Store new mask after opening new files to minimize missing log message race conditions */
atomic_store_explicit(&ol->mask, ol->new_mask, memory_order_release);
/* Never close syslog channel */
if (ol->new_mask || !ol->rf)
/* Never close syslog channel or debug */
if (ol->new_mask || !ol->rf || (ol->rf == dbg_rf))
{
pprev = &ol->next;
ol = atomic_load_explicit(pprev, memory_order_acquire);

View File

@@ -31,7 +31,7 @@
#include "lib/locking.h"
#include "lib/timer.h"
#include "lib/string.h"
#include "nest/rt.h"
#include "nest/route.h"
#include "nest/protocol.h"
#include "nest/iface.h"
#include "nest/cli.h"
@@ -112,21 +112,21 @@ get_hostname(linpool *lp)
#ifdef PATH_IPROUTE_DIR
static inline void
add_num_const(char *name, int val, const char *file, const uint line)
add_num_const(struct config *conf, char *name, int val, const char *file, const uint line)
{
struct f_val *v = cfg_alloc(sizeof(struct f_val));
*v = (struct f_val) { .type = T_INT, .val.i = val };
struct symbol *sym = cf_get_symbol(name);
if (sym->class && cf_symbol_is_local(sym))
struct symbol *sym = cf_get_symbol(conf, name);
if (sym->class && cf_symbol_is_local(conf, sym))
cf_error("Error reading value for %s from %s:%d: already defined", name, file, line);
cf_define_symbol(sym, SYM_CONSTANT | T_INT, val, v);
cf_define_symbol(conf, sym, SYM_CONSTANT | T_INT, val, v);
}
/* the code of read_iproute_table() is based on
rtnl_tab_initialize() from iproute2 package */
static void
read_iproute_table(char *file, char *prefix, uint max)
read_iproute_table(struct config *conf, char *file, char *prefix, uint max)
{
char buf[512], namebuf[512];
char *name;
@@ -163,7 +163,7 @@ read_iproute_table(char *file, char *prefix, uint max)
if ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z') && (*p < '0' || *p > '9') && (*p != '_'))
*p = '_';
add_num_const(namebuf, val, file, line);
add_num_const(conf, namebuf, val, file, line);
}
fclose(fp);
@@ -192,10 +192,10 @@ sysdep_preconfig(struct config *c)
c->watchdog_warning = UNIX_DEFAULT_WATCHDOG_WARNING;
#ifdef PATH_IPROUTE_DIR
read_iproute_table(PATH_IPROUTE_DIR "/rt_protos", "ipp_", 255);
read_iproute_table(PATH_IPROUTE_DIR "/rt_realms", "ipr_", 0xffffffff);
read_iproute_table(PATH_IPROUTE_DIR "/rt_scopes", "ips_", 255);
read_iproute_table(PATH_IPROUTE_DIR "/rt_tables", "ipt_", 0xffffffff);
read_iproute_table(c, PATH_IPROUTE_DIR "/rt_protos", "ipp_", 255);
read_iproute_table(c, PATH_IPROUTE_DIR "/rt_realms", "ipr_", 0xffffffff);
read_iproute_table(c, PATH_IPROUTE_DIR "/rt_scopes", "ips_", 255);
read_iproute_table(c, PATH_IPROUTE_DIR "/rt_tables", "ipt_", 0xffffffff);
#endif
}