diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-12-13 17:08:11 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-12-13 17:08:11 +0000 |
commit | 5ac712832fc9d0ee58e5ca5dac1d4c4724e741dc (patch) | |
tree | 91e23cb9524a52c119134382110d5a5bb8ce992a | |
parent | 3d14d8797244b0e6b72353394f548114c2bfbe7d (diff) |
in event reports, use a struct timeval instead of time_t since we want more
than second precision
discussed with eric@
-rw-r--r-- | usr.sbin/smtpd/lka.c | 60 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka_report.c | 64 | ||||
-rw-r--r-- | usr.sbin/smtpd/mproc.c | 15 | ||||
-rw-r--r-- | usr.sbin/smtpd/report_smtp.c | 86 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 32 |
5 files changed, 164 insertions, 93 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 71e968aa359..2fc7a6034f8 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.226 2018/12/12 21:27:49 gilles Exp $ */ +/* $OpenBSD: lka.c,v 1.227 2018/12/13 17:08:10 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -82,7 +82,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg) const char *tablename, *username, *password, *label, *procname; uint64_t reqid; int v; - time_t tm; + struct timeval tv; const char *direction; const char *rdns; const char *command, *response; @@ -424,7 +424,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg) case IMSG_REPORT_SMTP_LINK_CONNECT: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_string(&m, &rdns); m_get_int(&m, &fcrdns); @@ -432,158 +432,158 @@ lka_imsg(struct mproc *p, struct imsg *imsg) m_get_sockaddr(&m, (struct sockaddr *)&ss_dest); m_end(&m); - lka_report_smtp_link_connect(direction, tm, reqid, rdns, fcrdns, &ss_src, &ss_dest); + lka_report_smtp_link_connect(direction, &tv, reqid, rdns, fcrdns, &ss_src, &ss_dest); return; case IMSG_REPORT_SMTP_LINK_DISCONNECT: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_end(&m); - lka_report_smtp_link_disconnect(direction, tm, reqid); + lka_report_smtp_link_disconnect(direction, &tv, reqid); return; case IMSG_REPORT_SMTP_LINK_IDENTIFY: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_string(&m, &heloname); m_end(&m); - lka_report_smtp_link_identify(direction, tm, reqid, heloname); + lka_report_smtp_link_identify(direction, &tv, reqid, heloname); return; case IMSG_REPORT_SMTP_LINK_TLS: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_string(&m, &ciphers); m_end(&m); - lka_report_smtp_link_tls(direction, tm, reqid, ciphers); + lka_report_smtp_link_tls(direction, &tv, reqid, ciphers); return; case IMSG_REPORT_SMTP_TX_BEGIN: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_u32(&m, &msgid); m_end(&m); - lka_report_smtp_tx_begin(direction, tm, reqid, msgid); + lka_report_smtp_tx_begin(direction, &tv, reqid, msgid); return; case IMSG_REPORT_SMTP_TX_MAIL: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_u32(&m, &msgid); m_get_string(&m, &address); m_get_int(&m, &ok); m_end(&m); - lka_report_smtp_tx_mail(direction, tm, reqid, msgid, address, ok); + lka_report_smtp_tx_mail(direction, &tv, reqid, msgid, address, ok); return; case IMSG_REPORT_SMTP_TX_RCPT: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_u32(&m, &msgid); m_get_string(&m, &address); m_get_int(&m, &ok); m_end(&m); - lka_report_smtp_tx_rcpt(direction, tm, reqid, msgid, address, ok); + lka_report_smtp_tx_rcpt(direction, &tv, reqid, msgid, address, ok); return; case IMSG_REPORT_SMTP_TX_ENVELOPE: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_u32(&m, &msgid); m_get_id(&m, &evpid); m_end(&m); - lka_report_smtp_tx_envelope(direction, tm, reqid, msgid, evpid); + lka_report_smtp_tx_envelope(direction, &tv, reqid, msgid, evpid); return; case IMSG_REPORT_SMTP_TX_DATA: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_u32(&m, &msgid); m_get_int(&m, &ok); m_end(&m); - lka_report_smtp_tx_data(direction, tm, reqid, msgid, ok); + lka_report_smtp_tx_data(direction, &tv, reqid, msgid, ok); return; case IMSG_REPORT_SMTP_TX_COMMIT: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_u32(&m, &msgid); m_get_size(&m, &msgsz); m_end(&m); - lka_report_smtp_tx_commit(direction, tm, reqid, msgid, msgsz); + lka_report_smtp_tx_commit(direction, &tv, reqid, msgid, msgsz); return; case IMSG_REPORT_SMTP_TX_ROLLBACK: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_u32(&m, &msgid); m_end(&m); - lka_report_smtp_tx_rollback(direction, tm, reqid, msgid); + lka_report_smtp_tx_rollback(direction, &tv, reqid, msgid); return; case IMSG_REPORT_SMTP_PROTOCOL_CLIENT: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_string(&m, &command); m_end(&m); - lka_report_smtp_protocol_client(direction, tm, reqid, command); + lka_report_smtp_protocol_client(direction, &tv, reqid, command); return; case IMSG_REPORT_SMTP_PROTOCOL_SERVER: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_string(&m, &response); m_end(&m); - lka_report_smtp_protocol_server(direction, tm, reqid, response); + lka_report_smtp_protocol_server(direction, &tv, reqid, response); return; case IMSG_REPORT_SMTP_FILTER_RESPONSE: m_msg(&m, imsg); m_get_string(&m, &direction); - m_get_time(&m, &tm); + m_get_timeval(&m, &tv); m_get_id(&m, &reqid); m_get_int(&m, &filter_phase); m_get_int(&m, &filter_response); m_get_string(&m, &filter_param); m_end(&m); - lka_report_smtp_filter_response(direction, tm, reqid, + lka_report_smtp_filter_response(direction, &tv, reqid, filter_phase, filter_response, filter_param); return; diff --git a/usr.sbin/smtpd/lka_report.c b/usr.sbin/smtpd/lka_report.c index c368fbc6c38..30648aa1c50 100644 --- a/usr.sbin/smtpd/lka_report.c +++ b/usr.sbin/smtpd/lka_report.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka_report.c,v 1.14 2018/12/12 21:27:49 gilles Exp $ */ +/* $OpenBSD: lka_report.c,v 1.15 2018/12/13 17:08:10 gilles Exp $ */ /* * Copyright (c) 2018 Gilles Chehade <gilles@poolp.org> @@ -38,7 +38,7 @@ #define PROTOCOL_VERSION 1 static void -report_smtp_broadcast(const char *direction, time_t tm, const char *format, ...) +report_smtp_broadcast(const char *direction, struct timeval *tv, const char *format, ...) { va_list ap; void *hdl = NULL; @@ -52,8 +52,8 @@ report_smtp_broadcast(const char *direction, time_t tm, const char *format, ...) va_start(ap, format); while (dict_iter(d, &hdl, &reporter, NULL)) { - if (io_printf(lka_proc_get_io(reporter), "report|%d|%zd|%s|", - PROTOCOL_VERSION, tm, direction) == -1 || + if (io_printf(lka_proc_get_io(reporter), "report|%d|%lld.%06ld|%s|", + PROTOCOL_VERSION, tv->tv_sec, tv->tv_usec, direction) == -1 || io_vprintf(lka_proc_get_io(reporter), format, ap) == -1) fatalx("failed to write to processor"); } @@ -61,7 +61,7 @@ report_smtp_broadcast(const char *direction, time_t tm, const char *format, ...) } void -lka_report_smtp_link_connect(const char *direction, time_t tm, uint64_t reqid, const char *rdns, +lka_report_smtp_link_connect(const char *direction, struct timeval *tv, uint64_t reqid, const char *rdns, int fcrdns, const struct sockaddr_storage *ss_src, const struct sockaddr_storage *ss_dest) @@ -97,41 +97,41 @@ lka_report_smtp_link_connect(const char *direction, time_t tm, uint64_t reqid, c break; } - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "link-connect|%016"PRIx64"|%s|%s|%s:%d|%s:%d\n", reqid, rdns, fcrdns_str, src, src_port, dest, dest_port); } void -lka_report_smtp_link_disconnect(const char *direction, time_t tm, uint64_t reqid) +lka_report_smtp_link_disconnect(const char *direction, struct timeval *tv, uint64_t reqid) { - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "link-disconnect|%016"PRIx64"\n", reqid); } void -lka_report_smtp_link_identify(const char *direction, time_t tm, uint64_t reqid, const char *heloname) +lka_report_smtp_link_identify(const char *direction, struct timeval *tv, uint64_t reqid, const char *heloname) { - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "link-identify|%016"PRIx64"|%s\n", reqid, heloname); } void -lka_report_smtp_link_tls(const char *direction, time_t tm, uint64_t reqid, const char *ciphers) +lka_report_smtp_link_tls(const char *direction, struct timeval *tv, uint64_t reqid, const char *ciphers) { - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "link-tls|%016"PRIx64"|%s\n", reqid, ciphers); } void -lka_report_smtp_tx_begin(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid) +lka_report_smtp_tx_begin(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid) { - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "tx-begin|%016"PRIx64"|%08x\n", reqid, msgid); } void -lka_report_smtp_tx_mail(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid, const char *address, int ok) +lka_report_smtp_tx_mail(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid, const char *address, int ok) { const char *result; @@ -146,12 +146,12 @@ lka_report_smtp_tx_mail(const char *direction, time_t tm, uint64_t reqid, uint32 result = "tempfail"; break; } - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "tx-mail|%016"PRIx64"|%08x|%s|%s\n", reqid, msgid, address, result); } void -lka_report_smtp_tx_rcpt(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid, const char *address, int ok) +lka_report_smtp_tx_rcpt(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid, const char *address, int ok) { const char *result; @@ -166,20 +166,20 @@ lka_report_smtp_tx_rcpt(const char *direction, time_t tm, uint64_t reqid, uint32 result = "tempfail"; break; } - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "tx-rcpt|%016"PRIx64"|%08x|%s|%s\n", reqid, msgid, address, result); } void -lka_report_smtp_tx_envelope(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid, uint64_t evpid) +lka_report_smtp_tx_envelope(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid, uint64_t evpid) { - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "tx-envelope|%016"PRIx64"|%08x|%016"PRIx64"\n", reqid, msgid, evpid); } void -lka_report_smtp_tx_data(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid, int ok) +lka_report_smtp_tx_data(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid, int ok) { const char *result; @@ -194,44 +194,44 @@ lka_report_smtp_tx_data(const char *direction, time_t tm, uint64_t reqid, uint32 result = "tempfail"; break; } - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "tx-data|%016"PRIx64"|%08x|%s\n", reqid, msgid, result); } void -lka_report_smtp_tx_commit(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid, size_t msgsz) +lka_report_smtp_tx_commit(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid, size_t msgsz) { - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "tx-commit|%016"PRIx64"|%08x|%zd\n", reqid, msgid, msgsz); } void -lka_report_smtp_tx_rollback(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid) +lka_report_smtp_tx_rollback(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid) { - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "tx-rollback|%016"PRIx64"|%08x\n", reqid, msgid); } void -lka_report_smtp_protocol_client(const char *direction, time_t tm, uint64_t reqid, const char *command) +lka_report_smtp_protocol_client(const char *direction, struct timeval *tv, uint64_t reqid, const char *command) { - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "protocol-client|%016"PRIx64"|%s\n", reqid, command); } void -lka_report_smtp_protocol_server(const char *direction, time_t tm, uint64_t reqid, const char *response) +lka_report_smtp_protocol_server(const char *direction, struct timeval *tv, uint64_t reqid, const char *response) { - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "protocol-server|%016"PRIx64"|%s\n", reqid, response); } void -lka_report_smtp_filter_response(const char *direction, time_t tm, uint64_t reqid, +lka_report_smtp_filter_response(const char *direction, struct timeval *tv, uint64_t reqid, int phase, int response, const char *param) { const char *phase_name; @@ -304,7 +304,7 @@ lka_report_smtp_filter_response(const char *direction, time_t tm, uint64_t reqid response_name = ""; } - report_smtp_broadcast(direction, tm, + report_smtp_broadcast(direction, tv, "filter-response|%016"PRIx64"|%s|%s|%s\n", reqid, phase_name, response_name, param ? param : ""); } diff --git a/usr.sbin/smtpd/mproc.c b/usr.sbin/smtpd/mproc.c index 97da799b09f..f1175f74b06 100644 --- a/usr.sbin/smtpd/mproc.c +++ b/usr.sbin/smtpd/mproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mproc.c,v 1.30 2018/11/11 14:00:51 eric Exp $ */ +/* $OpenBSD: mproc.c,v 1.31 2018/12/13 17:08:10 gilles Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@faurot.net> @@ -439,6 +439,13 @@ m_add_time(struct mproc *m, time_t v) }; void +m_add_timeval(struct mproc *m, struct timeval *tv) +{ + m_add(m, tv, sizeof(*tv)); +} + + +void m_add_string(struct mproc *m, const char *v) { if (v) { @@ -541,6 +548,12 @@ m_get_time(struct msg *m, time_t *t) } void +m_get_timeval(struct msg *m, struct timeval *tv) +{ + m_get(m, tv, sizeof(*tv)); +} + +void m_get_string(struct msg *m, const char **s) { uint8_t *end; diff --git a/usr.sbin/smtpd/report_smtp.c b/usr.sbin/smtpd/report_smtp.c index e2cac45f633..d2d8b27d6c9 100644 --- a/usr.sbin/smtpd/report_smtp.c +++ b/usr.sbin/smtpd/report_smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: report_smtp.c,v 1.2 2018/12/12 21:27:49 gilles Exp $ */ +/* $OpenBSD: report_smtp.c,v 1.3 2018/12/13 17:08:10 gilles Exp $ */ /* * Copyright (c) 2018 Gilles Chehade <gilles@poolp.org> @@ -48,9 +48,13 @@ report_smtp_link_connect(const char *direction, uint64_t qid, const char *rdns, const struct sockaddr_storage *ss_src, const struct sockaddr_storage *ss_dest) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_LINK_CONNECT, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_string(p_lka, rdns); m_add_int(p_lka, fcrdns); @@ -62,9 +66,13 @@ report_smtp_link_connect(const char *direction, uint64_t qid, const char *rdns, void report_smtp_link_identify(const char *direction, uint64_t qid, const char *identity) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_LINK_IDENTIFY, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_string(p_lka, identity); m_close(p_lka); @@ -73,9 +81,13 @@ report_smtp_link_identify(const char *direction, uint64_t qid, const char *ident void report_smtp_link_tls(const char *direction, uint64_t qid, const char *ssl) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_LINK_TLS, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_string(p_lka, ssl); m_close(p_lka); @@ -84,9 +96,13 @@ report_smtp_link_tls(const char *direction, uint64_t qid, const char *ssl) void report_smtp_link_disconnect(const char *direction, uint64_t qid) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_LINK_DISCONNECT, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_close(p_lka); } @@ -94,9 +110,13 @@ report_smtp_link_disconnect(const char *direction, uint64_t qid) void report_smtp_tx_begin(const char *direction, uint64_t qid, uint32_t msgid) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_TX_BEGIN, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_u32(p_lka, msgid); m_close(p_lka); @@ -105,9 +125,13 @@ report_smtp_tx_begin(const char *direction, uint64_t qid, uint32_t msgid) void report_smtp_tx_mail(const char *direction, uint64_t qid, uint32_t msgid, const char *address, int ok) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_TX_MAIL, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_u32(p_lka, msgid); m_add_string(p_lka, address); @@ -118,9 +142,13 @@ report_smtp_tx_mail(const char *direction, uint64_t qid, uint32_t msgid, const c void report_smtp_tx_rcpt(const char *direction, uint64_t qid, uint32_t msgid, const char *address, int ok) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_TX_RCPT, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_u32(p_lka, msgid); m_add_string(p_lka, address); @@ -131,9 +159,13 @@ report_smtp_tx_rcpt(const char *direction, uint64_t qid, uint32_t msgid, const c void report_smtp_tx_envelope(const char *direction, uint64_t qid, uint32_t msgid, uint64_t evpid) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_TX_ENVELOPE, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_u32(p_lka, msgid); m_add_id(p_lka, evpid); @@ -143,9 +175,13 @@ report_smtp_tx_envelope(const char *direction, uint64_t qid, uint32_t msgid, uin void report_smtp_tx_data(const char *direction, uint64_t qid, uint32_t msgid, int ok) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_TX_DATA, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_u32(p_lka, msgid); m_add_int(p_lka, ok); @@ -155,9 +191,13 @@ report_smtp_tx_data(const char *direction, uint64_t qid, uint32_t msgid, int ok) void report_smtp_tx_commit(const char *direction, uint64_t qid, uint32_t msgid, size_t msgsz) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_TX_COMMIT, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_u32(p_lka, msgid); m_add_size(p_lka, msgsz); @@ -167,9 +207,13 @@ report_smtp_tx_commit(const char *direction, uint64_t qid, uint32_t msgid, size_ void report_smtp_tx_rollback(const char *direction, uint64_t qid, uint32_t msgid) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_TX_ROLLBACK, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_u32(p_lka, msgid); m_close(p_lka); @@ -178,9 +222,13 @@ report_smtp_tx_rollback(const char *direction, uint64_t qid, uint32_t msgid) void report_smtp_protocol_client(const char *direction, uint64_t qid, const char *command) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_PROTOCOL_CLIENT, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_string(p_lka, command); m_close(p_lka); @@ -189,9 +237,13 @@ report_smtp_protocol_client(const char *direction, uint64_t qid, const char *com void report_smtp_protocol_server(const char *direction, uint64_t qid, const char *response) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_PROTOCOL_SERVER, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_string(p_lka, response); m_close(p_lka); @@ -200,9 +252,13 @@ report_smtp_protocol_server(const char *direction, uint64_t qid, const char *res void report_smtp_filter_response(const char *direction, uint64_t qid, int phase, int response, const char *param) { + struct timeval tv; + + gettimeofday(&tv, NULL); + m_create(p_lka, IMSG_REPORT_SMTP_FILTER_RESPONSE, 0, 0, -1); m_add_string(p_lka, direction); - m_add_time(p_lka, time(NULL)); + m_add_timeval(p_lka, &tv); m_add_id(p_lka, qid); m_add_int(p_lka, phase); m_add_int(p_lka, response); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index b1bbde702f8..ca83cd51a13 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.593 2018/12/12 21:28:39 gilles Exp $ */ +/* $OpenBSD: smtpd.h,v 1.594 2018/12/13 17:08:10 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -1327,21 +1327,21 @@ struct io *lka_proc_get_io(const char *); /* lka_report.c */ -void lka_report_smtp_link_connect(const char *, time_t, uint64_t, const char *, int, +void lka_report_smtp_link_connect(const char *, struct timeval *, uint64_t, const char *, int, const struct sockaddr_storage *, const struct sockaddr_storage *); -void lka_report_smtp_link_disconnect(const char *, time_t, uint64_t); -void lka_report_smtp_link_identify(const char *, time_t, uint64_t, const char *); -void lka_report_smtp_link_tls(const char *, time_t, uint64_t, const char *); -void lka_report_smtp_tx_begin(const char *, time_t, uint64_t, uint32_t); -void lka_report_smtp_tx_mail(const char *, time_t, uint64_t, uint32_t, const char *, int); -void lka_report_smtp_tx_rcpt(const char *, time_t, uint64_t, uint32_t, const char *, int); -void lka_report_smtp_tx_envelope(const char *, time_t, uint64_t, uint32_t, uint64_t); -void lka_report_smtp_tx_commit(const char *, time_t, uint64_t, uint32_t, size_t); -void lka_report_smtp_tx_data(const char *, time_t, uint64_t, uint32_t, int); -void lka_report_smtp_tx_rollback(const char *, time_t, uint64_t, uint32_t); -void lka_report_smtp_protocol_client(const char *, time_t, uint64_t, const char *); -void lka_report_smtp_protocol_server(const char *, time_t, uint64_t, const char *); -void lka_report_smtp_filter_response(const char *, time_t, uint64_t, +void lka_report_smtp_link_disconnect(const char *, struct timeval *, uint64_t); +void lka_report_smtp_link_identify(const char *, struct timeval *, uint64_t, const char *); +void lka_report_smtp_link_tls(const char *, struct timeval *, uint64_t, const char *); +void lka_report_smtp_tx_begin(const char *, struct timeval *, uint64_t, uint32_t); +void lka_report_smtp_tx_mail(const char *, struct timeval *, uint64_t, uint32_t, const char *, int); +void lka_report_smtp_tx_rcpt(const char *, struct timeval *, uint64_t, uint32_t, const char *, int); +void lka_report_smtp_tx_envelope(const char *, struct timeval *, uint64_t, uint32_t, uint64_t); +void lka_report_smtp_tx_commit(const char *, struct timeval *, uint64_t, uint32_t, size_t); +void lka_report_smtp_tx_data(const char *, struct timeval *, uint64_t, uint32_t, int); +void lka_report_smtp_tx_rollback(const char *, struct timeval *, uint64_t, uint32_t); +void lka_report_smtp_protocol_client(const char *, struct timeval *, uint64_t, const char *); +void lka_report_smtp_protocol_server(const char *, struct timeval *, uint64_t, const char *); +void lka_report_smtp_filter_response(const char *, struct timeval *, uint64_t, int, int, const char *); @@ -1407,6 +1407,7 @@ void m_add_int(struct mproc *, int); void m_add_u32(struct mproc *, uint32_t); void m_add_size(struct mproc *, size_t); void m_add_time(struct mproc *, time_t); +void m_add_timeval(struct mproc *, struct timeval *tv); void m_add_string(struct mproc *, const char *); void m_add_data(struct mproc *, const void *, size_t); void m_add_evpid(struct mproc *, uint64_t); @@ -1426,6 +1427,7 @@ void m_get_int(struct msg *, int *); void m_get_size(struct msg *, size_t *); void m_get_u32(struct msg *, uint32_t *); void m_get_time(struct msg *, time_t *); +void m_get_timeval(struct msg *, struct timeval *); void m_get_string(struct msg *, const char **); void m_get_data(struct msg *, const void **, size_t *); void m_get_evpid(struct msg *, uint64_t *); |