summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2018-11-08 13:21:01 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2018-11-08 13:21:01 +0000
commit451ad30b66e2128aa87885ed36a5069f55ee9429 (patch)
treea6215d57d8f3fcefedf0806291310e075d7348d6
parentbb0057aac7a6fba0894cafa156a8a0d641952a88 (diff)
when reporting tx events, report tx id
when reporting tx commit, report data size report tx-envelope events
-rw-r--r--usr.sbin/smtpd/lka.c23
-rw-r--r--usr.sbin/smtpd/lka_report.c22
-rw-r--r--usr.sbin/smtpd/smtp_report.c20
-rw-r--r--usr.sbin/smtpd/smtp_session.c7
-rw-r--r--usr.sbin/smtpd/smtpd.h13
5 files changed, 64 insertions, 21 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index d0554b8d75e..6d6124884a7 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.213 2018/11/03 13:56:49 gilles Exp $ */
+/* $OpenBSD: lka.c,v 1.214 2018/11/08 13:21:00 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -90,6 +90,9 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
struct sockaddr_storage ss_src, ss_dest;
int filter_phase;
const char *filter_param;
+ uint32_t msgid;
+ uint64_t evpid;
+ size_t msgsz;
if (imsg == NULL)
lka_shutdown();
@@ -442,18 +445,32 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_msg(&m, imsg);
m_get_time(&m, &tm);
m_get_id(&m, &reqid);
+ m_get_u32(&m, &msgid);
m_end(&m);
- lka_report_smtp_tx_begin(tm, reqid);
+ lka_report_smtp_tx_begin(tm, reqid, msgid);
+ return;
+
+ case IMSG_SMTP_REPORT_TX_ENVELOPE:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_get_u32(&m, &msgid);
+ m_get_id(&m, &evpid);
+ m_end(&m);
+
+ lka_report_smtp_tx_envelope(tm, reqid, msgid, evpid);
return;
case IMSG_SMTP_REPORT_TX_COMMIT:
m_msg(&m, imsg);
m_get_time(&m, &tm);
m_get_id(&m, &reqid);
+ m_get_u32(&m, &msgid);
+ m_get_size(&m, &msgsz);
m_end(&m);
- lka_report_smtp_tx_commit(tm, reqid);
+ lka_report_smtp_tx_commit(tm, reqid, msgid, msgsz);
return;
case IMSG_SMTP_REPORT_TX_ROLLBACK:
diff --git a/usr.sbin/smtpd/lka_report.c b/usr.sbin/smtpd/lka_report.c
index a6ab66b4cd6..ac1a53aa88a 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.6 2018/11/08 12:42:29 gilles Exp $ */
+/* $OpenBSD: lka_report.c,v 1.7 2018/11/08 13:21:00 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -98,19 +98,27 @@ lka_report_smtp_link_tls(time_t tm, uint64_t reqid, const char *ciphers)
}
void
-lka_report_smtp_tx_begin(time_t tm, uint64_t reqid)
+lka_report_smtp_tx_begin(time_t tm, uint64_t reqid, uint32_t msgid)
{
report_smtp_broadcast("report|%d|%zd|smtp-in|tx-begin|"
- "%016"PRIx64"\n",
- PROTOCOL_VERSION, tm, reqid);
+ "%016"PRIx64"|%08x\n",
+ PROTOCOL_VERSION, tm, reqid, msgid);
+}
+
+void
+lka_report_smtp_tx_envelope(time_t tm, uint64_t reqid, uint32_t msgid, uint64_t evpid)
+{
+ report_smtp_broadcast("report|%d|%zd|smtp-in|tx-envelope|"
+ "%016"PRIx64"|%08x|%016"PRIx64"\n",
+ PROTOCOL_VERSION, tm, reqid, msgid, evpid);
}
void
-lka_report_smtp_tx_commit(time_t tm, uint64_t reqid)
+lka_report_smtp_tx_commit(time_t tm, uint64_t reqid, uint32_t msgid, size_t msgsz)
{
report_smtp_broadcast("report|%d|%zd|smtp-in|tx-commit|"
- "%016"PRIx64"\n",
- PROTOCOL_VERSION, tm, reqid);
+ "%016"PRIx64"|%08x|%zd\n",
+ PROTOCOL_VERSION, tm, reqid, msgid, msgsz);
}
void
diff --git a/usr.sbin/smtpd/smtp_report.c b/usr.sbin/smtpd/smtp_report.c
index 0db974d9400..ea70ee138da 100644
--- a/usr.sbin/smtpd/smtp_report.c
+++ b/usr.sbin/smtpd/smtp_report.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_report.c,v 1.3 2018/11/02 17:20:22 gilles Exp $ */
+/* $OpenBSD: smtp_report.c,v 1.4 2018/11/08 13:21:00 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -77,20 +77,34 @@ smtp_report_link_disconnect(uint64_t qid)
}
void
-smtp_report_tx_begin(uint64_t qid)
+smtp_report_tx_begin(uint64_t qid, uint32_t msgid)
{
m_create(p_lka, IMSG_SMTP_REPORT_TX_BEGIN, 0, 0, -1);
m_add_time(p_lka, time(NULL));
m_add_id(p_lka, qid);
+ m_add_u32(p_lka, msgid);
m_close(p_lka);
}
void
-smtp_report_tx_commit(uint64_t qid)
+smtp_report_tx_envelope(uint64_t qid, uint32_t msgid, uint64_t evpid)
+{
+ m_create(p_lka, IMSG_SMTP_REPORT_TX_ENVELOPE, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_add_u32(p_lka, msgid);
+ m_add_id(p_lka, evpid);
+ m_close(p_lka);
+}
+
+void
+smtp_report_tx_commit(uint64_t qid, uint32_t msgid, size_t msgsz)
{
m_create(p_lka, IMSG_SMTP_REPORT_TX_COMMIT, 0, 0, -1);
m_add_time(p_lka, time(NULL));
m_add_id(p_lka, qid);
+ m_add_u32(p_lka, msgid);
+ m_add_size(p_lka, msgsz);
m_close(p_lka);
}
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 6cbfa84a06a..fdd8ba3eed6 100644
--- a/usr.sbin/smtpd/smtp_session.c
+++ b/usr.sbin/smtpd/smtp_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_session.c,v 1.351 2018/11/07 17:45:01 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.352 2018/11/08 13:21:00 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -689,6 +689,7 @@ smtp_session_imsg(struct mproc *p, struct imsg *imsg)
s->tx->msgid = msgid;
s->tx->evp.id = msgid_to_evpid(msgid);
s->tx->rcptcount = 0;
+ smtp_report_tx_begin(s->id, s->tx->msgid);
smtp_reply(s, "250 %s: Ok",
esc_code(ESC_STATUS_OK, ESC_OTHER_STATUS));
} else {
@@ -729,6 +730,7 @@ smtp_session_imsg(struct mproc *p, struct imsg *imsg)
if (success) {
m_get_evpid(&m, &evpid);
s->tx->destcount++;
+ smtp_report_tx_envelope(s->id, s->tx->msgid, evpid);
}
else
s->tx->error = TX_ERROR_ENVELOPE;
@@ -2266,7 +2268,6 @@ smtp_tx_create_message(struct smtp_tx *tx)
m_add_id(p_queue, tx->session->id);
m_close(p_queue);
tree_xset(&wait_queue_msg, tx->session->id, tx->session);
- smtp_report_tx_begin(tx->session->id);
}
static void
@@ -2358,7 +2359,7 @@ smtp_tx_commit(struct smtp_tx *tx)
m_add_msgid(p_queue, tx->msgid);
m_close(p_queue);
tree_xset(&wait_queue_commit, tx->session->id, tx->session);
- smtp_report_tx_commit(tx->session->id);
+ smtp_report_tx_commit(tx->session->id, tx->msgid, tx->odatalen);
}
static void
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index f5e5651f3f1..7f58a998ab8 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.572 2018/11/03 14:39:46 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.573 2018/11/08 13:21:00 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -310,6 +310,7 @@ enum imsg_type {
IMSG_SMTP_REPORT_LINK_TLS,
IMSG_SMTP_REPORT_TX_BEGIN,
+ IMSG_SMTP_REPORT_TX_ENVELOPE,
IMSG_SMTP_REPORT_TX_COMMIT,
IMSG_SMTP_REPORT_TX_ROLLBACK,
@@ -1299,8 +1300,9 @@ struct io *lka_proc_get_io(const char *);
void lka_report_smtp_link_connect(time_t, uint64_t, const char *, const struct sockaddr_storage *, const struct sockaddr_storage *);
void lka_report_smtp_link_disconnect(time_t, uint64_t);
void lka_report_smtp_link_tls(time_t, uint64_t, const char *);
-void lka_report_smtp_tx_begin(time_t, uint64_t);
-void lka_report_smtp_tx_commit(time_t, uint64_t);
+void lka_report_smtp_tx_begin(time_t, uint64_t, uint32_t);
+void lka_report_smtp_tx_envelope(time_t, uint64_t, uint32_t, uint64_t);
+void lka_report_smtp_tx_commit(time_t, uint64_t, uint32_t, size_t);
void lka_report_smtp_tx_rollback(time_t, uint64_t);
void lka_report_smtp_protocol_client(time_t, uint64_t, const char *);
void lka_report_smtp_protocol_server(time_t, uint64_t, const char *);
@@ -1482,8 +1484,9 @@ void smtp_collect(void);
void smtp_report_link_connect(uint64_t, const char *, const struct sockaddr_storage *, const struct sockaddr_storage *);
void smtp_report_link_disconnect(uint64_t);
void smtp_report_link_tls(uint64_t, const char *);
-void smtp_report_tx_begin(uint64_t);
-void smtp_report_tx_commit(uint64_t);
+void smtp_report_tx_begin(uint64_t, uint32_t);
+void smtp_report_tx_envelope(uint64_t, uint32_t, uint64_t);
+void smtp_report_tx_commit(uint64_t, uint32_t, size_t);
void smtp_report_tx_rollback(uint64_t);
void smtp_report_protocol_client(uint64_t, const char *);
void smtp_report_protocol_server(uint64_t, const char *);