gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r32465 - in libmicrohttpd: . doc src/include src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r32465 - in libmicrohttpd: . doc src/include src/microhttpd
Date: Mon, 24 Feb 2014 17:25:43 +0100

Author: harsha
Date: 2014-02-24 17:25:43 +0100 (Mon, 24 Feb 2014)
New Revision: 32465

Modified:
   libmicrohttpd/AUTHORS
   libmicrohttpd/doc/libmicrohttpd.texi
   libmicrohttpd/src/include/microhttpd.h
   libmicrohttpd/src/microhttpd/daemon.c
   libmicrohttpd/src/microhttpd/internal.h
Log:
Add support for TCP FASTOPEN connections.


Modified: libmicrohttpd/AUTHORS
===================================================================
--- libmicrohttpd/AUTHORS       2014-02-24 14:11:53 UTC (rev 32464)
+++ libmicrohttpd/AUTHORS       2014-02-24 16:25:43 UTC (rev 32465)
@@ -46,8 +46,8 @@
 Scott Goldman <address@hidden>
 Jared Cantwell
 Luke-Jr <address@hidden>
+Sree Harsha Totakura <address@hidden>
 
 Documentation contributions also came from:
 Marco Maggi <address@hidden>
 Sebastian Gerhardt <address@hidden>
-

Modified: libmicrohttpd/doc/libmicrohttpd.texi
===================================================================
--- libmicrohttpd/doc/libmicrohttpd.texi        2014-02-24 14:11:53 UTC (rev 
32464)
+++ libmicrohttpd/doc/libmicrohttpd.texi        2014-02-24 16:25:43 UTC (rev 
32465)
@@ -519,6 +519,12 @@
 additional pipes to be created, and code not using these calls should
 not pay the cost.
 
address@hidden MHD_USE_TCP_FASTOPEN
address@hidden listen
+Enable TCP_FASTOPEN on the listen socket.  TCP_FASTOPEN is currently
+supported on Linux >= 3.6.  On other systems using this option with
+cause @code{MHD_start_daemon} to fail.
+
 @end table
 @end deftp
 
@@ -831,6 +837,16 @@
 a value of zero means using the system default (which is likely to
 differ based on your platform).
 
address@hidden MHD_OPTION_TCP_FASTQUEUE_QUEUE_SIZE
address@hidden listen
+When the flag @code{MHD_USE_TCP_FASTOPEN} is used, this option sets the
+connection handshake queue size for the TCP FASTOPEN connections.  Note
+that a TCP FASTOPEN connection handshake occupies more resources than a
+TCP handshake as the SYN packets also contain DATA which is kept in the
+associate state until handshake is completed.  If this option is not
+given the queue size is set to a default value of 10.  This option must
+be followed by a @code{unsigned int}.
+
 @end table
 @end deftp
 

Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h      2014-02-24 14:11:53 UTC (rev 
32464)
+++ libmicrohttpd/src/include/microhttpd.h      2014-02-24 16:25:43 UTC (rev 
32465)
@@ -551,8 +551,15 @@
    * Enable suspend/resume functions, which also implies setting up
    * pipes to signal resume.
    */
-  MHD_USE_SUSPEND_RESUME = 8192 | MHD_USE_PIPE_FOR_SHUTDOWN
+  MHD_USE_SUSPEND_RESUME = 8192 | MHD_USE_PIPE_FOR_SHUTDOWN,
 
+  /**
+   * Enable TCP_FASTOPEN option.  This option is only available on Linux with a
+   * kernel >= 3.6.  On other systems, using this option cases 
#MHD_start_daemon
+   * to fail.
+   */
+  MHD_USE_TCP_FASTOPEN = 16384
+
 };
 
 
@@ -817,8 +824,17 @@
    * to access the SNI data using `gnutls_server_name_get()`.
    * Using this option requires GnuTLS 3.0 or higher.
    */
-  MHD_OPTION_HTTPS_CERT_CALLBACK = 22
+  MHD_OPTION_HTTPS_CERT_CALLBACK = 22,
 
