Fix IPv6 gateway field
authorJamie Cameron <jcameron@webmin.com>
Tue, 28 Jun 2011 20:36:58 +0000 (16:36 -0400)
committerJamie Cameron <jcameron@webmin.com>
Tue, 28 Jun 2011 20:36:58 +0000 (16:36 -0400)
net/debian-linux-lib.pl

index fa92dab..f6f0414 100755 (executable)
@@ -185,6 +185,8 @@ if ($cfg->{'ether'}) {
                                   $cfg->{'ether'} ]);
        }
 if ($cfg->{'bridge'}) {
+       &has_command("brctl") || &error("Bridges cannot be created unless the ".
+                                       "brctl command is installed");
        push(@options, [ 'bridge_ports', $cfg->{'bridgeto'} ]);
        }
 
@@ -640,14 +642,18 @@ if (!$in{'gateway_def'}) {
 &set_default_gateway($gw, $dev);
 
 # Save IPv6 address
-local ($dev6, $gw6);
-if (!$in{'gateway6_def'}) {
-       &check_ip6address($in{'gateway6'}) ||
-               &error(&text('routes_egateway6', $in{'gateway6'}));
-       $gw6 = $in{'gateway6'};
-       $dev6 = $in{'gatewaydev6'};
+local @ifaces6 = grep { $_->[1] eq 'inet6' && $_->[0] ne 'lo' }
+                     &get_interface_defs();
+if (@ifaces6) {
+       local ($dev6, $gw6);
+       if (!$in{'gateway6_def'}) {
+               &check_ip6address($in{'gateway6'}) ||
+                       &error(&text('routes_egateway6', $in{'gateway6'}));
+               $gw6 = $in{'gateway6'};
+               $dev6 = $in{'gatewaydev6'};
+               }
+       &set_default_ipv6_gateway($gw6, $dev6);
        }
-&set_default_ipv6_gateway($gw6, $dev6);
 
 # Parse static and local routes
 local %st;