Skip to content

Commit

Permalink
Skip management interface, continue with pairs in netlink.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluhm committed Dec 24, 2023
1 parent c9798da commit d81d281
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions net.pl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Date::Parse;
use File::Basename;
use Getopt::Std;
use List::Util qw(pairkeys);
use POSIX;

use lib dirname($0);
Expand Down Expand Up @@ -214,12 +215,21 @@ END
die "Interface type '$if' does not exist in dmesg";
}
}
my $numre = defined($num) ? qr/$num/ : qr/[0-9]*[02468]+/;
foreach my $ifnum (map { /^$iftype($numre) at / ? $1 : () } @dmesg) {
if (($iftype.($ifnum + 0)) eq $management_if ||
($iftype.($ifnum + 1)) eq $management_if) {
my %ifnums;
@ifnums{
map { /^$iftype(\d+)$/ }
grep { ! /^($management_if)$/ }
map { /^($iftype\d+) at / ? $1 : () }
@dmesg} = ();
foreach my $ifnum (defined($num) ? ($num + 0) :
pairkeys sort { $a <=> $b } keys %ifnums) {
if (($iftype.($ifnum + 0)) =~ /^($management_if)$/ ||
($iftype.($ifnum + 1)) =~ /^($management_if)$/) {
die "Cannot use inferface '$if', conflicts management";
}
if (!exists($ifnums{$ifnum + 0}) || !exists($ifnums{$ifnum + 1})) {
if (defined($num)) {
die "Cannot use inferface '$if', conflicts management";
die "Interface pair '$if' does not exist in dmesg";
} else {
next;
}
Expand Down
4 changes: 2 additions & 2 deletions netlink.pl
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
$left_ifidx = 0;
$right_ifidx = 1;
}
if (($iftype.$left_ifidx) eq $management_if ||
($iftype.$right_ifidx) eq $management_if) {
if (($iftype.$left_ifidx) =~ /^($management_if$/ ||
($iftype.$right_ifidx) =~ /^($management_if$/) {
if (defined($ifnum)) {
die "Cannot use inferface '$iface', conflicts management";
} else {
Expand Down

0 comments on commit d81d281

Please sign in to comment.