diff options
author | Eric Wong <e@80x24.org> | 2023-10-03 09:26:01 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-03 10:16:11 +0000 |
commit | 60a3a95cea89b7f4a28b4b663897a07b7d4bf98a (patch) | |
tree | 4e6984e2f0070e7a7805d4335868106348e0627e /lib | |
parent | ad722a4e32af5e2889be819b49ef31ecee4c3f2b (diff) | |
download | public-inbox-60a3a95cea89b7f4a28b4b663897a07b7d4bf98a.tar.gz |
NetBSD 5.0+ has accept filter support from FreeBSD; and I I think we can assume all NetBSD is 5.0+ (released in 2009) nowadays if we're already depending on Perl 5.12 from 2010.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/Daemon.pm | 2 | ||||
-rw-r--r-- | lib/PublicInbox/TestCommon.pm | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index 07883153..7546105e 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -641,7 +641,7 @@ sub defer_accept ($$) { my $sec = unpack('i', $x); return if $sec > 0; # systemd users may set a higher value setsockopt($s, IPPROTO_TCP, $TCP_DEFER_ACCEPT, 1); - } elsif ($^O eq 'freebsd') { + } elsif ($^O =~ /\A(?:freebsd|netbsd)\z/) { my $x = getsockopt($s, SOL_SOCKET, $SO_ACCEPTFILTER); return if defined $x; # don't change if set my $accf_arg = pack('a16a240', $af_name, ''); diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 2c38500c..7d0eb2c4 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -133,6 +133,15 @@ my %IPv6_VERSION = ( 'Net::POP3' => 2.32, ); +sub need_accept_filter ($) { + my ($af) = @_; + return if $^O eq 'netbsd'; # since NetBSD 5.0 + skip 'SO_ACCEPTFILTER is FreeBSD/NetBSD-only' if $^O ne 'freebsd'; + state $tried = {}; + ($tried->{$af} //= system("kldstat -m $af >/dev/null")) and + skip "$af not loaded: kldload $af"; +} + sub require_mods { my @mods = @_; my $maybe = pop @mods if $mods[-1] =~ /\A[0-9]+\z/; @@ -166,6 +175,9 @@ sub require_mods { push @need, $msg; next; } + } elsif ($mod =~ /\A\+(accf_.*)\z/) { + need_accept_filter($1); + next } elsif (index($mod, '||') >= 0) { # "Foo||Bar" my $ok; for my $m (split(/\Q||\E/, $mod)) { |