summaryrefslogtreecommitdiff
path: root/regress/sys/kern/sosplice/error/args-max-EINVAL.pl
diff options
context:
space:
mode:
Diffstat (limited to 'regress/sys/kern/sosplice/error/args-max-EINVAL.pl')
-rw-r--r--regress/sys/kern/sosplice/error/args-max-EINVAL.pl39
1 files changed, 39 insertions, 0 deletions
diff --git a/regress/sys/kern/sosplice/error/args-max-EINVAL.pl b/regress/sys/kern/sosplice/error/args-max-EINVAL.pl
new file mode 100644
index 00000000000..e61d83a81b5
--- /dev/null
+++ b/regress/sys/kern/sosplice/error/args-max-EINVAL.pl
@@ -0,0 +1,39 @@
+# test EINVAL for splicing with negative maximum
+
+use strict;
+use warnings;
+use IO::Socket;
+use BSD::Socket::Splice "SO_SPLICE";
+use Config;
+
+our %args = (
+ errno => 'EINVAL',
+ func => sub {
+ my $sl = IO::Socket::INET->new(
+ Proto => "tcp",
+ Listen => 5,
+ LocalAddr => "127.0.0.1",
+ ) or die "socket listen failed: $!";
+
+ my $s = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => $sl->sockhost(),
+ PeerPort => $sl->sockport(),
+ ) or die "socket failed: $!";
+
+ my $ss = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => $sl->sockhost(),
+ PeerPort => $sl->sockport(),
+ ) or die "socket splice failed: $!";
+
+ my $packed;
+ if ($Config{longsize} == 8) {
+ $packed = pack('iiiiiiii', $ss->fileno(),0,-1,-1,0,0,0,0);
+ } else {
+ $packed = pack('iiiii', $ss->fileno(),-1,-1,0,0);
+ }
+ $s->setsockopt(SOL_SOCKET, SO_SPLICE, $packed)
+ and die "splice to unconnected socket succeeded";
+ },
+);