From: Maria Matejka Date: Thu, 28 Nov 2024 09:57:37 +0000 (+0100) Subject: Merge commit 'a95fff37' into thread-merge-2.16 X-Git-Tag: v3.0.0~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ce352ebf5a7a6fe5db4af381b16418fd6d346c9;p=thirdparty%2Fbird.git Merge commit 'a95fff37' into thread-merge-2.16 --- 1ce352ebf5a7a6fe5db4af381b16418fd6d346c9 diff --cc conf/conf.h index 9a06ad4df,dd2966520..03ef4ef82 --- a/conf/conf.h +++ b/conf/conf.h @@@ -13,8 -13,8 +13,9 @@@ #include "lib/ip.h" #include "lib/hash.h" #include "lib/resource.h" +#include "lib/obstacle.h" #include "lib/timer.h" + #include "lib/tlists.h" /* Configuration structure */ struct config { @@@ -26,10 -26,11 +27,11 @@@ list logfiles; /* Configured log files (sysdep) */ list tests; /* Configured unit tests (f_bt_test_suite) */ list symbols; /* Configured symbols in config order */ + TLIST_STRUCT_DEF(cli_config, struct cli_config) cli; /* Configured CLI sockets */ - int mrtdump_file; /* Configured MRTDump file (sysdep, fd in unix) */ + struct rfile *mrtdump_file; /* Configured MRTDump file */ const char *syslog_name; /* Name used for syslog (NULL -> no syslog) */ - struct rtable_config *def_tables[NET_MAX]; /* Default routing tables for each network */ + struct symbol *def_tables[NET_MAX]; /* Default routing tables for each network */ struct iface_patt *router_id_from; /* Configured list of router ID iface patterns */ u32 router_id; /* Our Router ID */ diff --cc nest/cli.h index bcc64dc05,a9848a89d..37943a1b9 --- a/nest/cli.h +++ b/nest/cli.h @@@ -10,8 -10,9 +10,10 @@@ #define _BIRD_CLI_H_ #include "lib/resource.h" +#include "lib/lists.h" #include "lib/event.h" + #include "lib/tlists.h" + #include "conf/conf.h" #define CLI_RX_BUF_SIZE 4096 #define CLI_TX_BUF_SIZE 4096 diff --cc sysdep/unix/config.Y index 46365c850,24d1ae5d2..6df86c2f6 --- a/sysdep/unix/config.Y +++ b/sysdep/unix/config.Y @@@ -17,12 -17,11 +17,12 @@@ static struct log_config *this_log CF_DECLS - CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT, UDP, PORT) -CF_KEYWORDS(LOG, SYSLOG, NAME, STDERR, UDP, PORT, CLI) -CF_KEYWORDS(ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG) -CF_KEYWORDS(DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, TIMEOUT, THREADS) ++CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT, UDP, PORT, CLI) +CF_KEYWORDS(NAME, CONFIRM, UNDO, CHECK, TIMEOUT, DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, STATUS) +CF_KEYWORDS(PING, WAKEUP, SOCKETS, SCHEDULING, EVENTS, TIMERS, ALLOCATOR) +CF_KEYWORDS(GRACEFUL, RESTART, FIXED) -%type log_mask log_mask_list log_cat cfg_timeout +%type log_mask log_mask_list log_cat cfg_timeout debug_unix latency_debug_mask latency_debug_flag latency_debug_list %type cfg_name %type timeformat_which %type syslog_name @@@ -122,13 -123,6 +122,12 @@@ mrtdump_base } ; - +conf: THREADS expr { + if ($2 < 1) cf_error("Number of threads must be at least one."); + new_config->thread_count = $2; +} + + conf: debug_unix ; debug_unix: diff --cc sysdep/unix/io.c index 7f7676e9d,5a0dde8e3..9d120258e --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@@ -1684,7 -1531,7 +1684,7 @@@ err } int - sk_open_unix(sock *s, struct birdloop *loop, char *name) -sk_open_unix(sock *s, const char *name) ++sk_open_unix(sock *s, struct birdloop *loop, const char *name) { struct sockaddr_un sa; int fd; diff --cc sysdep/unix/main.c index 254690b1b,c712aee48..38b96fe5b --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@@ -545,19 -536,51 +548,51 @@@ cli_listener(struct cli_config *cf s->fast_rx = 1; /* Return value intentionally ignored */ - unlink(path_control_socket); + unlink(cf->name); - if (sk_open_unix(s, &main_birdloop, path_control_socket) < 0) - die("Cannot create control socket %s: %m", path_control_socket); - if (sk_open_unix(s, cf->name) < 0) ++ if (sk_open_unix(s, &main_birdloop, cf->name) < 0) + { + log(L_ERR "Cannot create control socket %s: %m", cf->name); + return NULL; + } - if (use_uid || use_gid) - if (chown(path_control_socket, use_uid, use_gid) < 0) - die("chown: %m"); + if (cf->uid || cf->gid) + if (chown(cf->name, cf->uid, cf->gid) < 0) + { + log(L_ERR "Cannot chown control socket %s: %m", cf->name); + return NULL; + } - if (chmod(path_control_socket, 0660) < 0) - die("chmod: %m"); + if (chmod(cf->name, cf->mode) < 0) + { + log(L_ERR "Cannot chmod control socket %s: %m", cf->name); + return NULL; + } + + return l; + } + + static void + cli_init_unix(uid_t use_uid, gid_t use_gid) + { + ASSERT_DIE(main_control_socket_config == NULL); + + main_control_socket_config = mb_alloc(&root_pool, sizeof *main_control_socket_config); + *main_control_socket_config = (struct cli_config) { + .name = path_control_socket, + .uid = use_uid, + .gid = use_gid, + .mode = 0660, + }; + + ASSERT_DIE(main_control_socket == NULL); + cli_init(); + main_control_socket = cli_listener(main_control_socket_config); + if (!main_control_socket) + die("Won't run without control socket"); } + /* * PID file */ diff --cc sysdep/unix/unix.h index e7c4c1436,7c15e30d4..e9b8758d7 --- a/sysdep/unix/unix.h +++ b/sysdep/unix/unix.h @@@ -114,22 -107,11 +114,22 @@@ extern volatile sig_atomic_t async_shut void io_init(void); void io_loop(void); void io_log_dump(void); - int sk_open_unix(struct birdsock *s, struct birdloop *, char *name); -int sk_open_unix(struct birdsock *s, const char *name); -struct rfile *rf_open(struct pool *, const char *name, const char *mode); -struct rfile *rf_fdopen(pool *p, int fd, const char *mode); -void *rf_file(struct rfile *f); ++int sk_open_unix(struct birdsock *s, struct birdloop *, const char *name); + +enum rf_mode { + RF_APPEND = 1, + RF_FIXED, +}; + +struct rfile *rf_open(struct pool *, const char *name, enum rf_mode mode, off_t limit); +off_t rf_size(struct rfile *); +int rf_same(struct rfile *, struct rfile *); +int rf_writev(struct rfile *, struct iovec *, int); +void rf_write_crude(struct rfile *, const char *, int); int rf_fileno(struct rfile *f); + +extern struct rfile rf_stderr; + void test_old_bird(char *path); ip_addr resolve_hostname(const char *host, int type, const char **err_msg);