Forward port SOCKSENDBUF, SOCKRECVBUF features from 2.10.11.
authorMichael Poole <mdpoole@troilus.org>
Sat, 15 May 2004 14:44:58 +0000 (14:44 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 15 May 2004 14:44:58 +0000 (14:44 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1049 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

12 files changed:
ChangeLog
doc/readme.features
include/ircd_features.h
include/ircd_osdep.h
ircd/ircd_features.c
ircd/listener.c
ircd/os_bsd.c
ircd/os_generic.c
ircd/os_linux.c
ircd/os_openbsd.c
ircd/os_solaris.c
ircd/s_bsd.c

index 075f77a6c319a2840687df7630bf953d95b7b008..4a7b9328169423ec73b5cb683c531c9d169c74ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-05-15  Isomer <isomer@undernet.org>
+
+       [Original ChangeLog date: 2003-11-23 -MDP]
+       
+       * ircd/os_*.c, ircd/ircd_features.c: Default changing window sizes
+       to off.  if an admin is smart enough to understand these features
+       they can enable them manually.
+
 2004-05-15  Isomer <isomer@undernet.org>
 
        [Original ChangeLog date: 2003-11-18 -MDP]
index b30202e41cb5ff6e05e11cbbc30c5c129cc85b93..eaa96785b6880e531388f37f8ef525c9c4e0899e 100644 (file)
@@ -1131,3 +1131,15 @@ code kicks in.  Even if a user connects repeditively during this period,
 they will never get throttled.  This is so after a restart users on a 
 multiuser box can all connect to a server simultaniously without being 
 considered an attack.
+
+SOCKSENDBUF
+ * Type: integer
+ * Default: 0
+
+The send window size used for connections to other servers.
+
+SOCKRECVBUF
+ * Type: integer
+ * Default: 0
+
+The receive window size used for connections to other servers.
index 0c6275e9484319baacf58f3cafa9cc28106d3560..533e3802e75019cbcc636f9fe258d8f00f8a5311 100644 (file)
@@ -68,6 +68,8 @@ enum Feature {
   FEAT_CONNECTFREQUENCY,
   FEAT_DEFAULTMAXSENDQLENGTH,
   FEAT_GLINEMAXUSERCOUNT,
+  FEAT_SOCKSENDBUF,
+  FEAT_SOCKRECVBUF,
   FEAT_IPCHECK_CLONE_LIMIT,
   FEAT_IPCHECK_CLONE_PERIOD,
   FEAT_IPCHECK_CLONE_DELAY,
index 2f9e4633e894dd57520b5b1db6df572dfb7d7f1f..8639e721a5e328dac609895c1e665b9229b13f9b 100644 (file)
@@ -42,7 +42,7 @@ extern int os_set_fdlimit(unsigned int max_descriptors);
 extern int os_set_listen(int fd, int backlog);
 extern int os_set_nonblocking(int fd);
 extern int os_set_reuseaddr(int fd);
-extern int os_set_sockbufs(int fd, unsigned int size);
+extern int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize);
 extern int os_set_tos(int fd,int tos);
 
 #endif /* INCLUDED_ircd_osdep_h */
index 9a3c592f32f7fb63ea1298736e69499070ee7d2e..1ccef6891d216423ec8f949d8d6f9bd83de75262 100644 (file)
@@ -274,6 +274,8 @@ static struct FeatureDesc {
   F_I(CONNECTFREQUENCY, 0, 600, init_class),
   F_I(DEFAULTMAXSENDQLENGTH, 0, 40000, init_class),
   F_I(GLINEMAXUSERCOUNT, 0, 20, 0),
+  F_I(SOCKSENDBUF, 0, 0, 0),
+  F_I(SOCKRECVBUF, 0, 0, 0),
   F_I(IPCHECK_CLONE_LIMIT, 0, 4, 0),
   F_I(IPCHECK_CLONE_PERIOD, 0, 40, 0),
   F_I(IPCHECK_CLONE_DELAY, 0, 600, 0),
index 42ee4bdca21d53288edbd1d3d649b2d9af7e4379..6b67d0ca8a0f1c9a80e0b642f19e29805ffd5c51 100644 (file)
@@ -210,7 +210,9 @@ static int inetport(struct Listener* listener)
    * else has no effect whatsoever on the connection.
    * NOTE: this must be set before listen is called
    */
-  if (!os_set_sockbufs(fd, (listener->server) ? SERVER_TCP_WINDOW : CLIENT_TCP_WINDOW)) {
+  if (!os_set_sockbufs(fd,
+                       (listener->server) ? feature_int(FEAT_SOCKSENDBUF) : CLIENT_TCP_WINDOW,
+                       (listener->server) ? feature_int(FEAT_SOCKRECVBUF) : CLIENT_TCP_WINDOW)) {
     report_error(SETBUFS_ERROR_MSG, get_listener_name(listener), errno);
     close(fd);
     return 0;
index 9a052d2f5ea6092b22fabb75afa0d33c68dc643a..09850d940756bcde784fa2c2af90116a260e2f13 100644 (file)
@@ -209,13 +209,14 @@ int os_set_reuseaddr(int fd)
                           (const char*) &opt, sizeof(opt)));
 }
 
-int os_set_sockbufs(int fd, unsigned int size)
+int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize)
 {
-  unsigned int opt = size;
+  unsigned int sopt = ssize;
+  unsigned int ropt = rsize;
   return (0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, 
-                          (const char*) &opt, sizeof(opt)) &&
+                          (const char*) &ropt, sizeof(ropt)) &&
           0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 
-                          (const char*) &opt, sizeof(opt)));
+                          (const char*) &sopt, sizeof(sopt)));
 }
 
 int os_set_tos(int fd,int tos)
