summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2015-07-20 18:03:48 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2015-07-20 18:03:48 +0000
commit0e46e726124cd6a6c42e188b188226681e21a3dc (patch)
tree1413a785344e5079184fba9cbe3af9898b06379a /regress
parent6dcc258a2b9466898e7381617526275b57fc8812 (diff)
Test what happens when syslogd reaches its file descriptor limit
and cannot accept TCP connections anymore.
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.sbin/syslogd/args-client-tcp-deferred.pl65
-rw-r--r--regress/usr.sbin/syslogd/args-fdexhaustion-tcp.pl48
-rw-r--r--regress/usr.sbin/syslogd/args-maxtcp.pl79
3 files changed, 113 insertions, 79 deletions
diff --git a/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl b/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl
new file mode 100644
index 00000000000..f876f812d5c
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-client-tcp-deferred.pl
@@ -0,0 +1,65 @@
+# The syslogd listens on 127.0.0.1 TCP socket.
+# The client creates connections to syslogd TCP socket until it blocks.
+# The client writes to all sockets and closes them.
+# Wait until syslogd has slots to accept all sockets.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check the messages end up in the log file.
+
+use strict;
+use warnings;
+use IO::Socket::INET6;
+
+our %args = (
+ client => {
+ connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1",
+ port => 514 },
+ func => sub {
+ my $self = shift;
+ local $| = 1;
+ my @s;
+ $s[0] = \*STDOUT;
+ # open additional connections until syslogd deferres
+ for (my $i = 1; $i <= 30; $i++) {
+ $s[$i] = IO::Socket::INET6->new(
+ Domain => AF_INET,
+ Proto => "tcp",
+ PeerAddr => "127.0.0.1",
+ PeerPort => 514,
+ ) or die "id $i tcp socket connect failed: $!";
+ print STDERR "<<< id $i tcp connected\n";
+ ${$self->{syslogd}}->loggrep("tcp logger .* accepted", 1, $i);
+ ${$self->{syslogd}}->loggrep("accept deferred")
+ and last;
+ }
+ write_tcp($self, \*STDOUT, 0);
+ for (my $i = 1; $i < @s; $i++) {
+ my $fh = $s[$i];
+ write_tcp($self, $fh, $i);
+ # close connection so that others can be accepted
+ close($fh);
+ }
+ ${$self->{syslogd}}->loggrep(qr/tcp logger .* use \d+ bytes/, 10,
+ scalar @s)
+ or die ref($self), " syslogd did not use connections";
+ write_shutdown($self);
+ },
+ },
+ syslogd => {
+ options => ["-T", "127.0.0.1:514"],
+ rlimit => {
+ RLIMIT_NOFILE => 30,
+ },
+ loggrep => {
+ qr/tcp logger .* accepted/ => '>=10',
+ qr/tcp logger .* use \d+ bytes/ => '>=10',
+ qr/tcp logger .* connection close/ => '>=10',
+ },
+ },
+ file => {
+ loggrep => {
+ get_testgrep() => '>=10',
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-fdexhaustion-tcp.pl b/regress/usr.sbin/syslogd/args-fdexhaustion-tcp.pl
new file mode 100644
index 00000000000..00d23339f1d
--- /dev/null
+++ b/regress/usr.sbin/syslogd/args-fdexhaustion-tcp.pl
@@ -0,0 +1,48 @@
+# The syslogd is started with reduced file descriptor limits.
+# The syslogd config contains more log files than possible.
+# The client connects to the 127.0.0.1 TCP socket, but is not accepted.
+# Check the error messages and that syslogd tries to listen again.
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1",
+ port => 514 },
+ logsock => { type => "tcp", host => "127.0.0.1", port => 514 },
+ func => sub {
+ my $self = shift;
+ ${$self->{syslogd}}->loggrep("Listen again", 5);
+ write_log($self);
+ },
+ },
+ syslogd => {
+ options => ["-T", "127.0.0.1:514"],
+ conf => join("", map { "*.*\t\$objdir/file-$_.log\n" } 0..19),
+ rlimit => {
+ RLIMIT_NOFILE => 30,
+ },
+ loggrep => {
+ qr/syslogd: receive_fd: recvmsg: Message too long/ => 5,
+ # One file is opened by test default config, 20 by multifile.
+ qr/X FILE:/ => 1+15,
+ qr/X UNUSED:/ => 5,
+ qr/Accepting tcp connection/ => 0,
+ qr/Listen again/ => '>=1',
+ },
+ },
+ server => {
+ loggrep => { get_testlog() => 0 },
+ },
+ multifile => [
+ (map { { loggrep => qr/syslogd: accept deferred/ } } 0..14),
+ (map { { loggrep => { qr/./s => 0 } } } 15..19),
+ ],
+ file => {
+ loggrep => qr/syslogd: accept deferred: Too many open files/,
+ },
+ pipe => { loggrep => {} },
+);
+
+1;
diff --git a/regress/usr.sbin/syslogd/args-maxtcp.pl b/regress/usr.sbin/syslogd/args-maxtcp.pl
deleted file mode 100644
index 9044bd36e89..00000000000
--- a/regress/usr.sbin/syslogd/args-maxtcp.pl
+++ /dev/null
@@ -1,79 +0,0 @@
-# The syslogd listens on 127.0.0.1 TCP socket.
-# The client creates MAXTCP connections to syslogd TCP socket.
-# The syslogd writes it into a file and through a pipe.
-# The syslogd passes it via UDP to the loghost.
-# The server receives the message on its UDP socket.
-# Find the message in client, file, pipe, syslogd, server log.
-# Check that an additional connection gets denied by syslogd.
-# Check that close and reopen a connection succeeds.
-# Check that every connection transfers a message.
-
-use strict;
-use warnings;
-use IO::Socket::INET6;
-use constant MAXTCP => 20;
-
-our %args = (
- client => {
- connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1",
- port => 514 },
- func => sub {
- my $self = shift;
- local $| = 1;
- my @s;
- $s[0] = \*STDOUT;
- # open all additional connections and one more
- for (my $i = 1; $i <= MAXTCP; $i++) {
- $s[$i] = IO::Socket::INET6->new(
- Domain => AF_INET,
- Proto => "tcp",
- PeerAddr => "127.0.0.1",
- PeerPort => 514,
- ) or die "tcp socket $i connect failed: $!";
- }
- # the last connection was denied
- defined $s[MAXTCP]->getline()
- and die "MAXTCP connection not closed by syslogd\n";
- # close and reopen a single connection
- close($s[1])
- or die "tcp socket 1 close failed: $!";
- ${$self->{syslogd}}->loggrep("tcp logger .* connection close", 5)
- or die ref($self), " syslogd did not close connection";
- $s[1] = IO::Socket::INET6->new(
- Domain => AF_INET,
- Proto => "tcp",
- PeerAddr => "127.0.0.1",
- PeerPort => 514,
- ) or die "tcp socket 1 connect again failed: $!";
- # write messages over all connections
- for (my $i = 0; $i < MAXTCP; $i++) {
- my $fh = $s[$i];
- write_tcp($self, $fh, $i);
- }
- ${$self->{syslogd}}->loggrep(qr/tcp logger .* use \d+ bytes/, 5,
- MAXTCP) or die ref($self), " syslogd did not use all messages";
- write_shutdown($self);
- },
- },
- syslogd => {
- options => ["-T", "127.0.0.1:514"],
- fstat => {
- qr/^root .* internet/ => 0,
- qr/^_syslogd .* internet/ => 3,
- qr/ internet6? stream tcp \w+ (127.0.0.1|\[::1\]):514$/ => 1,
- },
- loggrep => {
- qr/tcp logger .* accepted/ => MAXTCP+1,
- qr/tcp logger .* denied: maximum /.MAXTCP.qr/ reached/ => 1,
- },
- },
- file => {
- loggrep => {
- qr/ localhost .* tcp socket: /.get_testgrep() => MAXTCP,
- (map { " $_ tcp socket: ".get_testgrep() => 1 } 0..MAXTCP-1),
- MAXTCP." tcp socket: ".get_testgrep() => 0,
- },
- },
-);
-
-1;