From: Jeremy Harris Date: Sat, 6 Oct 2018 14:32:14 +0000 (+0100) Subject: TFO: use enum for client status X-Git-Tag: exim-4.92-RC1~83 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=06e272a37fca29df8be58167a30818857a78e348;p=exim.git TFO: use enum for client status --- diff --git a/src/src/globals.c b/src/src/globals.c index cdf00e810..fdeaebd64 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -1519,7 +1519,7 @@ gid_t system_filter_gid = 0; uid_t system_filter_uid = (uid_t)-1; blob tcp_fastopen_nodata = { .data = NULL, .len = 0 }; -int tcp_out_fastopen = 0; +tfo_state_t tcp_out_fastopen = TFO_NOT_USED; #ifdef USE_TCP_WRAPPERS uschar *tcp_wrappers_daemon_name = US TCP_WRAPPERS_DAEMON_NAME; #endif diff --git a/src/src/globals.h b/src/src/globals.h index bdf03606e..de0a7bab8 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -988,7 +988,7 @@ extern BOOL system_filter_uid_set; /* TRUE if uid set */ extern blob tcp_fastopen_nodata; /* for zero-data TFO connect requests */ extern BOOL tcp_nodelay; /* Controls TCP_NODELAY on daemon */ -extern int tcp_out_fastopen; /* 0: no 1: conn used 2: useful */ +extern tfo_state_t tcp_out_fastopen; /* 0: no 1: conn used 2: useful */ #ifdef USE_TCP_WRAPPERS extern uschar *tcp_wrappers_daemon_name; /* tcpwrappers daemon lookup name */ #endif diff --git a/src/src/ip.c b/src/src/ip.c index 633e0c2f9..ef133bf9f 100644 --- a/src/src/ip.c +++ b/src/src/ip.c @@ -267,7 +267,7 @@ if (fastopen_blob && f.tcp_fastopen_ok) debug_printf("non-TFO mode connection attempt to %s, %lu data\n", address, (unsigned long)fastopen_blob->len); /*XXX also seen on successful TFO, sigh */ - tcp_out_fastopen = fastopen_blob->len > 0 ? 2 : 1; + tcp_out_fastopen = fastopen_blob->len > 0 ? TFO_USED : TFO_ATTEMPTED; } else if (errno == EINPROGRESS) /* expected if we had no cookie for peer */ /* seen for no-data, proper TFO option, both cookie-request and with-cookie cases */ @@ -280,7 +280,7 @@ if (fastopen_blob && f.tcp_fastopen_ok) fastopen_blob->len > 0 ? "with" : "no"); if (!fastopen_blob->data) { - tcp_out_fastopen = 1; /* we tried; unknown if useful yet */ + tcp_out_fastopen = TFO_ATTEMPTED; /* we tried; unknown if useful yet */ rc = 0; } else diff --git a/src/src/smtp_out.c b/src/src/smtp_out.c index 62d4c7333..f02863a54 100644 --- a/src/src/smtp_out.c +++ b/src/src/smtp_out.c @@ -163,12 +163,12 @@ if (getsockopt(sock, IPPROTO_TCP, TCP_INFO, &tinfo, &len) == 0) '# echo -n "00000000-00000000-00000000-0000000" >/proc/sys/net/ipv4/tcp_fastopen_key' The kernel seems to be counting unack'd packets. */ - case 1: + case TFO_ATTEMPTED: if (tinfo.tcpi_unacked > 1) { DEBUG(D_transport|D_v) debug_printf("TCP_FASTOPEN tcpi_unacked %d\n", tinfo.tcpi_unacked); - tcp_out_fastopen = 2; + tcp_out_fastopen = TFO_USED; } break; @@ -178,11 +178,11 @@ if (getsockopt(sock, IPPROTO_TCP, TCP_INFO, &tinfo, &len) == 0) /* If there was data-on-SYN but we had to retrasnmit it, declare no TFO */ - case 2: + case TFO_USED: if (!(tinfo.tcpi_options & TCPI_OPT_SYN_DATA)) { DEBUG(D_transport|D_v) debug_printf("TFO: had to retransmit\n"); - tcp_out_fastopen = 0; + tcp_out_fastopen = TFO_NOT_USED; } break; #endif diff --git a/src/src/structs.h b/src/src/structs.h index b1df408be..1ac455ca5 100644 --- a/src/src/structs.h +++ b/src/src/structs.h @@ -65,6 +65,10 @@ typedef enum { CHUNKING_NOT_OFFERED = -1, CHUNKING_ACTIVE, CHUNKING_LAST} chunking_state_t; +typedef enum { TFO_NOT_USED = 0, + TFO_ATTEMPTED, + TFO_USED } tfo_state_t; + /* Structure for holding information about a host for use mainly by routers, but also used when checking lists of hosts and when transporting. Looking up host addresses is done using this structure. */ diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index f3e09ada7..fba5a7ce8 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -2680,10 +2680,10 @@ for (addr = sx->first_addr, address_count = 0; BOOL no_flush; uschar * rcpt_addr; - if (tcp_out_fastopen && !f.tcp_out_fastopen_logged) + if (tcp_out_fastopen != TFO_NOT_USED && !f.tcp_out_fastopen_logged) { setflag(addr, af_tcp_fastopen_conn); - if (tcp_out_fastopen > 1) setflag(addr, af_tcp_fastopen); + if (tcp_out_fastopen >= TFO_USED) setflag(addr, af_tcp_fastopen); } addr->dsn_aware = sx->peer_offered & OPTION_DSN