diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2011-10-09 18:39:55 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2011-10-09 18:39:55 +0000 |
commit | ad03e2c7c7cab0cccdb501682fc29d230896cddc (patch) | |
tree | dceaf0773380012682d8e3af7bad545aea21a10e | |
parent | c45e61c7b6744c0dd8c3296ed9a6ef961a772ac6 (diff) |
show messages sent between processes in debug mode
ok gilles@ chl@
-rw-r--r-- | usr.sbin/smtpd/control.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/mda.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/mfa.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/mta.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/queue.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/runner.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp.c | 10 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 114 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 3 |
10 files changed, 139 insertions, 16 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index 3be91e81407..9dd53fe9721 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.60 2011/09/01 19:56:49 eric Exp $ */ +/* $OpenBSD: control.c,v 1.61 2011/10/09 18:39:53 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -66,6 +66,8 @@ control_imsg(struct imsgev *iev, struct imsg *imsg) struct ctl_conn *c; struct reload *reload; + log_imsg(PROC_CONTROL, iev->proc, imsg); + if (iev->proc == PROC_SMTP) { switch (imsg->hdr.type) { case IMSG_SMTP_ENQUEUE: diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 581a72e86d3..3ba0514430f 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.127 2011/05/16 21:05:51 gilles Exp $ */ +/* $OpenBSD: lka.c,v 1.128 2011/10/09 18:39:53 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -61,6 +61,8 @@ lka_imsg(struct imsgev *iev, struct imsg *imsg) struct map *map; void *tmp; + log_imsg(PROC_LKA, iev->proc, imsg); + if (imsg->hdr.type == IMSG_DNS_HOST || imsg->hdr.type == IMSG_DNS_MX || imsg->hdr.type == IMSG_DNS_PTR) { dns_async(iev, imsg->hdr.type, imsg->data); diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index 9f3dd26e0af..eaef4e7bd62 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.59 2011/08/29 21:43:08 chl Exp $ */ +/* $OpenBSD: mda.c,v 1.60 2011/10/09 18:39:53 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -57,6 +57,8 @@ mda_imsg(struct imsgev *iev, struct imsg *imsg) struct delivery_mda *d_mda; struct mailaddr *maddr; + log_imsg(PROC_MDA, iev->proc, imsg); + if (iev->proc == PROC_QUEUE) { switch (imsg->hdr.type) { case IMSG_MDA_SESS_NEW: diff --git a/usr.sbin/smtpd/mfa.c b/usr.sbin/smtpd/mfa.c index 22e5a19827c..b2c02918ee9 100644 --- a/usr.sbin/smtpd/mfa.c +++ b/usr.sbin/smtpd/mfa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfa.c,v 1.62 2011/09/27 18:53:24 chl Exp $ */ +/* $OpenBSD: mfa.c,v 1.63 2011/10/09 18:39:53 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -54,6 +54,8 @@ mfa_imsg(struct imsgev *iev, struct imsg *imsg) { struct filter *filter; + log_imsg(PROC_MFA, iev->proc, imsg); + if (iev->proc == PROC_SMTP) { switch (imsg->hdr.type) { case IMSG_MFA_HELO: diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index 70ac092fd4b..c727307ecd6 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.113 2011/08/29 21:43:09 chl Exp $ */ +/* $OpenBSD: mta.c,v 1.114 2011/10/09 18:39:53 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -65,6 +65,8 @@ mta_imsg(struct imsgev *iev, struct imsg *imsg) struct dns *dns; struct ssl *ssl; + log_imsg(PROC_MTA, iev->proc, imsg); + if (iev->proc == PROC_QUEUE) { switch (imsg->hdr.type) { case IMSG_BATCH_CREATE: diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 593b4651c0f..12ea1bd0d8a 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.106 2011/09/01 19:56:49 eric Exp $ */ +/* $OpenBSD: queue.c,v 1.107 2011/10/09 18:39:53 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -51,6 +51,8 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg) struct ramqueue_batch *rq_batch; int fd, ret; + log_imsg(PROC_QUEUE, iev->proc, imsg); + if (iev->proc == PROC_SMTP) { e = imsg->data; diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index 2a559bf0522..33f9b7f6af9 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.118 2011/09/18 21:37:53 gilles Exp $ */ +/* $OpenBSD: runner.c,v 1.119 2011/10/09 18:39:53 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -70,6 +70,8 @@ runner_imsg(struct imsgev *iev, struct imsg *imsg) { struct envelope *e; + log_imsg(PROC_RUNNER, iev->proc, imsg); + switch (imsg->hdr.type) { case IMSG_QUEUE_COMMIT_MESSAGE: e = imsg->data; diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index b2946208075..8ea6d9465ec 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.91 2011/09/01 20:17:47 gilles Exp $ */ +/* $OpenBSD: smtp.c,v 1.92 2011/10/09 18:39:54 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -61,6 +61,8 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg) struct ssl *ssl; struct dns *dns; + log_imsg(PROC_SMTP, iev->proc, imsg); + if (iev->proc == PROC_LKA) { switch (imsg->hdr.type) { case IMSG_DNS_PTR: @@ -83,7 +85,6 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg) case IMSG_MFA_HELO: case IMSG_MFA_MAIL: case IMSG_MFA_RCPT: - log_debug("smtp: got imsg_mfa_helo/mail/rcpt"); case IMSG_MFA_DATALINE: ss = imsg->data; s = session_lookup(ss->id); @@ -99,7 +100,6 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg) switch (imsg->hdr.type) { case IMSG_QUEUE_CREATE_MESSAGE: - log_debug("smtp: imsg_queue_create_message returned"); s = session_lookup(ss->id); if (s == NULL) return; @@ -108,7 +108,6 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg) return; case IMSG_QUEUE_MESSAGE_FILE: - log_debug("smtp: imsg_queue_message_file returned"); s = session_lookup(ss->id); if (s == NULL) { close(imsg->fd); @@ -125,7 +124,6 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg) return; case IMSG_QUEUE_TEMPFAIL: - log_debug("smtp: got imsg_queue_tempfail"); skey.s_id = ss->id; s = SPLAY_FIND(sessiontree, &env->sc_sessions, &skey); if (s == NULL) @@ -138,7 +136,6 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg) return; case IMSG_QUEUE_COMMIT_ENVELOPES: - log_debug("smtp: got imsg_queue_commit_envelopes"); s = session_lookup(ss->id); if (s == NULL) return; @@ -146,7 +143,6 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg) return; case IMSG_QUEUE_COMMIT_MESSAGE: - log_debug("smtp: got imsg_queue_commit_message"); s = session_lookup(ss->id); if (s == NULL) return; diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index e52b1257004..dcfb03a841a 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.130 2011/09/01 19:56:49 eric Exp $ */ +/* $OpenBSD: smtpd.c,v 1.131 2011/10/09 18:39:54 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -89,6 +89,8 @@ parent_imsg(struct imsgev *iev, struct imsg *imsg) struct auth_backend *auth_backend; int fd; + log_imsg(PROC_PARENT, iev->proc, imsg); + if (iev->proc == PROC_SMTP) { switch (imsg->hdr.type) { case IMSG_PARENT_SEND_CONFIG: @@ -1111,3 +1113,113 @@ imsg_dispatch(int fd, short event, void *p) } SPLAY_GENERATE(childtree, child, entry, child_cmp); + +const char * proc_to_str(int); +const char * imsg_to_str(int); + +void +log_imsg(int to, int from, struct imsg *imsg) +{ + log_debug("imsg: %s <- %s: %s (len=%zu)", + proc_to_str(to), + proc_to_str(from), + imsg_to_str(imsg->hdr.type), + imsg->hdr.len - IMSG_HEADER_SIZE); +} + +#define CASE(x) case x : return #x + +const char * +proc_to_str(int proc) +{ + switch (proc) { + CASE(PROC_PARENT); + CASE(PROC_SMTP); + CASE(PROC_MFA); + CASE(PROC_LKA); + CASE(PROC_QUEUE); + CASE(PROC_MDA); + CASE(PROC_MTA); + CASE(PROC_CONTROL); + CASE(PROC_RUNNER); + default: + return "PROC_???"; + } +} + +const char * +imsg_to_str(int type) +{ + switch(type) { + CASE(IMSG_NONE); + CASE(IMSG_CTL_OK); + CASE(IMSG_CTL_FAIL); + CASE(IMSG_CTL_SHUTDOWN); + CASE(IMSG_CTL_VERBOSE); + CASE(IMSG_CONF_START); + CASE(IMSG_CONF_SSL); + CASE(IMSG_CONF_LISTENER); + CASE(IMSG_CONF_MAP); + CASE(IMSG_CONF_MAP_CONTENT); + CASE(IMSG_CONF_RULE); + CASE(IMSG_CONF_RULE_SOURCE); + CASE(IMSG_CONF_FILTER); + CASE(IMSG_CONF_END); + CASE(IMSG_CONF_RELOAD); + CASE(IMSG_LKA_MAIL); + CASE(IMSG_LKA_RCPT); + CASE(IMSG_LKA_SECRET); + CASE(IMSG_LKA_RULEMATCH); + CASE(IMSG_MDA_SESS_NEW); + CASE(IMSG_MDA_DONE); + + CASE(IMSG_MFA_HELO); + CASE(IMSG_MFA_MAIL); + CASE(IMSG_MFA_RCPT); + CASE(IMSG_MFA_DATALINE); + + CASE(IMSG_QUEUE_CREATE_MESSAGE); + CASE(IMSG_QUEUE_SUBMIT_ENVELOPE); + CASE(IMSG_QUEUE_COMMIT_ENVELOPES); + CASE(IMSG_QUEUE_REMOVE_MESSAGE); + CASE(IMSG_QUEUE_COMMIT_MESSAGE); + CASE(IMSG_QUEUE_TEMPFAIL); + CASE(IMSG_QUEUE_PAUSE_LOCAL); + CASE(IMSG_QUEUE_PAUSE_OUTGOING); + CASE(IMSG_QUEUE_RESUME_LOCAL); + CASE(IMSG_QUEUE_RESUME_OUTGOING); + + CASE(IMSG_QUEUE_MESSAGE_UPDATE); + CASE(IMSG_QUEUE_MESSAGE_FD); + CASE(IMSG_QUEUE_MESSAGE_FILE); + CASE(IMSG_QUEUE_SCHEDULE); + CASE(IMSG_QUEUE_REMOVE); + + CASE(IMSG_RUNNER_REMOVE); + CASE(IMSG_RUNNER_SCHEDULE); + + CASE(IMSG_BATCH_CREATE); + CASE(IMSG_BATCH_APPEND); + CASE(IMSG_BATCH_CLOSE); + CASE(IMSG_BATCH_DONE); + + CASE(IMSG_PARENT_ENQUEUE_OFFLINE); + CASE(IMSG_PARENT_FORWARD_OPEN); + CASE(IMSG_PARENT_FORK_MDA); + + CASE(IMSG_PARENT_AUTHENTICATE); + CASE(IMSG_PARENT_SEND_CONFIG); + + CASE(IMSG_STATS); + CASE(IMSG_SMTP_ENQUEUE); + CASE(IMSG_SMTP_PAUSE); + CASE(IMSG_SMTP_RESUME); + + CASE(IMSG_DNS_HOST); + CASE(IMSG_DNS_HOST_END); + CASE(IMSG_DNS_MX); + CASE(IMSG_DNS_PTR); + default: + return "IMSG_???"; + } +} diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 4a06bb839e1..da6d9713544 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.240 2011/09/19 13:10:47 chl Exp $ */ +/* $OpenBSD: smtpd.h,v 1.241 2011/10/09 18:39:54 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -1225,3 +1225,4 @@ u_int32_t evpid_to_msgid(u_int64_t); u_int64_t msgid_to_evpid(u_int32_t); u_int32_t filename_to_msgid(char *); u_int64_t filename_to_evpid(char *); +void log_imsg(int, int, struct imsg*); |