diff --git a/src/bgp/bgp.c b/src/bgp/bgp.c index 124ab2ddf..f4e99ba1d 100644 --- a/src/bgp/bgp.c +++ b/src/bgp/bgp.c @@ -640,6 +640,11 @@ void skinny_bgp_daemon_online() reload_log_bgp_thread = FALSE; } + if (reload_log && !bgp_misc_db->is_thread) { + reload_logs(); + reload_log = FALSE; + } + if (bgp_misc_db->msglog_backend_methods || bgp_misc_db->dump_backend_methods) { gettimeofday(&bgp_misc_db->log_tstamp, NULL); compose_timestamp(bgp_misc_db->log_tstamp_str, SRVBUFLEN, &bgp_misc_db->log_tstamp, TRUE, diff --git a/src/bmp/bmp.c b/src/bmp/bmp.c index 13e300bbe..9eb977d56 100644 --- a/src/bmp/bmp.c +++ b/src/bmp/bmp.c @@ -590,6 +590,11 @@ void skinny_bmp_daemon() reload_log_bmp_thread = FALSE; } + if (reload_log && !bmp_misc_db->is_thread) { + reload_logs(); + reload_log = FALSE; + } + if (bmp_misc_db->msglog_backend_methods || bmp_misc_db->dump_backend_methods) { gettimeofday(&bmp_misc_db->log_tstamp, NULL); compose_timestamp(bmp_misc_db->log_tstamp_str, SRVBUFLEN, &bmp_misc_db->log_tstamp, TRUE, diff --git a/src/imt_plugin.c b/src/imt_plugin.c index 027992842..357f7d67e 100644 --- a/src/imt_plugin.c +++ b/src/imt_plugin.c @@ -361,6 +361,11 @@ void imt_plugin(int pipe_fd, struct configuration *cfgptr, void *ptr) reload_map = FALSE; } + if (reload_log) { + reload_logs(); + reload_log = FALSE; + } + if (poll_fd[0].revents & POLLIN) { #ifdef WITH_ZMQ read_data: diff --git a/src/nfacctd.c b/src/nfacctd.c index b108bff2c..8c7284c99 100644 --- a/src/nfacctd.c +++ b/src/nfacctd.c @@ -1195,6 +1195,11 @@ int main(int argc,char **argv, char **envp) gettimeofday(&reload_map_tstamp, NULL); } + if (reload_log) { + reload_logs(); + reload_log = FALSE; + } + if (print_stats) { time_t now = time(NULL); diff --git a/src/nfprobe_plugin/nfprobe_plugin.c b/src/nfprobe_plugin/nfprobe_plugin.c index 8d53dd20f..f92545524 100644 --- a/src/nfprobe_plugin/nfprobe_plugin.c +++ b/src/nfprobe_plugin/nfprobe_plugin.c @@ -1547,6 +1547,11 @@ void nfprobe_plugin(int pipe_fd, struct configuration *cfgptr, void *ptr) reload_map = FALSE; } + if (reload_log) { + reload_logs(); + reload_log = FALSE; + } + recv_budget = 0; if (poll_bypass) { poll_bypass = FALSE; diff --git a/src/nl.c b/src/nl.c index b52dd2768..efd19b430 100644 --- a/src/nl.c +++ b/src/nl.c @@ -188,6 +188,11 @@ void pcap_cb(u_char *user, const struct pcap_pkthdr *pkthdr, const u_char *buf) gettimeofday(&reload_map_tstamp, NULL); } + if (reload_log) { + reload_logs(); + reload_log = FALSE; + } + if (cb_data->has_tun_prims && pptrs.tun_pptrs) { struct packet_ptrs *tpptrs = (struct packet_ptrs *) pptrs.tun_pptrs; diff --git a/src/plugin_common.c b/src/plugin_common.c index e4a38ec2a..0f5328da0 100644 --- a/src/plugin_common.c +++ b/src/plugin_common.c @@ -672,6 +672,11 @@ void P_cache_handle_flush_event(struct ports_table *pt) load_ports(config.ports_file, pt); reload_map = FALSE; } + + if (reload_log) { + reload_logs(); + reload_log = FALSE; + } } void P_cache_mark_flush(struct chained_cache *queue[], int index, int exiting) diff --git a/src/pmacct-build.h b/src/pmacct-build.h index bc82a1be9..c938060cb 100644 --- a/src/pmacct-build.h +++ b/src/pmacct-build.h @@ -1 +1 @@ -#define PMACCT_BUILD "20191120-00" +#define PMACCT_BUILD "20191122-00" diff --git a/src/pmacct-globals.c b/src/pmacct-globals.c index 7dcd2bada..90a922297 100644 --- a/src/pmacct-globals.c +++ b/src/pmacct-globals.c @@ -26,7 +26,7 @@ struct utpl_field *(*get_ext_db_ie_by_type)(struct template_cache_entry *, u_int char sll_mac[2][ETH_ADDR_LEN]; struct host_addr mcast_groups[MAX_MCAST_GROUPS]; int reload_map, reload_map_exec_plugins, reload_geoipv2_file; -int reload_map_bgp_thread, reload_log_bgp_thread; +int reload_map_bgp_thread, reload_log, reload_log_bgp_thread; int reload_map_bmp_thread, reload_log_bmp_thread; int reload_map_rpki_thread, reload_log_rpki_thread; int reload_map_telemetry_thread, reload_log_telemetry_thread; diff --git a/src/pmacct.h b/src/pmacct.h index 81019a0f5..a9bd7b5a1 100644 --- a/src/pmacct.h +++ b/src/pmacct.h @@ -425,7 +425,7 @@ initsetproctitle(int, char**, char**); extern char sll_mac[2][ETH_ADDR_LEN]; extern struct host_addr mcast_groups[MAX_MCAST_GROUPS]; extern int reload_map, reload_map_exec_plugins, reload_geoipv2_file; -extern int reload_map_bgp_thread, reload_log_bgp_thread; +extern int reload_map_bgp_thread, reload_log, reload_log_bgp_thread; extern int reload_map_bmp_thread, reload_log_bmp_thread; extern int reload_map_rpki_thread, reload_log_rpki_thread; extern int reload_map_telemetry_thread, reload_log_telemetry_thread; diff --git a/src/sfacctd.c b/src/sfacctd.c index d889ed6f8..ca94d6d04 100644 --- a/src/sfacctd.c +++ b/src/sfacctd.c @@ -1256,6 +1256,11 @@ int main(int argc,char **argv, char **envp) gettimeofday(&reload_map_tstamp, NULL); } + if (reload_log) { + reload_logs(); + reload_log = FALSE; + } + if (reload_log_sf_cnt) { int nodes_idx; diff --git a/src/sfprobe_plugin/sfprobe_plugin.c b/src/sfprobe_plugin/sfprobe_plugin.c index d97c38641..b1b4c9fe9 100644 --- a/src/sfprobe_plugin/sfprobe_plugin.c +++ b/src/sfprobe_plugin/sfprobe_plugin.c @@ -730,6 +730,11 @@ void sfprobe_plugin(int pipe_fd, struct configuration *cfgptr, void *ptr) reload_map = FALSE; } + if (reload_log) { + reload_logs(); + reload_log = FALSE; + } + recv_budget = 0; if (poll_bypass) { poll_bypass = FALSE; diff --git a/src/signals.c b/src/signals.c index c43bd12fe..c8e09d37b 100644 --- a/src/signals.c +++ b/src/signals.c @@ -175,29 +175,11 @@ void PM_sigint_handler(int signum) void reload() { - int logf; - - if (config.syslog) { - closelog(); - logf = parse_log_facility(config.syslog); - if (logf == ERR) { - config.syslog = NULL; - Log(LOG_WARNING, "WARN ( %s/%s ): specified syslog facility is not supported; logging to console.\n", config.name, config.type); - } - openlog(NULL, LOG_PID, logf); - Log(LOG_INFO, "INFO ( %s/%s ): Start logging ...\n", config.name, config.type); - } - - if (config.logfile) { - fclose(config.logfile_fd); - config.logfile_fd = open_output_file(config.logfile, "a", FALSE); - } - + reload_log = TRUE; if (config.nfacctd_bgp_msglog_file) reload_log_bgp_thread = TRUE; if (config.nfacctd_bmp_msglog_file) reload_log_bmp_thread = TRUE; if (config.sfacctd_counter_file) reload_log_sf_cnt = TRUE; if (config.telemetry_msglog_file) reload_log_telemetry_thread = TRUE; - } void push_stats() diff --git a/src/sql_common.c b/src/sql_common.c index be2ce0ef4..f9e56f7e2 100644 --- a/src/sql_common.c +++ b/src/sql_common.c @@ -501,6 +501,11 @@ void sql_cache_handle_flush_event(struct insert_data *idata, time_t *refresh_dea load_ports(config.ports_file, pt); reload_map = FALSE; } + + if (reload_log) { + reload_logs(); + reload_log = FALSE; + } } struct db_cache *sql_cache_search(struct primitives_ptrs *prim_ptrs, time_t basetime) diff --git a/src/tee_plugin/tee_plugin.c b/src/tee_plugin/tee_plugin.c index 51d73906d..0be73a9f1 100644 --- a/src/tee_plugin/tee_plugin.c +++ b/src/tee_plugin/tee_plugin.c @@ -164,6 +164,11 @@ void tee_plugin(int pipe_fd, struct configuration *cfgptr, void *ptr) reload_map = FALSE; } + if (reload_log) { + reload_logs(); + reload_log = FALSE; + } + recv_budget = 0; if (poll_bypass) { poll_bypass = FALSE; diff --git a/src/telemetry/telemetry.c b/src/telemetry/telemetry.c index 96d98deed..1452a73bd 100644 --- a/src/telemetry/telemetry.c +++ b/src/telemetry/telemetry.c @@ -548,6 +548,11 @@ void telemetry_daemon(void *t_data_void) reload_log_telemetry_thread = FALSE; } + if (reload_log && !telemetry_misc_db->is_thread) { + reload_logs(); + reload_log = FALSE; + } + if (telemetry_misc_db->msglog_backend_methods || telemetry_misc_db->dump_backend_methods) { gettimeofday(&telemetry_misc_db->log_tstamp, NULL); compose_timestamp(telemetry_misc_db->log_tstamp_str, SRVBUFLEN, &telemetry_misc_db->log_tstamp, TRUE, diff --git a/src/util.c b/src/util.c index 2b9bc5da6..977d09250 100644 --- a/src/util.c +++ b/src/util.c @@ -3143,3 +3143,24 @@ char *null_terminate(char *str, int len) return loc; } + +void reload_logs() +{ + int logf; + + if (config.syslog) { + closelog(); + logf = parse_log_facility(config.syslog); + if (logf == ERR) { + config.syslog = NULL; + Log(LOG_WARNING, "WARN ( %s/%s ): specified syslog facility is not supported; logging to console.\n", config.name, config.type); + } + openlog(NULL, LOG_PID, logf); + Log(LOG_INFO, "INFO ( %s/%s ): Start logging ...\n", config.name, config.type); + } + + if (config.logfile) { + fclose(config.logfile_fd); + config.logfile_fd = open_output_file(config.logfile, "a", FALSE); + } +} diff --git a/src/util.h b/src/util.h index 38781067c..ad35a8160 100644 --- a/src/util.h +++ b/src/util.h @@ -108,6 +108,7 @@ extern void parse_hostport(const char *, struct sockaddr *, socklen_t *); extern bool is_prime(u_int32_t); extern u_int32_t next_prime(u_int32_t); extern char *null_terminate(char *, int); +extern void reload_logs(); extern char *compose_json_str(void *); extern void write_and_free_json(FILE *, void *);