Hi,

With the new large socket buffer sizes, syslogd could use more mbufs
for TCP or TLS connections than before.  It makes no sense to buffer
messages in kernel, the dynamic limit there makes testing the dropped
message statistics unreliable.  Syslog has no high performance
requirements, so limit all TCP socket buffers to 64 KB.

ok?

bluhm

Index: syslogd.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.213
diff -u -p -r1.213 syslogd.c
--- syslogd.c   21 Sep 2016 11:54:57 -0000      1.213
+++ syslogd.c   21 Sep 2016 23:22:08 -0000
@@ -343,6 +343,7 @@ int socket_bind(const char *, const char
     int *, int *);
 int    unix_socket(char *, int, mode_t);
 void   double_sockbuf(int, int);
+void   set_sockbuf(int);
 void   tailify_replytext(char *, int);
 
 int
@@ -886,6 +887,10 @@ socket_bind(const char *proto, const cha
                        *fdp = -1;
                        continue;
                }
+               if (!shutread && res->ai_protocol == IPPROTO_UDP)
+                       double_sockbuf(*fdp, SO_RCVBUF);
+               else if (res->ai_protocol == IPPROTO_TCP)
+                       set_sockbuf(*fdp);
                reuseaddr = 1;
                if (setsockopt(*fdp, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,
                    sizeof(reuseaddr)) == -1) {
@@ -916,8 +921,6 @@ socket_bind(const char *proto, const cha
                        *fdp = -1;
                        continue;
                }
-               if (!shutread && res->ai_protocol == IPPROTO_UDP)
-                       double_sockbuf(*fdp, SO_RCVBUF);
        }
 
        freeaddrinfo(res0);
@@ -1257,6 +1260,7 @@ tcp_socket(struct filed *f)
                logerror(ebuf);
                return (-1);
        }
+       set_sockbuf(s);
        if (connect(s, (struct sockaddr *)&f->f_un.f_forw.f_addr,
            f->f_un.f_forw.f_addr.ss_len) == -1 && errno != EINPROGRESS) {
                snprintf(ebuf, sizeof(ebuf), "connect \"%s\"",
@@ -2909,6 +2913,17 @@ double_sockbuf(int fd, int optname)
                if (setsockopt(fd, SOL_SOCKET, optname, &newsize, len) == -1)
                        logerror("setsockopt bufsize");
        }
+}
+
+void
+set_sockbuf(int fd)
+{
+       int size = 65536;
+
+       if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) == -1)
+               logerror("setsockopt sndbufsize");
+       if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) == -1)
+               logerror("setsockopt rcvbufsize");
 }
 
 void

Reply via email to