From 4efe320bc07bb6e4ff9af711abfc10dcf6a53c18 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sun, 23 Aug 2009 18:02:29 -0700 Subject: [PATCH] Updated bonding support to use the new format in Debian 5.0, thanks to Caspar Smit. --- net/CHANGELOG | 2 ++ net/debian-linux-lib.pl | 30 +++++++++++++++++++++++++++--- net/delete_bifcs.cgi | 3 ++- net/linux-lib.pl | 26 ++++++++++++++++++++------ net/save_bifc.cgi | 5 ++++- 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/net/CHANGELOG b/net/CHANGELOG index ee3f842cc..3af517324 100644 --- a/net/CHANGELOG +++ b/net/CHANGELOG @@ -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. diff --git a/net/debian-linux-lib.pl b/net/debian-linux-lib.pl index 519e00a1a..ea4b16c76 100755 --- a/net/debian-linux-lib.pl +++ b/net/debian-linux-lib.pl @@ -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'}); } } diff --git a/net/delete_bifcs.cgi b/net/delete_bifcs.cgi index 61c8424c6..4766fc7af 100755 --- a/net/delete_bifcs.cgi +++ b/net/delete_bifcs.cgi @@ -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'});} } } } diff --git a/net/linux-lib.pl b/net/linux-lib.pl index 080df0c1e..bb6a2e90e 100755 --- a/net/linux-lib.pl +++ b/net/linux-lib.pl @@ -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("
$out
"); + } + } if(&iface_type($name) =~ /^(.*) (VLAN)$/) { $out = &backquote_logged("vconfig rem $name 2>&1"); } - local ($still) = grep { $_->{'fullname'} eq $name } - &active_interfaces(); - if ($still) { - &error("
$out
"); - } } } diff --git a/net/save_bifc.cgi b/net/save_bifc.cgi index c7821d69a..cbc8a53bb 100755 --- a/net/save_bifc.cgi +++ b/net/save_bifc.cgi @@ -232,7 +232,10 @@ else { $err && &error("
$err
"); } 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); } }