Updated bonding support to use the new format in Debian 5.0, thanks to Caspar Smit.
authorJamie Cameron <jcameron@webmin.com>
Mon, 24 Aug 2009 01:02:29 +0000 (18:02 -0700)
committerJamie Cameron <jcameron@webmin.com>
Mon, 24 Aug 2009 01:02:29 +0000 (18:02 -0700)
net/CHANGELOG
net/debian-linux-lib.pl
net/delete_bifcs.cgi
net/linux-lib.pl
net/save_bifc.cgi

index ee3f842..3af5173 100644 (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.
index 519e00a..ea4b16c 100755 (executable)
@@ -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'});
        }
 }
index 61c8424..4766fc7 100755 (executable)
@@ -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'});}
                                        }
                                        }
                                }
index 080df0c..bb6a2e9 100755 (executable)
@@ -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,16 +153,21 @@ 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(&iface_type($name) =~ /^(.*) (VLAN)$/) {
-               $out = &backquote_logged("vconfig rem $name 2>&1");
+       if (($gconfig{'os_type'} eq 'debian-linux') && ($gconfig{'os_version'} >= 5)) {
+               local $out = &backquote_logged("ifdown $name 2>&1");    
        }
-       local ($still) = grep { $_->{'fullname'} eq $name }
+       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 ($still) {
+                       &error("<pre>$out</pre>");
                }
        }
+       if(&iface_type($name) =~ /^(.*) (VLAN)$/) {
+               $out = &backquote_logged("vconfig rem $name 2>&1");
+       }
+       }
 }
 
 # iface_type(name)
index c7821d6..cbc8a53 100755 (executable)
@@ -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);
                        }
                }