From 4c068d6c51cbc9b820008b37570fa23df72a8a48 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Thu, 22 Sep 2016 01:16:30 +0000 Subject: Call setsockopt(2) before listen(2) in relayd tests and adjust some error messages. --- regress/usr.sbin/relayd/Client.pm | 10 +++++----- regress/usr.sbin/relayd/Server.pm | 15 ++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/regress/usr.sbin/relayd/Client.pm b/regress/usr.sbin/relayd/Client.pm index 854b912fe21..b3e011de13d 100644 --- a/regress/usr.sbin/relayd/Client.pm +++ b/regress/usr.sbin/relayd/Client.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Client.pm,v 1.11 2015/07/18 22:11:34 benno Exp $ +# $OpenBSD: Client.pm,v 1.12 2016/09/22 01:16:29 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm # @@ -61,22 +61,22 @@ sub child { if ($self->{sndbuf}) { setsockopt($cs, SOL_SOCKET, SO_SNDBUF, pack('i', $self->{sndbuf})) - or die ref($self), " set sndbuf listen failed: $!"; + or die ref($self), " set SO_SNDBUF failed: $!"; } if ($self->{rcvbuf}) { setsockopt($cs, SOL_SOCKET, SO_RCVBUF, pack('i', $self->{rcvbuf})) - or die ref($self), " set rcvbuf listen failed: $!"; + or die ref($self), " set SO_SNDBUF failed: $!"; } if ($self->{sndtimeo}) { setsockopt($cs, SOL_SOCKET, SO_SNDTIMEO, pack('l!l!', $self->{sndtimeo}, 0)) - or die ref($self), " set SO_SNDTIMEO failed failed: $!"; + or die ref($self), " set SO_SNDTIMEO failed: $!"; } if ($self->{rcvtimeo}) { setsockopt($cs, SOL_SOCKET, SO_RCVTIMEO, pack('l!l!', $self->{rcvtimeo}, 0)) - or die ref($self), " set SO_RCVTIMEO failed failed: $!"; + or die ref($self), " set SO_RCVTIMEO failed: $!"; } print STDERR "connect sock: ",$cs->sockhost()," ",$cs->sockport(),"\n"; diff --git a/regress/usr.sbin/relayd/Server.pm b/regress/usr.sbin/relayd/Server.pm index 22d2855a284..5ada2f91833 100644 --- a/regress/usr.sbin/relayd/Server.pm +++ b/regress/usr.sbin/relayd/Server.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Server.pm,v 1.10 2016/08/25 22:56:13 bluhm Exp $ +# $OpenBSD: Server.pm,v 1.11 2016/09/22 01:16:29 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm # @@ -41,35 +41,36 @@ sub new { Proto => "tcp", ReuseAddr => 1, Domain => $self->{listendomain}, - Listen => 1, $self->{listenaddr} ? (LocalAddr => $self->{listenaddr}) : (), $self->{listenport} ? (LocalPort => $self->{listenport}) : (), SSL_key_file => "server.key", SSL_cert_file => "server.crt", SSL_verify_mode => SSL_VERIFY_NONE, - ) or die ref($self), " $iosocket socket listen failed: $!,$SSL_ERROR"; + ) or die ref($self), " $iosocket socket failed: $!,$SSL_ERROR"; if ($self->{sndbuf}) { setsockopt($ls, SOL_SOCKET, SO_SNDBUF, pack('i', $self->{sndbuf})) - or die ref($self), " set sndbuf SO_SNDBUF failed: $!"; + or die ref($self), " set SO_SNDBUF failed: $!"; } if ($self->{rcvbuf}) { setsockopt($ls, SOL_SOCKET, SO_RCVBUF, pack('i', $self->{rcvbuf})) - or die ref($self), " set rcvbuf SO_RCVBUF failed: $!"; + or die ref($self), " set SO_RCVBUF failed: $!"; } my $packstr = $Config{longsize} == 8 ? 'ql!' : $Config{byteorder} == 1234 ? 'lxxxxl!' : 'xxxxll!'; if ($self->{sndtimeo}) { setsockopt($ls, SOL_SOCKET, SO_SNDTIMEO, pack($packstr, $self->{sndtimeo}, 0)) - or die ref($self), " set SO_SNDTIMEO failed failed: $!"; + or die ref($self), " set SO_SNDTIMEO failed: $!"; } if ($self->{rcvtimeo}) { setsockopt($ls, SOL_SOCKET, SO_RCVTIMEO, pack($packstr, $self->{rcvtimeo}, 0)) - or die ref($self), " set SO_RCVTIMEO failed failed: $!"; + or die ref($self), " set SO_RCVTIMEO failed: $!"; } + listen($ls, 1) + or die ref($self), " socket listen failed: $!"; my $log = $self->{log}; print $log "listen sock: ",$ls->sockhost()," ",$ls->sockport(),"\n"; $self->{listenaddr} = $ls->sockhost() unless $self->{listenaddr}; -- cgit v1.2.3