[exim-cvs] TFO: use enum for client status

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Exim Git Commits Mailing List
Fecha:  
A: exim-cvs
Asunto: [exim-cvs] TFO: use enum for client status
Gitweb: https://git.exim.org/exim.git/commitdiff/06e272a37fca29df8be58167a30818857a78e348
Commit:     06e272a37fca29df8be58167a30818857a78e348
Parent:     ae8f9024d8d4fad31457d758022e3186d782929c
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sat Oct 6 15:32:14 2018 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sat Oct 6 15:32:14 2018 +0100


    TFO: use enum for client status
---
 src/src/globals.c         | 2 +-
 src/src/globals.h         | 2 +-
 src/src/ip.c              | 4 ++--
 src/src/smtp_out.c        | 8 ++++----
 src/src/structs.h         | 4 ++++
 src/src/transports/smtp.c | 4 ++--
 6 files changed, 14 insertions(+), 10 deletions(-)


diff --git a/src/src/globals.c b/src/src/globals.c
index cdf00e8..fdeaebd 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 bdf0360..de0a7ba 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 633e0c2..ef133bf 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 62d4c73..f02863a 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 b1df408..1ac455c 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 f3e09ad..fba5a7c 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