+  /**
+   * When using #MHD_USE_TCP_FASTOPEN, this option changes the default TCP
+   * fastopen queue length of 50.  Note that having a larger queue size can
+   * cause resource exhaustion attack as the TCP stack has to now allocate
+   * resources for the SYN packet along with its DATA.  This option should be
+   * followed by an `unsigned int` argument.
+   */
+  MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE = 23
+
 };
 
 

Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c       2014-02-24 14:11:53 UTC (rev 
32464)
+++ libmicrohttpd/src/microhttpd/daemon.c       2014-02-24 16:25:43 UTC (rev 
32465)
@@ -75,7 +75,14 @@
  */
 #define MHD_POOL_SIZE_DEFAULT (32 * 1024)
 
+#ifdef TCP_FASTOPEN
 /**
+ * Default TCP fastopen queue size.
+ */
+#define MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT 10
+#endif
+
+/**
  * Print extra messages with reasons for closing
  * sockets? (only adds non-error messages).
  */
@@ -2957,6 +2964,11 @@
         case MHD_OPTION_THREAD_STACK_SIZE:
           daemon->thread_stack_size = va_arg (ap, size_t);
           break;
+#ifdef TCP_FASTOPEN
+        case MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE:
+          daemon->fastopen_queue_size = va_arg (ap, unsigned int);
+          break;
+#endif
        case MHD_OPTION_ARRAY:
          oa = va_arg (ap, struct MHD_OptionItem*);
          i = 0;
@@ -2981,6 +2993,7 @@
                case MHD_OPTION_CONNECTION_TIMEOUT:
                case MHD_OPTION_PER_IP_CONNECTION_LIMIT:
                case MHD_OPTION_THREAD_POOL_SIZE:
+                case MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE:
                  if (MHD_YES != parse_options (daemon,
                                                servaddr,
                                                opt,
@@ -3229,6 +3242,10 @@
   if (0 != (flags & MHD_USE_SSL))
     return NULL;
 #endif
+#ifndef TCP_FASTOPEN
+  if (0 != (flags & MHD_USE_TCP_FASTSEND))
+    return NULL;
+#endif
   if (NULL == dh)
     return NULL;
   if (NULL == (daemon = malloc (sizeof (struct MHD_Daemon))))
@@ -3541,6 +3558,24 @@
            MHD_PANIC ("close failed\n");
          goto free_and_fail;
        }
+#ifdef TCP_FASTOPEN
+      if (0 != (flags & MHD_USE_TCP_FASTOPEN))
+      {
+        if (0 == daemon->fastopen_queue_size)
+          daemon->fastopen_queue_size = MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT;
+        if (0 != setsockopt (socket_fd,
+                             IPPROTO_TCP, TCP_FASTOPEN,
+                             &daemon->fastopen_queue_size,
+                             sizeof (daemon->fastopen_queue_size)))
+        {
+#if HAVE_MESSAGES
+          MHD_DLOG (daemon,
+                    "setsockopt failed: %s\n",
+                    MHD_socket_last_strerr_ ());
+#endif
+        }
+      }
+#endif
 #if EPOLL_SUPPORT
       if (0 != (flags & MHD_USE_EPOLL_LINUX_ONLY))
        {

Modified: libmicrohttpd/src/microhttpd/internal.h
===================================================================
--- libmicrohttpd/src/microhttpd/internal.h     2014-02-24 14:11:53 UTC (rev 
32464)
+++ libmicrohttpd/src/microhttpd/internal.h     2014-02-24 16:25:43 UTC (rev 
32465)
@@ -39,6 +39,10 @@
 #if EPOLL_SUPPORT
 #include <sys/epoll.h>
 #endif
+#if HAVE_NETINET_TCP_H
+/* for TCP_FASTOPEN */
+#include <netinet/tcp.h>
+#endif
 
 
 /**
@@ -1228,6 +1232,12 @@
 
 #endif
 
+#ifdef TCP_FASTOPEN
+  /**
+   * The queue size for incoming SYN + DATA packets.
+   */
+  unsigned int fastopen_queue_size;
+#endif
 };
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]