From: Wietse Venema
See Client-side TLS -connection reuse to also implement multiple deliveries over a -TLS-encrypted connection (Postfix version 3.4 and later).
-SMTP Connection caching is a performance feature. Whether or not it actually improves performance depends on the conditions:
@@ -95,7 +91,7 @@ architecture OVERVIEW document.The Postfix connection cache is shared among Postfix mail delivering processes. This maximizes the opportunity to reuse an -open connection. Other MTAs such as Sendmail or exim have a +open connection. Some MTAs such as Sendmail have a non-shared connection cache. Here, a connection can be reused only by the mail delivering process that creates the connection. To get the same performance improvement as with a shared connection cache, @@ -105,42 +101,79 @@ non-shared connections need to be kept open for a longer time.
maintains the shared connection cache. With Postfix version 2.2, only the smtp(8) client has support to access this cache. +When SMTP connection caching is enabled (see next section), the +smtp(8) client does not disconnect after a mail transaction, but +gives the connection to the scache(8) server which keeps the +connection open for a limited amount of time.
+ +After handing over the open connection to the scache(8) server, +the smtp(8) client continues with some other mail delivery request. +Meanwhile, any smtp(8) client process can ask the scache(8) server +for that cached connection and reuse it for mail delivery.
+-
+--> /-- smtp(8) ---> Internet Internet + + qmgr(8) - |
|
|
|
v+ |
|
|
|
v- \-- smtp(8) + - - \-- smtp(8) ---> Internet + ^ -
|- ^
|scache(8)
When SMTP connection caching is enabled (see next section), the -smtp(8) client does not disconnect after a mail transaction, but -gives the connection to the scache(8) server which keeps the -connection open for a limited amount of time.
+With TLS connection reuse (Postfix 3.4 and later), the Postfix +smtp(8) client connects to a remote SMTP server and sends plaintext +EHLO and STARTTLS commands, then inserts a tlsproxy(8) process into +the connection as shown below.
-After handing over the open connection to the scache(8) server, -the smtp(8) client continues with some other mail delivery request. -Meanwhile, any smtp(8) client process can ask the scache(8) server -for that cached connection and reuse it for mail delivery.
+After delivering mail, the smtp(8) client hands over the open +smtp(8)-to-tlsproxy(8) connection to the scache(8) server, and +continues with some other mail delivery request. Meanwhile, any +smtp(8) client process can ask the scache(8) server for that cached +connection and reuse it for mail delivery.
+ ++ ++ +
+ ++ + /-- smtp(8) +--> tlsproxy(8) + --> Internet + + qmgr(8) + | +
|
|
|
v+ + \-- smtp(8) + + + ^
|+ + scache(8)
The connection cache can be searched by destination domain name (the right-hand side of the recipient address) and by the IP address @@ -214,6 +247,10 @@ lookups is ignored.
+See Client-side TLS +connection reuse to enable multiple deliveries over a TLS-encrypted +connection (Postfix version 3.4 and later).
+After the mail transaction completes, the Postfix smtp(8) client -gives its connection to the tlsproxy(8) process to the scache(8) +gives the smtp(8)-to-tlsproxy(8) connection to the scache(8) server, which keeps the connection open for a limited amount of time. The smtp(8) client continues with some other mail delivery request. Meanwhile, any Postfix smtp(8) client can ask the scache(8) diff --git a/postfix/proto/CONNECTION_CACHE_README.html b/postfix/proto/CONNECTION_CACHE_README.html index dafecf400..7f35146e0 100644 --- a/postfix/proto/CONNECTION_CACHE_README.html +++ b/postfix/proto/CONNECTION_CACHE_README.html @@ -48,10 +48,6 @@ messages over the same SMTP connection. By default, Postfix 2.2 reuses a plaintext SMTP connection automatically when a destination has high volume of mail in the active queue.
-See Client-side TLS -connection reuse to also implement multiple deliveries over a -TLS-encrypted connection (Postfix version 3.4 and later).
-SMTP Connection caching is a performance feature. Whether or not it actually improves performance depends on the conditions:
@@ -95,7 +91,7 @@ architecture OVERVIEW document.The Postfix connection cache is shared among Postfix mail delivering processes. This maximizes the opportunity to reuse an -open connection. Other MTAs such as Sendmail or exim have a +open connection. Some MTAs such as Sendmail have a non-shared connection cache. Here, a connection can be reused only by the mail delivering process that creates the connection. To get the same performance improvement as with a shared connection cache, @@ -105,42 +101,79 @@ non-shared connections need to be kept open for a longer time.
maintains the shared connection cache. With Postfix version 2.2, only the smtp(8) client has support to access this cache. +When SMTP connection caching is enabled (see next section), the +smtp(8) client does not disconnect after a mail transaction, but +gives the connection to the scache(8) server which keeps the +connection open for a limited amount of time.
+ +After handing over the open connection to the scache(8) server, +the smtp(8) client continues with some other mail delivery request. +Meanwhile, any smtp(8) client process can ask the scache(8) server +for that cached connection and reuse it for mail delivery.
+-
+--> /-- smtp(8) ---> Internet Internet + + qmgr(8) - |
|
|
|
v+ |
|
|
|
v- \-- smtp(8) + - - \-- smtp(8) ---> Internet + ^ -
|- ^
|scache(8)
When SMTP connection caching is enabled (see next section), the -smtp(8) client does not disconnect after a mail transaction, but -gives the connection to the scache(8) server which keeps the -connection open for a limited amount of time.
+With TLS connection reuse (Postfix 3.4 and later), the Postfix +smtp(8) client connects to a remote SMTP server and sends plaintext +EHLO and STARTTLS commands, then inserts a tlsproxy(8) process into +the connection as shown below.
-After handing over the open connection to the scache(8) server, -the smtp(8) client continues with some other mail delivery request. -Meanwhile, any smtp(8) client process can ask the scache(8) server -for that cached connection and reuse it for mail delivery.
+After delivering mail, the smtp(8) client hands over the open +smtp(8)-to-tlsproxy(8) connection to the scache(8) server, and +continues with some other mail delivery request. Meanwhile, any +smtp(8) client process can ask the scache(8) server for that cached +connection and reuse it for mail delivery.
+ ++ ++ +
+ ++ + /-- smtp(8) +--> tlsproxy(8) + --> Internet + + qmgr(8) + | +
|
|
|
v+ + \-- smtp(8) + + + ^
|+ + scache(8)
The connection cache can be searched by destination domain name (the right-hand side of the recipient address) and by the IP address @@ -214,6 +247,10 @@ lookups is ignored.
+See Client-side TLS +connection reuse to enable multiple deliveries over a TLS-encrypted +connection (Postfix version 3.4 and later).
+ After the mail transaction completes, the Postfix smtp(8) client
-gives its connection to the tlsproxy(8) process to the scache(8)
+gives the smtp(8)-to-tlsproxy(8) connection to the scache(8)
server, which keeps the connection open for a limited amount of
time. The smtp(8) client continues with some other mail delivery
request. Meanwhile, any Postfix smtp(8) client can ask the scache(8)
diff --git a/postfix/src/global/haproxy_srvr.c b/postfix/src/global/haproxy_srvr.c
index da33eec8c..63147c1c5 100644
--- a/postfix/src/global/haproxy_srvr.c
+++ b/postfix/src/global/haproxy_srvr.c
@@ -455,19 +455,19 @@ const char *haproxy_srvr_parse(const char *str, ssize_t *str_len,
if (beyond_header == 0)
err = "missing protocol header terminator";
else if (haproxy_srvr_parse_lit(NEXT_TOKEN, "PROXY", (char *) 0) < 0)
- err = "unexpected protocol header";
+ err = "bad or missing protocol header";
else if (haproxy_srvr_parse_proto(NEXT_TOKEN, &addr_family) < 0)
- err = "unsupported protocol type";
+ err = "bad or missing protocol type";
else if (haproxy_srvr_parse_addr(NEXT_TOKEN, smtp_client_addr,
addr_family) < 0)
- err = "unexpected client address syntax";
+ err = "bad or missing client address";
else if (haproxy_srvr_parse_addr(NEXT_TOKEN, smtp_server_addr,
addr_family) < 0)
- err = "unexpected server address syntax";
+ err = "bad or missing server address";
else if (haproxy_srvr_parse_port(NEXT_TOKEN, smtp_client_port) < 0)
- err = "unexpected client port syntax";
+ err = "bad or missing client port";
else if (haproxy_srvr_parse_port(NEXT_TOKEN, smtp_server_port) < 0)
- err = "unexpected server port syntax";
+ err = "bad or missing server port";
else {
err = 0;
*str_len = beyond_header - saved_str;
@@ -561,32 +561,35 @@ static TEST_CASE v1_test_cases[] = {
/* IPv6. */
{"PROXY TCP6 fc:00:00:00:1:2:3:4 fc:00:00:00:4:3:2:1 123 321\n", 0, 0, 0, 0, "fc::1:2:3:4", "fc::4:3:2:1", "123", "321"},
{"PROXY TCP6 FC:00:00:00:1:2:3:4 FC:00:00:00:4:3:2:1 123 321\n", 0, 0, 0, 0, "fc::1:2:3:4", "fc::4:3:2:1", "123", "321"},
- {"PROXY TCP6 1.2.3.4 4.3.2.1 123 321\n", 0, 0, 0, "unexpected client address syntax"},
- {"PROXY TCP6 fc:00:00:00:1:2:3:4 4.3.2.1 123 321\n", 0, 0, 0, "unexpected server address syntax"},
+ {"PROXY TCP6 1.2.3.4 4.3.2.1 123 321\n", 0, 0, 0, "bad or missing client address"},
+ {"PROXY TCP6 fc:00:00:00:1:2:3:4 4.3.2.1 123 321\n", 0, 0, 0, "bad or missing server address"},
/* IPv4 in IPv6. */
{"PROXY TCP6 ::ffff:1.2.3.4 ::ffff:4.3.2.1 123 321\n", 0, 0, 0, 0, "1.2.3.4", "4.3.2.1", "123", "321"},
{"PROXY TCP6 ::FFFF:1.2.3.4 ::FFFF:4.3.2.1 123 321\n", 0, 0, 0, 0, "1.2.3.4", "4.3.2.1", "123", "321"},
- {"PROXY TCP4 ::ffff:1.2.3.4 ::ffff:4.3.2.1 123 321\n", 0, 0, 0, "unexpected client address syntax"},
- {"PROXY TCP4 1.2.3.4 ::ffff:4.3.2.1 123 321\n", 0, 0, 0, "unexpected server address syntax"},
+ {"PROXY TCP4 ::ffff:1.2.3.4 ::ffff:4.3.2.1 123 321\n", 0, 0, 0, "bad or missing client address"},
+ {"PROXY TCP4 1.2.3.4 ::ffff:4.3.2.1 123 321\n", 0, 0, 0, "bad or missing server address"},
/* IPv4. */
{"PROXY TCP4 1.2.3.4 4.3.2.1 123 321\n", 0, 0, 0, 0, "1.2.3.4", "4.3.2.1", "123", "321"},
{"PROXY TCP4 01.02.03.04 04.03.02.01 123 321\n", 0, 0, 0, 0, "1.2.3.4", "4.3.2.1", "123", "321"},
- {"PROXY TCP4 1.2.3.4 4.3.2.1 123456 321\n", 0, 0, 0, "unexpected client port syntax"},
- {"PROXY TCP4 1.2.3.4 4.3.2.1 123 654321\n", 0, 0, 0, "unexpected server port syntax"},
- {"PROXY TCP4 1.2.3.4 4.3.2.1 0123 321\n", 0, 0, 0, "unexpected client port syntax"},
- {"PROXY TCP4 1.2.3.4 4.3.2.1 123 0321\n", 0, 0, 0, "unexpected server port syntax"},
+ {"PROXY TCP4 1.2.3.4 4.3.2.1 123456 321\n", 0, 0, 0, "bad or missing client port"},
+ {"PROXY TCP4 1.2.3.4 4.3.2.1 123 654321\n", 0, 0, 0, "bad or missing server port"},
+ {"PROXY TCP4 1.2.3.4 4.3.2.1 0123 321\n", 0, 0, 0, "bad or missing client port"},
+ {"PROXY TCP4 1.2.3.4 4.3.2.1 123 0321\n", 0, 0, 0, "bad or missing server port"},
/* Missing fields. */
- {"PROXY TCP6 fc:00:00:00:1:2:3:4 fc:00:00:00:4:3:2:1 123\n", 0, 0, 0, "unexpected server port syntax"},
- {"PROXY TCP6 fc:00:00:00:1:2:3:4 fc:00:00:00:4:3:2:1\n", 0, 0, 0, "unexpected client port syntax"},
- {"PROXY TCP6 fc:00:00:00:1:2:3:4\n", 0, 0, 0, "unexpected server address syntax"},
- {"PROXY TCP6\n", 0, 0, 0, "unexpected client address syntax"},
- {"PROXY TCP4 1.2.3.4 4.3.2.1 123\n", 0, 0, 0, "unexpected server port syntax"},
- {"PROXY TCP4 1.2.3.4 4.3.2.1\n", 0, 0, 0, "unexpected client port syntax"},
- {"PROXY TCP4 1.2.3.4\n", 0, 0, 0, "unexpected server address syntax"},
- {"PROXY TCP4\n", 0, 0, 0, "unexpected client address syntax"},
+ {"PROXY TCP6 fc:00:00:00:1:2:3:4 fc:00:00:00:4:3:2:1 123\n", 0, 0, 0, "bad or missing server port"},
+ {"PROXY TCP6 fc:00:00:00:1:2:3:4 fc:00:00:00:4:3:2:1\n", 0, 0, 0, "bad or missing client port"},
+ {"PROXY TCP6 fc:00:00:00:1:2:3:4\n", 0, 0, 0, "bad or missing server address"},
+ {"PROXY TCP6\n", 0, 0, 0, "bad or missing client address"},
+ {"PROXY TCP4 1.2.3.4 4.3.2.1 123\n", 0, 0, 0, "bad or missing server port"},
+ {"PROXY TCP4 1.2.3.4 4.3.2.1\n", 0, 0, 0, "bad or missing client port"},
+ {"PROXY TCP4 1.2.3.4\n", 0, 0, 0, "bad or missing server address"},
+ {"PROXY TCP4\n", 0, 0, 0, "bad or missing client address"},
/* Other. */
- {"PROXY BLAH\n", 0, 0, 0, "unsupported protocol type"},
+ {"PROXY BLAH\n", 0, 0, 0, "bad or missing protocol type"},
+ {"PROXY\n", 0, 0, 0, "short protocol header"},
{"BLAH\n", 0, 0, 0, "short protocol header"},
+ {"\n", 0, 0, 0, "short protocol header"},
+ {"", 0, 0, 0, "short protocol header"},
0,
};
diff --git a/postfix/src/global/mail_task.c b/postfix/src/global/mail_task.c
index 4f006768b..733645d38 100644
--- a/postfix/src/global/mail_task.c
+++ b/postfix/src/global/mail_task.c
@@ -18,9 +18,7 @@
/* The result is overwritten with each call.
/*
/* A null argv0 argument requests that the current result is
-/* returned.
-/* DIAGNOSTICS
-/* Panic: argv0 is a null pointer, but no current result exists.
+/* returned, or "unknown" when no current result exists.
/* LICENSE
/* .ad
/* .fi
@@ -46,7 +44,6 @@
#include