diff options
Diffstat (limited to 'regress/sys/net')
-rw-r--r-- | regress/sys/net/pf_divert/Makefile | 4 | ||||
-rw-r--r-- | regress/sys/net/pf_divert/Remote.pm | 18 | ||||
-rw-r--r-- | regress/sys/net/pf_divert/remote.pl | 18 |
3 files changed, 31 insertions, 9 deletions
diff --git a/regress/sys/net/pf_divert/Makefile b/regress/sys/net/pf_divert/Makefile index ee2d7f5dcf6..e5350132921 100644 --- a/regress/sys/net/pf_divert/Makefile +++ b/regress/sys/net/pf_divert/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.13 2016/09/02 21:30:34 bluhm Exp $ +# $OpenBSD: Makefile,v 1.14 2016/11/15 16:00:50 bluhm Exp $ # The following ports must be installed for the regression tests: # p5-IO-Socket-INET6 object interface for AF_INET and AF_INET6 domain sockets @@ -109,7 +109,7 @@ PERLPATH = ${.CURDIR}/ .for a in ${ARGS} run-regress-${inet}-${a:R}: ${a} @echo '\n======== $@ ========' - time ${SUDO} SUDO=${SUDO} perl ${PERLINC} ${PERLPATH}remote.pl ${inet} ${LOCAL_${addr}} ${FAKE_${addr}} ${REMOTE_SSH} ${PERLPATH}${a} + time ${SUDO} SUDO=${SUDO} perl ${PERLINC} ${PERLPATH}remote.pl -f ${inet} ${LOCAL_${addr}} ${FAKE_${addr}} ${REMOTE_SSH} ${PERLPATH}${a} .endfor .for proto in tcp udp rip diff --git a/regress/sys/net/pf_divert/Remote.pm b/regress/sys/net/pf_divert/Remote.pm index 13ea67dedc1..41b2709128a 100644 --- a/regress/sys/net/pf_divert/Remote.pm +++ b/regress/sys/net/pf_divert/Remote.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Remote.pm,v 1.6 2016/05/03 19:13:04 bluhm Exp $ +# $OpenBSD: Remote.pm,v 1.7 2016/11/15 16:00:50 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -64,14 +64,24 @@ sub up { sub child { my $self = shift; + my @remoteopts; + + if ($self->{opts}) { + my %opts = %{$self->{opts}}; + foreach my $k (sort keys %opts) { + push @remoteopts, "-$k"; + my $v = $opts{$k}; + push @remoteopts, $v if $k =~ /[A-Z]/ or $v ne 1; + } + } print STDERR $self->{up}, "\n"; - my @opts = $ENV{SSH_OPTIONS} ? split(' ', $ENV{SSH_OPTIONS}) : (); + my @sshopts = $ENV{SSH_OPTIONS} ? split(' ', $ENV{SSH_OPTIONS}) : (); my @sudo = $ENV{SUDO} ? ($ENV{SUDO}, "SUDO=$ENV{SUDO}") : (); my $dir = dirname($0); $dir = getcwd() if ! $dir || $dir eq "."; - my @cmd = ("ssh", "-n", @opts, $self->{remotessh}, @sudo, "perl", - "-I", $dir, "$dir/".basename($0), $self->{af}, + my @cmd = ("ssh", "-n", @sshopts, $self->{remotessh}, @sudo, "perl", + "-I", $dir, "$dir/".basename($0), @remoteopts, $self->{af}, $self->{bindaddr}, $self->{connectaddr}, $self->{connectport}, ($self->{bindport} ? $self->{bindport} : ()), ($self->{testfile} ? "$dir/".basename($self->{testfile}) : ())); diff --git a/regress/sys/net/pf_divert/remote.pl b/regress/sys/net/pf_divert/remote.pl index 2cddecd7b0d..263cefd320b 100644 --- a/regress/sys/net/pf_divert/remote.pl +++ b/regress/sys/net/pf_divert/remote.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: remote.pl,v 1.6 2015/07/28 12:31:29 bluhm Exp $ +# $OpenBSD: remote.pl,v 1.7 2016/11/15 16:00:50 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org> # @@ -26,6 +26,7 @@ BEGIN { use File::Basename; use File::Copy; +use Getopt::Std; use Socket; use Socket6; @@ -46,6 +47,7 @@ usage: started automatically with ssh on remotessh. remote.pl af localaddr fakeaddr remotessh clientport serverport test-args.pl Run test with local client and server and fixed port, needed for reuse. + -f flush regress states EOF } @@ -57,6 +59,8 @@ if (@ARGV) { do $test or die "Do test file $test failed: ", $@ || $!; } +my %opts; +getopts("f", \%opts) or usage(); my($af, $domain, $protocol); if (@ARGV) { $af = shift; @@ -114,6 +118,7 @@ if ($local eq "server") { if ($mode eq "auto") { $r = Remote->new( %args, + opts => \%opts, logfile => "$remote.log", testfile => $test, af => $af, @@ -169,16 +174,23 @@ if ($mode eq "divert") { my $divertport = $port || "port 1"; # XXX bad pf syntax print $pf "pass in log $af proto $protocol ". "from $ARGV[1] to $ARGV[0] $port ". - "divert-to $s->{listenaddr} $divertport\n"; + "divert-to $s->{listenaddr} $divertport ". + "label regress\n"; } else { my $port = $protocol =~ /^(tcp|udp)$/ ? "port $ARGV[2]" : ""; print $pf "pass out log $af proto $protocol ". - "from $c->{bindaddr} to $ARGV[1] $port divert-reply\n"; + "from $c->{bindaddr} to $ARGV[1] $port divert-reply ". + "label regress\n"; } close($pf) or die $! ? "Close pipe to pf '@cmd' failed: $!" : "pf '@cmd' failed: $?"; + if ($opts{f}) { + @cmd = qw(pfctl -k label -k regress); + do { local $> = 0; system(@cmd) } + and die "Execute '@cmd' failed: $!"; + } print STDERR "Diverted\n"; $l->run; |