diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-09-23 13:13:14 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-09-23 13:13:14 +0000 |
commit | 2d09d6874ddf050a9ae6ccf586e4839e34752c8f (patch) | |
tree | 9c848f9343007772189995f3791bd012960f39dd | |
parent | 423545f214750ef4494a2a87ee876d5deb2dafdd (diff) |
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 henning@ deraadt@
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 23de4e501a9..29747fc8b80 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.213 2016/09/21 11:54:57 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.214 2016/09/23 13:13:13 bluhm Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -343,6 +343,7 @@ int socket_bind(const char *, const char *, const char *, int, 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 char *host, const char *port, *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 char *host, const char *port, *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\"", @@ -2912,6 +2916,17 @@ double_sockbuf(int fd, int optname) } 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 ctlconn_cleanup(void) { struct filed *f; |