Skip to content

Commit

Permalink
use interface netX if ethX is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
mariux committed Mar 11, 2015
1 parent 96b453c commit 0e23fa8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mxstartup2mxconfig
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,20 @@ sub read_file {
return @lines;
}

sub eth_to_net_if_not_exists {
my $dev = shift;
my $net;
my $num;

return $dev if -d "/sys/class/net/${dev}";

($num) = $dev =~ /^eth(\d+)$/;
$net = sprintf "net%02d", $num;

return $net if -d "/sys/class/net/${net}";

return $dev;
}

sub parse_ips {
local $_;
Expand Down Expand Up @@ -160,6 +173,8 @@ sub parse_ips {
}
$_todest = inet_ntoa($tmphostname);

$device = eth_to_net_if_not_exists($device);

$H->{$ip} = { device => $device, addressprefix => $addressprefix, ports => {%ports}, todest => $_todest };
}

Expand Down

0 comments on commit 0e23fa8

Please sign in to comment.