From 6fd1d0a6b05c9ce67ccf96ac230bf028d83b2de9 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sat, 15 May 2004 14:44:58 +0000 Subject: [PATCH 1/1] Forward port SOCKSENDBUF, SOCKRECVBUF features from 2.10.11. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1049 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 8 ++++++++ doc/readme.features | 12 ++++++++++++ include/ircd_features.h | 2 ++ include/ircd_osdep.h | 2 +- ircd/ircd_features.c | 2 ++ ircd/listener.c | 4 +++- ircd/os_bsd.c | 9 +++++---- ircd/os_generic.c | 9 +++++---- ircd/os_linux.c | 13 +++++++------ ircd/os_openbsd.c | 9 +++++---- ircd/os_solaris.c | 9 +++++---- ircd/s_bsd.c | 2 +- 12 files changed, 56 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 075f77a..4a7b932 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-05-15 Isomer + + [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 [Original ChangeLog date: 2003-11-18 -MDP] diff --git a/doc/readme.features b/doc/readme.features index b30202e..eaa9678 100644 --- a/doc/readme.features +++ b/doc/readme.features @@ -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. diff --git a/include/ircd_features.h b/include/ircd_features.h index 0c6275e..533e380 100644 --- a/include/ircd_features.h +++ b/include/ircd_features.h @@ -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, diff --git a/include/ircd_osdep.h b/include/ircd_osdep.h index 2f9e463..8639e72 100644 --- a/include/ircd_osdep.h +++ b/include/ircd_osdep.h @@ -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 */ diff --git a/ircd/ircd_features.c b/ircd/ircd_features.c index 9a3c592..1ccef68 100644 --- a/ircd/ircd_features.c +++ b/ircd/ircd_features.c @@ -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), diff --git a/ircd/listener.c b/ircd/listener.c index 42ee4bd..6b67d0c 100644 --- a/ircd/listener.c +++ b/ircd/listener.c @@ -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; diff --git a/ircd/os_bsd.c b/ircd/os_bsd.c index 9a052d2..09850d9 100644 --- a/ircd/os_bsd.c +++ b/ircd/os_bsd.c @@ -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) diff --git a/ircd/os_generic.c b/ircd/os_generic.c index b996ecd..2dbde7e 100644 --- a/ircd/os_generic.c +++ b/ircd/os_generic.c @@ -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) diff --git a/ircd/os_linux.c b/ircd/os_linux.c index 9ea434b..2c24bb1 100644 --- a/ircd/os_linux.c +++ b/ircd/os_linux.c @@ -40,9 +40,7 @@ #include #include #include -#if 0 #include -#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) diff --git a/ircd/os_openbsd.c b/ircd/os_openbsd.c index bf02113..27c5ded 100644 --- a/ircd/os_openbsd.c +++ b/ircd/os_openbsd.c @@ -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) diff --git a/ircd/os_solaris.c b/ircd/os_solaris.c index c94fd38..9452c0c 100644 --- a/ircd/os_solaris.c +++ b/ircd/os_solaris.c @@ -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) diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index 1b756a6..27d6690 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -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)); -- 2.20.1