From a13298bd7d4ed2a339d6701162a9864069ddf643 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Wed, 25 Oct 2023 22:51:08 +0200 Subject: [PATCH] Start and stop tcpbench service to avoid conflict during splice. --- netlink.pl | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/netlink.pl b/netlink.pl index 39fca4f8..eb8f1f2c 100755 --- a/netlink.pl +++ b/netlink.pl @@ -342,6 +342,10 @@ sub good { rc_reload=NO rc_bg=YES +rc_start() { + rc_exec "${daemon} ${daemon_flags}" & +} + rc_cmd $1 EOF close($tcpbench_rc); @@ -504,20 +508,26 @@ sub good { # tcpbench tests -if ($testmode{tcp4} || $testmode{tcp6}) { +sub tcpbench_server_startup { # requires echo 1 > /proc/sys/net/ipv6/bindv6only - my @cmd = ('ssh', '-f', $lnx_r_ssh, 'service', 'tcpbench', 'start'); + my @sshcmd = ('ssh', '-f', $lnx_r_ssh, 'service', 'tcpbench', 'start'); + mysystem(@sshcmd) + and die "Start linux tcpbench server with '@sshcmd' failed: $?"; + + my @cmd = ('rcctl', '-f', 'start', 'tcpbench'); mysystem(@cmd) - and die "Start tcpbench server with '@cmd' failed: $?"; - - @cmd = ('rcctl', '-f', 'start', 'tcpbench'); - defined(my $pid = fork()) - or die "Fork failed: $!"; - unless ($pid) { - exec(@cmd); - warn "Exec '@cmd' failed: $!"; - _exit(126); - } + and die "Start local tcpbench server with '@cmd' failed: $?"; +} + +sub tcpbench_server_shutdown { + # requires echo 1 > /proc/sys/net/ipv6/bindv6only + my @sshcmd = ('ssh', '-f', $lnx_r_ssh, 'service', 'tcpbench', 'stop'); + mysystem(@sshcmd) + and die "Stop linux tcpbench server with '@sshcmd' failed: $?"; + + my @cmd = ('rcctl', '-f', 'stop', 'tcpbench'); + mysystem(@cmd) + and die "Stop local tcpbench server with '@cmd' failed: $?"; } my @tcpbench_subvalues; @@ -731,6 +741,9 @@ sub notso_shutdown { parser => \&ping_f_parser, } ) if ($testmode{icmp6}); +push @tests, { + testcmd => \&tcpbench_server_startup, +} if ($testmode{tcp4} || $testmode{tcp6}); push @tests, ( { testcmd => ['ssh', $lnx_l_ssh, 'tcpbench', '-S1000000', '-t10', @@ -877,6 +890,10 @@ sub notso_shutdown { parser => \&udpbench_parser, } ) if ($testmode{fragment6}); +push @tests, { + testcmd => \&tcpbench_server_shutdown, +} if ($testmode{tcp4} || $testmode{tcp6} || + $testmode{splice4} || $testmode{splice6}); foreach my $mode (qw(tcpsplice tcpcopy)) { push @tests, ( { @@ -1012,6 +1029,11 @@ sub notso_shutdown { local $SIG{ALRM} = 'IGNORE'; TEST: foreach my $t (@tests) { + if (ref $t->{testcmd} eq 'CODE') { + $t->{testcmd}->(); + next; + } + my @runcmd = @{$t->{testcmd}}; (my $test = join("_", @runcmd)) =~ s,/.*/,,;