diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-09-28 12:40:36 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-09-28 12:40:36 +0000 |
commit | 60674b9c7cae1b0d52fc29a5b6fa61ade9a44d2a (patch) | |
tree | ca878f505cd21b68e81e1e64b5f14dccb0066762 /regress/usr.sbin/ospfd | |
parent | d371d61af3e9ff079fa925d03c98adfb01abc8e5 (diff) |
The tun interface has been renamed to tap(4). Adapt ospfd test.
Diffstat (limited to 'regress/usr.sbin/ospfd')
-rw-r--r-- | regress/usr.sbin/ospfd/Client.pm | 18 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/Default.pm | 12 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/Makefile | 22 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/README | 2 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/Tap.pm (renamed from regress/usr.sbin/ospfd/Tun.pm) | 44 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/args-ifstate-pri-ism-ospfd.pl | 4 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/args-ifstate-pri-ism.pl | 4 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/args-ifstate-pri-ospfd-ism.pl | 4 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/args-ifstate-pri-ospfd.pl | 4 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/opentap.c (renamed from regress/usr.sbin/ospfd/opentun.c) | 18 | ||||
-rw-r--r-- | regress/usr.sbin/ospfd/tapdump.pl (renamed from regress/usr.sbin/ospfd/tundump.pl) | 10 |
11 files changed, 71 insertions, 71 deletions
diff --git a/regress/usr.sbin/ospfd/Client.pm b/regress/usr.sbin/ospfd/Client.pm index fad2248a2d7..3c57559cf94 100644 --- a/regress/usr.sbin/ospfd/Client.pm +++ b/regress/usr.sbin/ospfd/Client.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Client.pm,v 1.4 2015/01/16 17:06:43 bluhm Exp $ +# $OpenBSD: Client.pm,v 1.5 2016/09/28 12:40:35 bluhm Exp $ # Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org> # Copyright (c) 2014-2015 Florian Riehm <mail@friehm.de> @@ -32,9 +32,9 @@ use AnyEvent::Handle; use AnyEvent::Strict; use Packet; -use Tun 'opentun'; +use Tap 'opentap'; -my $tun_number; +my $tap_number; my $area; my $hello_interval; # Parameters for interface state machine of the test @@ -342,25 +342,25 @@ sub child { or croak ref($self), " client ospf address missing"; $ism_rtrid = $self->{router_id} or croak ref($self), " client router id missing"; - $tun_number = $self->{tun_number} - or croak ref($self), " tun device number missing"; + $tap_number = $self->{tap_number} + or croak ref($self), " tap device number missing"; $ospfd_ip = $self->{ospfd_ip} or croak ref($self), " ospfd ip missing"; $ospfd_rtrid = $self->{ospfd_rtrid} or croak ref($self), " ospfd router id missing"; - my $tun = opentun($tun_number); + my $tap = opentap($tap_number); $handle = AnyEvent::Handle->new( - fh => $tun, + fh => $tap, read_size => 70000, # little more then max ip size on_error => sub { - $cv->croak("error on tun device $tun_number: $!"); + $cv->croak("error on tap device $tap_number: $!"); $handle->destroy(); undef $handle; }, on_eof => sub { - $cv->croak("end-of-file on tun device $tun_number: $!"); + $cv->croak("end-of-file on tap device $tap_number: $!"); $handle->destroy(); undef $handle; }, diff --git a/regress/usr.sbin/ospfd/Default.pm b/regress/usr.sbin/ospfd/Default.pm index 6b786f41b7b..c25f87e4873 100644 --- a/regress/usr.sbin/ospfd/Default.pm +++ b/regress/usr.sbin/ospfd/Default.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Default.pm,v 1.2 2014/07/11 22:28:51 bluhm Exp $ +# $OpenBSD: Default.pm,v 1.3 2016/09/28 12:40:35 bluhm Exp $ # Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org> # Copyright (c) 2014 Florian Riehm <mail@friehm.de> @@ -24,15 +24,15 @@ our @ISA = qw( Exporter ); our @EXPORT = qw( $area - $tun_number + $tap_number $ospfd_ip $ospfd_rtrid %default_args ); our $area = "10.188.0.0"; -our $tun_number = $ENV{TUNNUM}; -our $ospfd_ip = $ENV{TUNIP}; +our $tap_number = $ENV{TAPNUM}; +our $ospfd_ip = $ENV{TAPIP}; our $ospfd_rtrid = $ENV{RTRID}; my $hello_interval = 2; @@ -45,7 +45,7 @@ our %default_args = ( }, areas => { $area => { - "tun$tun_number:$ospfd_ip" => { + "tap$tap_number:$ospfd_ip" => { 'metric' => '15', 'hello-interval' => $hello_interval, 'router-dead-time' => 4 * $hello_interval, @@ -61,7 +61,7 @@ our %default_args = ( router_id => "10.188.0.18", area => $area, hello_intervall => $hello_interval, - tun_number => $tun_number, + tap_number => $tap_number, ospfd_ip => $ospfd_ip, ospfd_rtrid => $ospfd_rtrid, }, diff --git a/regress/usr.sbin/ospfd/Makefile b/regress/usr.sbin/ospfd/Makefile index 2765eae05ee..45abbc16e0d 100644 --- a/regress/usr.sbin/ospfd/Makefile +++ b/regress/usr.sbin/ospfd/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.5 2016/09/02 21:30:34 bluhm Exp $ +# $OpenBSD: Makefile,v 1.6 2016/09/28 12:40:35 bluhm Exp $ # The following ports must be installed for the regression tests: # p5-AnyEvent provide framework for multiple event loops @@ -21,10 +21,10 @@ regress: .endif # Fill out these variables with your own system parameters -# You need a tun device and an unused /24 IPv4 network. +# You need a tap device and an unused /24 IPv4 network. -TUNNUM ?= 3 -TUNIP ?= 10.188.6.17 +TAPNUM ?= 3 +TAPIP ?= 10.188.6.17 RTRID ?= 10.188.0.17 # Automatically generate regress targets from test cases in directory. @@ -32,7 +32,7 @@ RTRID ?= 10.188.0.17 ARGS != cd ${.CURDIR} && ls args-*.pl TARGETS ?= ${ARGS} REGRESS_TARGETS = ${TARGETS:S/^/run-regress-/} -CLEANFILES += *.log ospfd.conf ktrace.out stamp-* opentun +CLEANFILES += *.log ospfd.conf ktrace.out stamp-* opentap PERLHEADER != perl -MConfig -e 'print "$$Config{archlib}/CORE"' CLEANFILES += PassFd.c PassFd.o PassFd.so CFLAGS = -Wall @@ -42,9 +42,9 @@ CFLAGS = -Wall .if make (regress) || make (all) .BEGIN: @echo - [ -c /dev/tun${TUNNUM} ] - [ -z "${SUDO}" ] || ${SUDO} -C 3 true - ${SUDO} ifconfig tun${TUNNUM} ${TUNIP} netmask 255.255.255.0 link0 + [ -c /dev/tap${TAPNUM} ] + [ -z "${SUDO}" ] || ${SUDO} -C 4 true + ${SUDO} ifconfig tap${TAPNUM} ${TAPIP} netmask 255.255.255.0 .endif # Set variables so that make runs with and without obj directory. @@ -62,9 +62,9 @@ PERLPATH = ${.CURDIR}/ # test parameters. .for a in ${ARGS} -run-regress-$a: $a opentun PassFd.so +run-regress-$a: $a opentap PassFd.so @echo '\n======== $@ ========' - time TUNNUM=${TUNNUM} TUNIP=${TUNIP} RTRID=${RTRID} SUDO=${SUDO} KTRACE=${KTRACE} OSPFD=${OSPFD} perl ${PERLINC} ${PERLPATH}ospfd.pl ${PERLPATH}$a + time TAPNUM=${TAPNUM} TAPIP=${TAPIP} RTRID=${RTRID} SUDO=${SUDO} KTRACE=${KTRACE} OSPFD=${OSPFD} perl ${PERLINC} ${PERLPATH}ospfd.pl ${PERLPATH}$a .endfor # make perl syntax check for all args files @@ -75,7 +75,7 @@ syntax: stamp-syntax stamp-syntax: ${ARGS} stamp-passfd .for a in ${ARGS} - @TUNNUM=${TUNNUM} TUNIP=${TUNIP} RTRID=${RTRID} perl ${PERLINC} -c ${PERLPATH}$a + @TAPNUM=${TAPNUM} TAPIP=${TAPIP} RTRID=${RTRID} perl ${PERLINC} -c ${PERLPATH}$a .endfor @date >$@ diff --git a/regress/usr.sbin/ospfd/README b/regress/usr.sbin/ospfd/README index 22b68d5159e..eff65701251 100644 --- a/regress/usr.sbin/ospfd/README +++ b/regress/usr.sbin/ospfd/README @@ -1,6 +1,6 @@ This is a test framework for the ospfd routing daemon. For each test one fresh daemon is started with an individual config. It is -talking OSPF via a tun interface. At the process side of the tun +talking OSPF via a tap interface. At the process side of the tap device a client is running. This test programm is parsing the OSPF packets and generates new ones. It simulates other OSPF daemons. diff --git a/regress/usr.sbin/ospfd/Tun.pm b/regress/usr.sbin/ospfd/Tap.pm index 6c96d7daf27..f30219e7d59 100644 --- a/regress/usr.sbin/ospfd/Tun.pm +++ b/regress/usr.sbin/ospfd/Tap.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Tun.pm,v 1.2 2014/07/11 22:28:51 bluhm Exp $ +# $OpenBSD: Tap.pm,v 1.1 2016/09/28 12:40:35 bluhm Exp $ # Copyright (c) 2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -14,14 +14,14 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# Encapsulate tun interface handling into separate module. +# Encapsulate tap interface handling into separate module. use strict; use warnings; -package Tun; +package Tap; use parent 'Exporter'; -our @EXPORT_OK = qw(opentun); +our @EXPORT_OK = qw(opentap); use Carp; use Fcntl; @@ -30,30 +30,30 @@ use POSIX qw(_exit); use PassFd 'recvfd'; use Socket; -sub opentun { - my ($tun_number) = @_; - my $tun_device = "/dev/tun$tun_number"; +sub opentap { + my ($tap_number) = @_; + my $tap_device = "/dev/tap$tap_number"; if ($> == 0) { - sysopen(my $tun, $tun_device, O_RDWR) - or croak "Open $tun_device failed: $!"; - return $tun; + sysopen(my $tap, $tap_device, O_RDWR) + or croak "Open $tap_device failed: $!"; + return $tap; } if (!$ENV{SUDO}) { - die "To open the device $tun_device you must run as root or\n". + die "To open the device $tap_device you must run as root or\n". "set the SUDO environment variable and allow closefrom_override.\n"; } - my $opentun; + my $opentap; my $curdir = dirname($0) || "."; - if (-x "$curdir/opentun") { - $opentun = "$curdir/opentun"; - } elsif (-x "./opentun") { - $opentun = "./opentun"; + if (-x "$curdir/opentap") { + $opentap = "$curdir/opentap"; + } elsif (-x "./opentap") { + $opentap = "./opentap"; } else { - die "To open the device $tun_device the tool opentun is needed.\n". - "Executable opentun not found in $curdir or current directory.\n"; + die "To open the device $tap_device the tool opentap is needed.\n". + "Executable opentap not found in $curdir or current directory.\n"; } socketpair(my $parent, my $child, AF_UNIX, SOCK_STREAM, PF_UNSPEC) @@ -70,8 +70,8 @@ sub opentun { warn "Close parent socket failed: $!"; _exit(3); }; - my @cmd = ($ENV{SUDO}, '-C', $child->fileno()+1, $opentun, - $child->fileno(), $tun_number); + my @cmd = ($ENV{SUDO}, '-C', $child->fileno()+1, $opentap, + $child->fileno(), $tap_number); exec(@cmd); warn "Exec '@cmd' failed: $!"; _exit(3); @@ -80,14 +80,14 @@ sub opentun { # parent process close($child) or croak "Close child socket failed: $!"; - my $tun = recvfd($parent) + my $tap = recvfd($parent) or croak "Recvfd failed: $!"; wait() or croak "Wait failed: $!"; $? == 0 or croak "Child process failed: $?"; - return $tun; + return $tap; } 1; diff --git a/regress/usr.sbin/ospfd/args-ifstate-pri-ism-ospfd.pl b/regress/usr.sbin/ospfd/args-ifstate-pri-ism-ospfd.pl index f9c57757067..97c18d0690a 100644 --- a/regress/usr.sbin/ospfd/args-ifstate-pri-ism-ospfd.pl +++ b/regress/usr.sbin/ospfd/args-ifstate-pri-ism-ospfd.pl @@ -4,14 +4,14 @@ use strict; use warnings; -use Default qw($area $tun_number $ospfd_ip $ospfd_rtrid); +use Default qw($area $tap_number $ospfd_ip $ospfd_rtrid); our %tst_args = ( ospfd => { conf => { areas => { $area => { - "tun$tun_number:$ospfd_ip" => { + "tap$tap_number:$ospfd_ip" => { 'router-priority' => '1', }, }, diff --git a/regress/usr.sbin/ospfd/args-ifstate-pri-ism.pl b/regress/usr.sbin/ospfd/args-ifstate-pri-ism.pl index f0c32777f86..b42ffeaeeeb 100644 --- a/regress/usr.sbin/ospfd/args-ifstate-pri-ism.pl +++ b/regress/usr.sbin/ospfd/args-ifstate-pri-ism.pl @@ -4,14 +4,14 @@ use strict; use warnings; -use Default qw($area $tun_number $ospfd_ip $ospfd_rtrid); +use Default qw($area $tap_number $ospfd_ip $ospfd_rtrid); our %tst_args = ( ospfd => { conf => { areas => { $area => { - "tun$tun_number:$ospfd_ip" => { + "tap$tap_number:$ospfd_ip" => { 'router-priority' => '0', }, }, diff --git a/regress/usr.sbin/ospfd/args-ifstate-pri-ospfd-ism.pl b/regress/usr.sbin/ospfd/args-ifstate-pri-ospfd-ism.pl index f1de202bc66..66069325da9 100644 --- a/regress/usr.sbin/ospfd/args-ifstate-pri-ospfd-ism.pl +++ b/regress/usr.sbin/ospfd/args-ifstate-pri-ospfd-ism.pl @@ -4,14 +4,14 @@ use strict; use warnings; -use Default qw($area $tun_number $ospfd_ip $ospfd_rtrid); +use Default qw($area $tap_number $ospfd_ip $ospfd_rtrid); our %tst_args = ( ospfd => { conf => { areas => { $area => { - "tun$tun_number:$ospfd_ip" => { + "tap$tap_number:$ospfd_ip" => { 'router-priority' => '2', }, }, diff --git a/regress/usr.sbin/ospfd/args-ifstate-pri-ospfd.pl b/regress/usr.sbin/ospfd/args-ifstate-pri-ospfd.pl index 8f2eb16550c..3745f6dacba 100644 --- a/regress/usr.sbin/ospfd/args-ifstate-pri-ospfd.pl +++ b/regress/usr.sbin/ospfd/args-ifstate-pri-ospfd.pl @@ -4,14 +4,14 @@ use strict; use warnings; -use Default qw($area $tun_number $ospfd_ip $ospfd_rtrid); +use Default qw($area $tap_number $ospfd_ip $ospfd_rtrid); our %tst_args = ( ospfd => { conf => { areas => { $area => { - "tun$tun_number:$ospfd_ip" => { + "tap$tap_number:$ospfd_ip" => { 'router-priority' => '1', }, }, diff --git a/regress/usr.sbin/ospfd/opentun.c b/regress/usr.sbin/ospfd/opentap.c index e16c37105dd..0bbf59bde52 100644 --- a/regress/usr.sbin/ospfd/opentun.c +++ b/regress/usr.sbin/ospfd/opentap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opentun.c,v 1.2 2014/07/11 22:28:51 bluhm Exp $ */ +/* $OpenBSD: opentap.c,v 1.1 2016/09/28 12:40:35 bluhm Exp $ */ /* * Copyright (c) 2014 Alexander Bluhm <bluhm@openbsd.org> @@ -31,16 +31,16 @@ void usage(void); void usage(void) { - fprintf(stderr, "usage: sudo %s fd# tun#\n", getprogname()); + fprintf(stderr, "usage: sudo %s fd# tap#\n", getprogname()); fprintf(stderr, " fd# number of file descriptor for fd passing\n"); - fprintf(stderr, " tun# number of tun device to open\n"); + fprintf(stderr, " tap# number of tap device to open\n"); exit(2); } int main(int argc, char *argv[]) { - int fd, tun; + int fd, tap; char dev[FILENAME_MAX]; const char *errstr; struct msghdr msg; @@ -56,12 +56,12 @@ main(int argc, char *argv[]) fd = strtonum(argv[1], 0, INT_MAX, &errstr); if (errstr) errx(2, "file descriptor number %s: %s", errstr, argv[1]); - tun = strtonum(argv[2], 0, INT_MAX, &errstr); + tap = strtonum(argv[2], 0, INT_MAX, &errstr); if (errstr) - errx(2, "tun device number %s: %s", errstr, argv[2]); - snprintf(dev, FILENAME_MAX, "/dev/tun%d", tun); + errx(2, "tap device number %s: %s", errstr, argv[2]); + snprintf(dev, FILENAME_MAX, "/dev/tap%d", tap); - if ((tun = open(dev, O_RDWR)) == -1) + if ((tap = open(dev, O_RDWR)) == -1) err(1, "open %s", dev); memset(&msg, 0, sizeof(msg)); @@ -72,7 +72,7 @@ main(int argc, char *argv[]) cmsg->cmsg_len = CMSG_LEN(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; - *(int *)CMSG_DATA(cmsg) = tun; + *(int *)CMSG_DATA(cmsg) = tap; if (sendmsg(fd, &msg, 0) == -1) err(1, "sendmsg %d", fd); diff --git a/regress/usr.sbin/ospfd/tundump.pl b/regress/usr.sbin/ospfd/tapdump.pl index 93b20267da5..6fc79058535 100644 --- a/regress/usr.sbin/ospfd/tundump.pl +++ b/regress/usr.sbin/ospfd/tapdump.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: tundump.pl,v 1.2 2014/07/11 22:28:51 bluhm Exp $ +# $OpenBSD: tapdump.pl,v 1.1 2016/09/28 12:40:35 bluhm Exp $ # Copyright (c) 2014 Alexander Bluhm <bluhm@openbsd.org> # @@ -17,13 +17,13 @@ use strict; use warnings; -use Tun 'opentun'; +use Tap 'opentap'; -my $tun = opentun(6) - or die "Open tun device 6 failed: $!"; +my $tap = opentap(6) + or die "Open tap device 6 failed: $!"; for (;;) { - my $n = sysread($tun, my $buf, 70000); + my $n = sysread($tap, my $buf, 70000); defined($n) or die "sysread failed: $!"; $n or last; print "Read $n bytes\n"; |