From 2738da66fc354121f24623a9cbb1d2bb153ba677 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Tue, 19 Jan 2021 10:53:26 +0000 Subject: Kill global eigrpd_process and instead pass the proc to merge_config() and config_clear(). Also set log_procname directly and remove the log_procnames array. --- usr.sbin/eigrpd/eigrpd.c | 22 +++++++++++----------- usr.sbin/eigrpd/eigrpd.h | 15 +++++---------- usr.sbin/eigrpd/eigrpe.c | 9 ++++----- usr.sbin/eigrpd/rde.c | 8 ++++---- 4 files changed, 24 insertions(+), 30 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/eigrpd/eigrpd.c b/usr.sbin/eigrpd/eigrpd.c index 26427d134c2..648a4464f21 100644 --- a/usr.sbin/eigrpd/eigrpd.c +++ b/usr.sbin/eigrpd/eigrpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpd.c,v 1.27 2019/03/31 03:36:18 yasuoka Exp $ */ +/* $OpenBSD: eigrpd.c,v 1.28 2021/01/19 10:53:25 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -111,8 +111,7 @@ main(int argc, char *argv[]) int pipe_parent2rde[2]; conffile = CONF_FILE; - eigrpd_process = PROC_MAIN; - log_procname = log_procnames[eigrpd_process]; + log_procname = "parent"; sockname = EIGRPD_SOCKET; log_init(1); /* log to stderr until daemonized */ @@ -292,7 +291,7 @@ eigrpd_shutdown(void) close(iev_rde->ibuf.fd); kr_shutdown(); - config_clear(eigrpd_conf); + config_clear(eigrpd_conf, PROC_MAIN); log_debug("waiting for children to terminate"); do { @@ -617,7 +616,7 @@ eigrp_reload(void) if (main_imsg_send_config(xconf) == -1) return (-1); - merge_config(eigrpd_conf, xconf); + merge_config(eigrpd_conf, xconf, PROC_MAIN); return (0); } @@ -633,7 +632,8 @@ eigrp_sendboth(enum imsg_type type, void *buf, uint16_t len) } void -merge_config(struct eigrpd_conf *conf, struct eigrpd_conf *xconf) +merge_config(struct eigrpd_conf *conf, struct eigrpd_conf *xconf, + enum eigrpd_process proc) { struct iface *iface, *itmp, *xi; struct eigrp *eigrp, *etmp, *xe; @@ -651,7 +651,7 @@ merge_config(struct eigrpd_conf *conf, struct eigrpd_conf *xconf) if ((xe = eigrp_find(xconf, eigrp->af, eigrp->as)) == NULL) { TAILQ_REMOVE(&conf->instances, eigrp, entry); - switch (eigrpd_process) { + switch (proc) { case PROC_RDE_ENGINE: rde_instance_del(eigrp); break; @@ -670,7 +670,7 @@ merge_config(struct eigrpd_conf *conf, struct eigrpd_conf *xconf) TAILQ_REMOVE(&xconf->instances, xe, entry); TAILQ_INSERT_TAIL(&conf->instances, xe, entry); - switch (eigrpd_process) { + switch (proc) { case PROC_RDE_ENGINE: rde_instance_init(xe); break; @@ -707,7 +707,7 @@ merge_config(struct eigrpd_conf *conf, struct eigrpd_conf *xconf) } /* resend addresses to activate new interfaces */ - if (eigrpd_process == PROC_MAIN) + if (proc == PROC_MAIN) kif_redistribute(); free(xconf); @@ -735,13 +735,13 @@ config_new_empty(void) } void -config_clear(struct eigrpd_conf *conf) +config_clear(struct eigrpd_conf *conf, enum eigrpd_process proc) { struct eigrpd_conf *xconf; /* merge current config with an empty config */ xconf = config_new_empty(); - merge_config(conf, xconf); + merge_config(conf, xconf, proc); free(conf); } diff --git a/usr.sbin/eigrpd/eigrpd.h b/usr.sbin/eigrpd/eigrpd.h index 4a7f599173f..41d5fdfbdb6 100644 --- a/usr.sbin/eigrpd/eigrpd.h +++ b/usr.sbin/eigrpd/eigrpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpd.h,v 1.25 2018/08/05 08:10:35 mestre Exp $ */ +/* $OpenBSD: eigrpd.h,v 1.26 2021/01/19 10:53:25 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -61,12 +61,6 @@ #define F_CTL_ACTIVE 0x0400 #define F_CTL_ALLLINKS 0x0800 -static const char * const log_procnames[] = { - "parent", - "eigrpe", - "rde" -}; - struct imsgev { struct imsgbuf ibuf; void (*handler)(int, short, void *); @@ -318,7 +312,7 @@ enum eigrpd_process { PROC_MAIN, PROC_EIGRP_ENGINE, PROC_RDE_ENGINE -} eigrpd_process; +}; struct eigrpd_conf { struct in_addr rtr_id; @@ -502,9 +496,10 @@ void imsg_event_add(struct imsgev *); int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, int, void *, uint16_t); struct eigrp *eigrp_find(struct eigrpd_conf *, int, uint16_t); -void merge_config(struct eigrpd_conf *, struct eigrpd_conf *); +void merge_config(struct eigrpd_conf *, struct eigrpd_conf *, + enum eigrpd_process); struct eigrpd_conf *config_new_empty(void); -void config_clear(struct eigrpd_conf *); +void config_clear(struct eigrpd_conf *, enum eigrpd_process); /* printconf.c */ void print_config(struct eigrpd_conf *); diff --git a/usr.sbin/eigrpd/eigrpe.c b/usr.sbin/eigrpd/eigrpe.c index 2b1eb749a90..59d2a5c1b7d 100644 --- a/usr.sbin/eigrpd/eigrpe.c +++ b/usr.sbin/eigrpd/eigrpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpe.c,v 1.38 2021/01/19 10:37:25 claudio Exp $ */ +/* $OpenBSD: eigrpe.c,v 1.39 2021/01/19 10:53:25 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -124,8 +124,7 @@ eigrpe(int debug, int verbose, char *sockname) fatal("chdir(\"/\")"); setproctitle("eigrp engine"); - eigrpd_process = PROC_EIGRP_ENGINE; - log_procname = log_procnames[eigrpd_process]; + log_procname = "eigrpe"; if (setgroups(1, &pw->pw_gid) || setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || @@ -182,7 +181,7 @@ eigrpe_shutdown(void) msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); - config_clear(econf); + config_clear(econf, PROC_EIGRP_ENGINE); event_del(&ev4); event_del(&ev6); @@ -363,7 +362,7 @@ eigrpe_dispatch_main(int fd, short event, void *bula) "RB_INSERT(ifaces_by_id) failed"); break; case IMSG_RECONF_END: - merge_config(econf, nconf); + merge_config(econf, nconf, PROC_EIGRP_ENGINE); nconf = NULL; break; case IMSG_CTL_KROUTE: diff --git a/usr.sbin/eigrpd/rde.c b/usr.sbin/eigrpd/rde.c index 9a48b40c3e9..0ee64719dd0 100644 --- a/usr.sbin/eigrpd/rde.c +++ b/usr.sbin/eigrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.23 2016/09/02 16:46:29 renato Exp $ */ +/* $OpenBSD: rde.c,v 1.24 2021/01/19 10:53:25 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -90,7 +90,7 @@ rde(int debug, int verbose) fatal("chdir(\"/\")"); setproctitle("route decision engine"); - eigrpd_process = PROC_RDE_ENGINE; + log_procname = "rde"; if (setgroups(1, &pw->pw_gid) || setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || @@ -137,7 +137,7 @@ rde_shutdown(void) msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); - config_clear(rdeconf); + config_clear(rdeconf, PROC_RDE_ENGINE); free(iev_eigrpe); free(iev_main); @@ -429,7 +429,7 @@ rde_dispatch_parent(int fd, short event, void *bula) "RB_INSERT(ifaces_by_id) failed"); break; case IMSG_RECONF_END: - merge_config(rdeconf, nconf); + merge_config(rdeconf, nconf, PROC_RDE_ENGINE); nconf = NULL; break; default: -- cgit v1.2.3