diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:56:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:56:24 +0000 |
commit | 54de8bbe36d7d968c6367939277942518bd4e11f (patch) | |
tree | 924f8c16d9c8831679f355b88c620b9b356c9d5a /ldpd/ldpd.c | |
parent | Adding debian version 10.0.1-0.1. (diff) | |
download | frr-54de8bbe36d7d968c6367939277942518bd4e11f.tar.xz frr-54de8bbe36d7d968c6367939277942518bd4e11f.zip |
Merging upstream version 10.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ldpd/ldpd.c')
-rw-r--r-- | ldpd/ldpd.c | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index da29a4f..4d38fdc 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -35,9 +35,11 @@ #include "qobj.h" #include "libfrr.h" #include "lib_errors.h" +#include "zlog_recirculate.h" +#include "libagentx.h" static void ldpd_shutdown(void); -static pid_t start_child(enum ldpd_process, char *, int, int); +static pid_t start_child(enum ldpd_process, char *, int, int, int); static void main_dispatch_ldpe(struct event *thread); static void main_dispatch_lde(struct event *thread); static int main_imsg_send_ipc_sockets(struct imsgbuf *, @@ -69,6 +71,8 @@ DEFINE_QOBJ_TYPE(l2vpn_pw); DEFINE_QOBJ_TYPE(l2vpn); DEFINE_QOBJ_TYPE(ldpd_conf); +const char *log_procname; + struct ldpd_global global; struct ldpd_init init; struct ldpd_conf *ldpd_conf, *vty_conf; @@ -231,8 +235,12 @@ main(int argc, char *argv[]) { char *saved_argv0; int lflag = 0, eflag = 0; - int pipe_parent2ldpe[2], pipe_parent2ldpe_sync[2]; - int pipe_parent2lde[2], pipe_parent2lde_sync[2]; + int pipe_parent2ldpe[2]; + int pipe_parent2ldpe_sync[2]; + int pipe_ldpe_log[2]; + int pipe_parent2lde[2]; + int pipe_parent2lde_sync[2]; + int pipe_lde_log[2]; bool ctl_sock_used = false; ldpd_process = PROC_MAIN; @@ -300,15 +308,6 @@ main(int argc, char *argv[]) exit(1); } - if (lflag || eflag) { - struct zprivs_ids_t ids; - - zprivs_preinit(&ldpd_privs); - zprivs_get_ids(&ids); - - zlog_init(ldpd_di.progname, "LDP", 0, - ids.uid_normal, ids.gid_normal); - } if (lflag) lde(); else if (eflag) @@ -321,6 +320,9 @@ main(int argc, char *argv[]) pipe_parent2ldpe_sync) == -1) fatal("socketpair"); + if (socketpair(AF_UNIX, SOCK_DGRAM, PF_UNSPEC, pipe_ldpe_log) == -1) + fatal("socketpair"); + if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_parent2lde) == -1) fatal("socketpair"); @@ -328,6 +330,9 @@ main(int argc, char *argv[]) pipe_parent2lde_sync) == -1) fatal("socketpair"); + if (socketpair(AF_UNIX, SOCK_DGRAM, PF_UNSPEC, pipe_lde_log) == -1) + fatal("socketpair"); + sock_set_nonblock(pipe_parent2ldpe[0]); sock_set_cloexec(pipe_parent2ldpe[0]); sock_set_nonblock(pipe_parent2ldpe[1]); @@ -335,6 +340,11 @@ main(int argc, char *argv[]) sock_set_nonblock(pipe_parent2ldpe_sync[0]); sock_set_cloexec(pipe_parent2ldpe_sync[0]); sock_set_cloexec(pipe_parent2ldpe_sync[1]); + sock_set_nonblock(pipe_ldpe_log[0]); + sock_set_cloexec(pipe_ldpe_log[0]); + sock_set_nonblock(pipe_ldpe_log[1]); + sock_set_cloexec(pipe_ldpe_log[1]); + sock_set_nonblock(pipe_parent2lde[0]); sock_set_cloexec(pipe_parent2lde[0]); sock_set_nonblock(pipe_parent2lde[1]); @@ -342,15 +352,26 @@ main(int argc, char *argv[]) sock_set_nonblock(pipe_parent2lde_sync[0]); sock_set_cloexec(pipe_parent2lde_sync[0]); sock_set_cloexec(pipe_parent2lde_sync[1]); + sock_set_nonblock(pipe_lde_log[0]); + sock_set_cloexec(pipe_lde_log[0]); + sock_set_nonblock(pipe_lde_log[1]); + sock_set_cloexec(pipe_lde_log[1]); /* start children */ lde_pid = start_child(PROC_LDE_ENGINE, saved_argv0, - pipe_parent2lde[1], pipe_parent2lde_sync[1]); + pipe_parent2lde[1], pipe_parent2lde_sync[1], pipe_lde_log[1]); ldpe_pid = start_child(PROC_LDP_ENGINE, saved_argv0, - pipe_parent2ldpe[1], pipe_parent2ldpe_sync[1]); + pipe_parent2ldpe[1], pipe_parent2ldpe_sync[1], pipe_ldpe_log[1]); master = frr_init(); + /* The two child processes use the zlog_live backend to send their + * messages here, where the actual logging config is then applied. + * Look for zlog_live_open_fd() to find the other end of this. + */ + zlog_recirculate_subscribe(master, pipe_lde_log[0]); + zlog_recirculate_subscribe(master, pipe_ldpe_log[0]); + libagentx_init(); vrf_init(NULL, NULL, NULL, NULL); access_list_init(); ldp_vty_init(); @@ -484,7 +505,8 @@ ldpd_shutdown(void) } static pid_t -start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync) +start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync, + int fd_log) { char *argv[7]; int argc = 0, nullfd; @@ -499,6 +521,7 @@ start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync) default: close(fd_async); close(fd_sync); + close(fd_log); return (pid); } @@ -520,6 +543,9 @@ start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync) if (dup2(fd_sync, LDPD_FD_SYNC) == -1) fatal("cannot setup imsg sync fd"); + if (dup2(fd_log, LDPD_FD_LOG) == -1) + fatal("cannot setup zlog fd"); + argv[argc++] = argv0; switch (p) { case PROC_MAIN: @@ -569,9 +595,6 @@ static void main_dispatch_ldpe(struct event *thread) break; switch (imsg.hdr.type) { - case IMSG_LOG: - logit(imsg.hdr.pid, "%s", (const char *)imsg.data); - break; case IMSG_REQUEST_SOCKETS: af = imsg.hdr.pid; main_imsg_send_net_sockets(af); @@ -637,9 +660,6 @@ static void main_dispatch_lde(struct event *thread) break; switch (imsg.hdr.type) { - case IMSG_LOG: - logit(imsg.hdr.pid, "%s", (const char *)imsg.data); - break; case IMSG_KLABEL_CHANGE: if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(struct kroute)) |