summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2019-01-05 09:43:40 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2019-01-05 09:43:40 +0000
commit04d2c7c9d73357f05a94dbee2c42311d5608c937 (patch)
treebbf7522807cffd66a3a38abe6004e297947f1713 /usr.sbin
parentbcf949487a05b1a08f49642909bfca143a2bfc1d (diff)
introduce smtp 'timeout' reporting event to notify filters that a timeout
occured during the smtp session
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/lka.c11
-rw-r--r--usr.sbin/smtpd/lka_report.c12
-rw-r--r--usr.sbin/smtpd/report_smtp.c16
-rw-r--r--usr.sbin/smtpd/smtp_session.c3
-rw-r--r--usr.sbin/smtpd/smtpd.h8
5 files changed, 44 insertions, 6 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 9e4d8dc0d3e..fcb4ad6b866 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.232 2018/12/28 11:40:29 eric Exp $ */
+/* $OpenBSD: lka.c,v 1.233 2019/01/05 09:43:39 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -529,6 +529,15 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
filter_phase, filter_response, filter_param);
return;
+ case IMSG_REPORT_SMTP_TIMEOUT:
+ m_msg(&m, imsg);
+ m_get_string(&m, &direction);
+ m_get_timeval(&m, &tv);
+ m_get_id(&m, &reqid);
+ m_end(&m);
+
+ lka_report_smtp_timeout(direction, &tv, reqid);
+ return;
case IMSG_FILTER_SMTP_PROTOCOL:
m_msg(&m, imsg);
diff --git a/usr.sbin/smtpd/lka_report.c b/usr.sbin/smtpd/lka_report.c
index e8eb33480a1..aff14ad3065 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.16 2018/12/21 14:33:52 gilles Exp $ */
+/* $OpenBSD: lka_report.c,v 1.17 2019/01/05 09:43:39 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -66,6 +66,8 @@ static struct smtp_events {
{ "protocol-server" },
{ "filter-response" },
+
+ { "timeout" },
};
@@ -408,3 +410,11 @@ lka_report_smtp_filter_response(const char *direction, struct timeval *tv, uint6
"%016"PRIx64"|%s|%s%s%s\n",
reqid, phase_name, response_name, param ? "|" : "", param ? param : "");
}
+
+void
+lka_report_smtp_timeout(const char *direction, struct timeval *tv, uint64_t reqid)
+{
+ report_smtp_broadcast(reqid, direction, tv, "timeout",
+ "%016"PRIx64"\n",
+ reqid);
+}
diff --git a/usr.sbin/smtpd/report_smtp.c b/usr.sbin/smtpd/report_smtp.c
index d2d8b27d6c9..a4268909e58 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.3 2018/12/13 17:08:10 gilles Exp $ */
+/* $OpenBSD: report_smtp.c,v 1.4 2019/01/05 09:43:39 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -265,3 +265,17 @@ report_smtp_filter_response(const char *direction, uint64_t qid, int phase, int
m_add_string(p_lka, param);
m_close(p_lka);
}
+
+void
+report_smtp_timeout(const char *direction, uint64_t qid)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ m_create(p_lka, IMSG_REPORT_SMTP_TIMEOUT, 0, 0, -1);
+ m_add_string(p_lka, direction);
+ m_add_timeval(p_lka, &tv);
+ m_add_id(p_lka, qid);
+ m_close(p_lka);
+}
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 8b1de9e5dfc..d9f2dd56064 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.386 2019/01/05 08:38:41 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.387 2019/01/05 09:43:39 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1148,6 +1148,7 @@ smtp_io(struct io *io, int evt, void *arg)
log_info("%016"PRIx64" smtp disconnected "
"reason=timeout",
s->id);
+ report_smtp_timeout("smtp-in", s->id);
smtp_free(s, "timeout");
break;
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 71af6b19d2e..fb7d57047a9 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.615 2018/12/28 15:09:28 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.616 2019/01/05 09:43:39 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -52,7 +52,8 @@
#define SMTPD_SOCKET "/var/run/smtpd.sock"
#define SMTPD_NAME "OpenSMTPD"
#define SMTPD_VERSION "6.4.0"
-#define SMTPD_SESSION_TIMEOUT 300
+//#define SMTPD_SESSION_TIMEOUT 300
+#define SMTPD_SESSION_TIMEOUT 30
#define SMTPD_BACKLOG 5
#define PATH_SMTPCTL "/usr/sbin/smtpctl"
@@ -319,6 +320,7 @@ enum imsg_type {
IMSG_REPORT_SMTP_PROTOCOL_CLIENT,
IMSG_REPORT_SMTP_PROTOCOL_SERVER,
IMSG_REPORT_SMTP_FILTER_RESPONSE,
+ IMSG_REPORT_SMTP_TIMEOUT,
IMSG_FILTER_SMTP_BEGIN,
IMSG_FILTER_SMTP_END,
@@ -1356,6 +1358,7 @@ void lka_report_smtp_protocol_client(const char *, struct timeval *, uint64_t, c
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 *);
+void lka_report_smtp_timeout(const char *, struct timeval *, uint64_t);
/* lka_filter.c */
@@ -1521,6 +1524,7 @@ void report_smtp_tx_rollback(const char *, uint64_t, uint32_t);
void report_smtp_protocol_client(const char *, uint64_t, const char *);
void report_smtp_protocol_server(const char *, uint64_t, const char *);
void report_smtp_filter_response(const char *, uint64_t, int, int, const char *);
+void report_smtp_timeout(const char *, uint64_t);
/* ruleset.c */