Updated bonding support to use the new format in Debian 5.0, thanks to Caspar Smit.

This commit is contained in:
Jamie Cameron
2009-08-23 18:02:29 -07:00
parent 38a9751070
commit 4efe320bc0
5 changed files with 55 additions and 11 deletions

View File

@@ -50,3 +50,5 @@ Fixed editing of bonding network interfaces on Debian Linux.
Fixed network interface management on SuSE 10.2.
Updated the Hostname and DNS Client page to always show the hostname from config files, rather than the system's short hostname.
On Debian systems, if the dns-nameservers option is defined in /etc/network/interfaces, it will be updated when changing nameservers.
---- Changes since 1.480 ----
Updated bonding support to use the new format in Debian 5.0, thanks to Caspar Smit.

View File

@@ -60,6 +60,21 @@ foreach $iface (@ifaces) {
$cfg->{'downdelay'} = $options{'downdelay'};
$cfg->{'updelay'} = $options{'updelay'};
}
elsif($param eq 'bond_mode') {
$cfg->{'mode'} = $value;
}
elsif($param eq 'bond_miimon') {
$cfg->{'miimon'} = $value;
}
elsif($param eq 'bond_downdelay') {
$cfg->{'downdelay'} = $value;
}
elsif($param eq 'bond_updelay') {
$cfg->{'updelay'} = $value;
}
elsif($param eq 'slaves') {
$cfg->{'partner'} = $value;
}
else { $cfg->{$param} = $value; }
}
$cfg->{'dhcp'} = ($method eq 'dhcp');
@@ -109,7 +124,14 @@ my $amode = $gconfig{'os_version'} > 3 || scalar(@autos);
if (!$cfg->{'up'} && !$amode) { push(@options, ['noauto', '']); }
# Set bonding parameters
if($cfg->{'bond'} == 1) {
if(($cfg->{'bond'} == 1) && ($gconfig{'os_version'} >= 5)) {
push(@options, ['bond_mode ' . $cfg->{'mode'}]);
push(@options, ['bond_miimon ' . $cfg->{'miimon'}]);
push(@options, ['bond_updelay ' . $cfg->{'updelay'}]);
push(@options, ['bond_downdelay ' . $cfg->{'downdelay'}]);
push(@options, ['slaves ' . $cfg->{'partner'}]);
}
elsif($cfg->{'bond'} == 1) {
push(@options, ['up', '/sbin/ifenslave ' . $cfg->{'name'} . " " . $cfg->{'partner'}]);
push(@options, ['down', '/sbin/ifenslave -d ' . $cfg->{'name'} . " " . $cfg->{'partner'}]);
}
@@ -150,7 +172,8 @@ if ($changeit == 0) {
else{
new_interface_def($cfg->{'fullname'}, 'inet', $method, \@options);
}
if($cfg->{'bond'} == 1) {
if (($cfg->{'bond'} == 1) && ($gconfig{'os_version'} >= 5)) {}
elsif ($cfg->{'bond'} == 1) {
new_module_def($cfg->{'fullname'}, $cfg->{'mode'}, $cfg->{'miimon'}, $cfg->{'downdelay'}, $cfg->{'updelay'});
}
}
@@ -163,7 +186,8 @@ else {
else{
modify_interface_def($cfg->{'fullname'}, 'inet', $method, \@options, 0);
}
if($cfg->{'bond'} == 1) {
if (($cfg->{'bond'} == 1) && ($gconfig{'os_version'} >= 5)) {}
elsif ($cfg->{'bond'} == 1) {
modify_module_def($cfg->{'fullname'}, 0, $cfg->{'mode'}, $cfg->{'miimon'}, $cfg->{'downdelay'}, $cfg->{'updelay'});
}
}

View File

@@ -32,7 +32,8 @@ foreach $d (reverse(@d)) {
else {
&deactivate_interface($act);
if(&iface_type($b->{'name'}) eq 'Bonded'){
&unload_module($b->{'name'});
if (($gconfig{'os_type'} eq 'debian-linux') && ($gconfig{'os_version'} >= 5)) {}
else {&unload_module($b->{'name'});}
}
}
}

View File

@@ -95,6 +95,14 @@ if($a->{'vlan'} == 1) {
}
local $cmd;
if (($gconfig{'os_type'} eq 'debian-linux') && ($gconfig{'os_version'} >= 5)) {
if ($a->{'up'}) { $cmd .= "ifup $a->{'name'}"; }
else { $cmd .= "ifdown $a->{'name'}"; }
local $out = &backquote_logged("$cmd 2>&1");
if ($?) { &error($out); }
}
else {
if($a->{'vlan'} == 1) {
$cmd .= "ifconfig $a->{'physical'}.$a->{'vlanid'}";
}
@@ -123,6 +131,7 @@ if ($a->{'ether'}) {
if ($?) { &error($out); }
}
}
}
# deactivate_interface(&details)
# Shutdown some active interface
@@ -144,15 +153,20 @@ if ($_[0]->{'virtual'} ne "") {
local ($still) = grep { $_->{'fullname'} eq $name } &active_interfaces();
if ($still && !&is_ipv6_address($address)) {
# Old version of ifconfig or non-virtual interface.. down it
local $out = &backquote_logged("ifconfig $name down 2>&1");
if (($gconfig{'os_type'} eq 'debian-linux') && ($gconfig{'os_version'} >= 5)) {
local $out = &backquote_logged("ifdown $name 2>&1");
}
else {
local $out = &backquote_logged("ifconfig $name down 2>&1");
local ($still) = grep { $_->{'fullname'} eq $name }
&active_interfaces();
if ($still) {
&error("<pre>$out</pre>");
}
}
if(&iface_type($name) =~ /^(.*) (VLAN)$/) {
$out = &backquote_logged("vconfig rem $name 2>&1");
}
local ($still) = grep { $_->{'fullname'} eq $name }
&active_interfaces();
if ($still) {
&error("<pre>$out</pre>");
}
}
}

View File

@@ -232,7 +232,10 @@ else {
$err && &error("<pre>$err</pre>");
}
else {
if($in{'bond'}) {&load_module($b);}
if ($in{'bond'}) {
if (($gconfig{'os_type'} eq 'debian-linux') && ($gconfig{'os_version'} >= 5)) {}
else {&load_module($b);}
}
&activate_interface($b);
}
}