index b996ecd66c80ea5b94e483cfac46dbc4742fd18b..2dbde7e727a5124b58c24421423325da583ba403 100644 (file)
@@ -211,13 +211,14 @@ int os_set_reuseaddr(int fd)
                           (const char*) &opt, sizeof(opt)));
 }
 
-int os_set_sockbufs(int fd, unsigned int size)
+int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize)
 {
-  unsigned int opt = size;
+  unsigned int sopt = ssize;
+  unsigned int ropt = rsize;
   return (0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, 
-                          (const char*) &opt, sizeof(opt)) &&
+                          (const char*) &ropt, sizeof(ropt)) &&
           0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 
-                          (const char*) &opt, sizeof(opt)));
+                          (const char*) &sopt, sizeof(sopt)));
 }
 
 int os_set_tos(int fd,int tos)
index 9ea434b580a802415543734702f0e2c529269410..2c24bb106806df0be6a055cb610384089e6802f6 100644 (file)
@@ -40,9 +40,7 @@
 #include <sys/times.h>
 #include <sys/uio.h>
 #include <sys/param.h>
-#if 0
 #include <unistd.h>
-#endif
 
 /*
  * This is part of the STATS replies. There is no offical numeric for this
@@ -152,11 +150,14 @@ int os_set_reuseaddr(int fd)
   return (0 == setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)));
 }
 
-int os_set_sockbufs(int fd, unsigned int size)
+int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize)
 {
-  unsigned int opt = size;
-  return (0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt)) &&
-          0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)));
+  unsigned int sopt = ssize;
+  unsigned int ropt = rsize;
+  return (0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, 
+                          (const char*) &ropt, sizeof(ropt)) &&
+          0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 
+                          (const char*) &sopt, sizeof(sopt)));
 }
 
 int os_set_tos(int fd,int tos)
index bf02113f38481cdb764df4abe6ca1600bf5206b3..27c5ded8c1cbec2ecc4a57dffa3e08eb52ceef28 100644 (file)
@@ -216,13 +216,14 @@ int os_set_reuseaddr(int fd)
                           (const char*) &opt, sizeof(opt)));
 }
 
-int os_set_sockbufs(int fd, unsigned int size)
+int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize)
 {
-  unsigned int opt = size;
+  unsigned int sopt = ssize;
+  unsigned int ropt = rsize;
   return (0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, 
-                          (const char*) &opt, sizeof(opt)) &&
+                          (const char*) &ropt, sizeof(ropt)) &&
           0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 
-                          (const char*) &opt, sizeof(opt)));
+                          (const char*) &sopt, sizeof(sopt)));
 }
 
 int os_set_tos(int fd,int tos)
index c94fd3845bb70a862665ad0e0f79b408859ffd84..9452c0c77133545d9438aaedb8579c2d2ea6f3c3 100644 (file)
@@ -125,13 +125,14 @@ int os_set_reuseaddr(int fd)
                           (const char*) &opt, sizeof(opt)));
 }
 
-int os_set_sockbufs(int fd, unsigned int size)
+int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize)
 {
-  unsigned int opt = size;
+  unsigned int sopt = ssize;
+  unsigned int ropt = rsize;
   return (0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, 
-                          (const char*) &opt, sizeof(opt)) &&
+                          (const char*) &ropt, sizeof(ropt)) &&
           0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 
-                          (const char*) &opt, sizeof(opt)));
+                          (const char*) &sopt, sizeof(sopt)));
 }
 
 int os_set_tos(int fd,int tos)
index 1b756a61d838b3f9ef4b26cebcde3e549b32b2d5..27d66901f0418abc6de1a29c78445a1bcca98b61 100644 (file)
@@ -290,7 +290,7 @@ static int connect_inet(struct ConfItem* aconf, struct Client* cptr)
   /*
    * we want a big buffer for server connections
    */
-  if (!os_set_sockbufs(cli_fd(cptr), SERVER_TCP_WINDOW)) {
+  if (!os_set_sockbufs(cli_fd(cptr), feature_int(FEAT_SOCKSENDBUF), feature_int(FEAT_SOCKRECVBUF))) {
     cli_error(cptr) = errno;
     report_error(SETBUFS_ERROR_MSG, cli_name(cptr), errno);
     close(cli_fd(cptr));