Skip to content

Commit

Permalink
Add jumbo modifier to OpenBSD and Linux netlink interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluhm committed Dec 30, 2023
1 parent 63e11ab commit df2fa72
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
4 changes: 2 additions & 2 deletions net.pl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
my $scriptname = "$0 @ARGV";

my @allifaces = qw(em igc ix ixl bnxt);
my @allmodifymodes = qw(nolro none nopf notso);
my @allpseudos = qw(bridge none veb vlan);
my @allmodifymodes = qw(none jumbo nolro nopf notso);
my @allpseudos = qw(none bridge veb vlan);
my @allsetupmodes = (qw(build install upgrade sysupgrade keep kernel reboot
tools), "cvs,build", "cvs,kernel");
my @alltestmodes = qw(all fragment icmp tcp udp splice);
Expand Down
43 changes: 36 additions & 7 deletions netlink.pl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use Netstat;

my @allifaces = qw(none em igc ix ixl bnxt);
my @allmodifymodes = qw(none nolro nopf notso);
my @allmodifymodes = qw(none jumbo nolro nopf notso);
my @allpseudos = qw(none bridge veb vlan);
my @alltestmodes = sort qw(all fragment icmp tcp udp splice);

Expand Down Expand Up @@ -140,6 +140,7 @@
my $lnx_pdev = "$lnx_if.$line";
my $lnx_ipdev = $lnx_if;

my $lnx_l_mtu = 1500;
my $lnx_l_addr = "$ip4prefix.${line}1.1";
my $lnx_l_net = "$lnx_l_addr/24";
my $lnx_l_net_flat = "$lnx_l_addr/21";
Expand All @@ -148,6 +149,7 @@
my $lnx_l_net6_flat = "$lnx_l_addr6/60";
my $lnx_l_ssh = 'root@lt40'; #$ENV{LINUXL_SSH}; # XXX

my $lnx_r_mtu = 1500;
my $lnx_r_addr = "$ip4prefix.${line}2.4";
my $lnx_r_net = "$lnx_r_addr/24";
my $lnx_r_net_flat = "$lnx_r_addr/21";
Expand Down Expand Up @@ -362,20 +364,39 @@ sub good {
# only run generic setup code, basically destroys interface config
exit if $iface eq "none";

my %hwfeatures;
foreach my $if ($obsd_l_if, $obsd_r_if) {
my @cmd = ('/sbin/ifconfig', $if, 'hwfeatures');
open(my $fh, '-|', @cmd)
or die "Open pipe from command '@cmd' failed: $!";
my @hwfeatures = grep { /^\s*hwfeatures=/ } <$fh>;
my @hwf = grep { /^\thwfeatures=/ } <$fh>;
close($fh) or die $! ?
"Close pipe from command '@cmd' failed: $!" :
"Command '@cmd' failed: $?";
next unless grep { /\bLRO\b/ } @hwfeatures;
if ($modify eq 'nolro') {
printcmd('/sbin/ifconfig', $if, '-tcplro');
} else {
printcmd('/sbin/ifconfig', $if, 'tcplro');
@hwf
or next;
@hwf == 1
or die "Hardware features of '$if' not unique: @hwf";
$hwfeatures{$if} = $hwf[0];
}
foreach my $if (sort keys %hwfeatures) {
my $hwf = $hwfeatures{$if};
my $hwlro = ($hwf =~ /\bLRO\b/);
if ($hwlro) {
if ($modify eq 'nolro') {
printcmd('/sbin/ifconfig', $if, '-tcplro');
} else {
printcmd('/sbin/ifconfig', $if, 'tcplro');
}
}
my ($hwhardmtu) = ($hwf =~ /\bhardmtu (\d+)\b/);
my $mtu = 1500;
if ($modify eq 'jumbo' && $hwhardmtu) {
($mtu = $hwhardmtu) =~ s/...$/000/ if $hwhardmtu >= 2000;
$lnx_l_mtu = $mtu if $if eq $obsd_l_if;
$lnx_r_mtu = $mtu if $if eq $obsd_r_if;
}
printcmd('/sbin/ifconfig', $if, 'mtu', $mtu);
}

if ($pseudo eq 'aggr') {
Expand Down Expand Up @@ -476,17 +497,25 @@ sub good {
foreach my $addr (@obsd_l_addr6_range) {
printcmd('ifconfig', $obsd_l_ipdev, 'inet6', "$addr/128", 'alias');
}
printcmd('ifconfig', $obsd_l_ipdev, 'mtu', $lnx_l_mtu)
if $obsd_l_ipdev ne $obsd_l_if && $lnx_l_mtu != 1500;
printcmd('ifconfig', $obsd_l_ipdev, 'up');
if ($obsd_r_ipdev) {
printcmd('ifconfig', $obsd_r_ipdev, 'inet',
"$obsd_r_addr/$obsd_r_prefix");
printcmd('ifconfig', $obsd_r_ipdev, 'inet6',
"$obsd_r_addr6/$obsd_r_prefix6");
printcmd('ifconfig', $obsd_r_ipdev, 'mtu', $lnx_r_mtu)
if $obsd_r_ipdev ne $obsd_r_if && $lnx_r_mtu != 1500;
printcmd('ifconfig', $obsd_r_ipdev, 'up');
}

# configure Linux addresses and routes

printcmd('ssh', $lnx_l_ssh, 'ip', 'link', 'set', 'mtu', $lnx_l_mtu,
'dev', $lnx_if);
printcmd('ssh', $lnx_r_ssh, 'ip', 'link', 'set', 'mtu', $lnx_r_mtu,
'dev', $lnx_if);
printcmd('ssh', $lnx_l_ssh, qw(
for net in), $lnx_l_net, $lnx_l_net6, qw(; do
ip address add $net dev), $lnx_ipdev, qw(;
Expand Down

0 comments on commit df2fa72

Please sign in to comment.