Skip to content

Commit

Permalink
Setup gre tunnel betreen OpenBSD and Linux in netlink.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluhm committed Jan 23, 2024
1 parent ba1fcb3 commit 74aafa9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion net.pl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

my @allifaces = qw(bnxt em igc ix ixl);
my @allmodifymodes = qw(none jumbo nolro nopf notso);
my @allpseudos = qw(none bridge carp gif veb vlan);
my @allpseudos = qw(none bridge carp gif gre 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
47 changes: 46 additions & 1 deletion netlink.pl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

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

my %opts;
Expand Down Expand Up @@ -296,6 +296,7 @@ sub good {

printcmd('sysctl', 'net.inet.ip.forwarding=1');
printcmd('sysctl', 'net.inet6.ip6.forwarding=1');
printcmd('sysctl', 'net.inet.gre.allow=1');

# allow tcpbench to bind on ipv6 addresses without explicitly providing it
printcmd('ssh', $lnx_l_ssh, 'sysctl','net.ipv6.bindv6only=1');
Expand Down Expand Up @@ -510,6 +511,50 @@ sub good {
printcmd('ssh', $ssh, 'ip', 'link', 'set', 'dev', $lnx_if, 'up');
}
$lnx_ipdev = $lnx_pdev;
} elsif ($pseudo eq 'gre') {
my $gre_l_key = "2${line}1";
my $gre_r_key = "2${line}2";

# configure OpenBSD tunnel addresses
printcmd('ifconfig', $obsd_l_if, 'inet', "$obsd_l_tunnel_addr/24");
printcmd('ifconfig', $obsd_r_if, 'inet', "$obsd_r_tunnel_addr/24");
printcmd('ifconfig', 'gre0', 'create');
printcmd('ifconfig', 'gre1', 'create');
printcmd('ifconfig', 'gre0', 'vnetid', $gre_l_key,
'tunnel', $obsd_l_tunnel_addr, $lnx_l_tunnel_addr);
printcmd('ifconfig', 'gre1', 'vnetid', $gre_r_key,
'tunnel', $obsd_r_tunnel_addr, $lnx_r_tunnel_addr);
printcmd('ifconfig', $obsd_l_if, 'up');
printcmd('ifconfig', $obsd_r_if, 'up');
$obsd_l_ipdev = "gre0";
$obsd_r_ipdev = "gre1";
$obsd_l_prefix = 32;
$obsd_l_prefix6 = 128;
$obsd_r_prefix = 32;
$obsd_r_prefix6 = 128;
@obsd_l_dest_addr = $lnx_l_addr;
@obsd_l_dest_addr6 = $lnx_l_addr6;
@obsd_r_dest_addr = $lnx_r_addr;
@obsd_r_dest_addr6 = $lnx_r_addr6;

# configure Linux tunnel addresses
foreach my $ssh ($lnx_l_ssh, $lnx_r_ssh) {
printcmd('ssh', $ssh, 'modprobe', 'ip_gre');
}
printcmd('ssh', $lnx_l_ssh, 'ip', 'address', 'add', $lnx_l_tunnel_net,
'dev', $lnx_if);
printcmd('ssh', $lnx_r_ssh, 'ip', 'address', 'add', $lnx_r_tunnel_net,
'dev', $lnx_if);
printcmd('ssh', $lnx_l_ssh, 'ip', 'link', 'add', 'name', $lnx_pdev,
'type', 'gre', 'key', $gre_l_key,
'local', $lnx_l_tunnel_addr, 'remote', $obsd_l_tunnel_addr);
printcmd('ssh', $lnx_r_ssh, 'ip', 'link', 'add', 'name', $lnx_pdev,
'type', 'gre', 'key', $gre_r_key,
'local', $lnx_r_tunnel_addr, 'remote', $obsd_r_tunnel_addr);
foreach my $ssh ($lnx_l_ssh, $lnx_r_ssh) {
printcmd('ssh', $ssh, 'ip', 'link', 'set', 'dev', $lnx_if, 'up');
}
$lnx_ipdev = $lnx_pdev;
} elsif ($pseudo eq 'veb') {
printcmd('ifconfig', 'veb0', 'create');
printcmd('ifconfig', 'vport0', 'create');
Expand Down

0 comments on commit 74aafa9

Please sign in to comment.