Redhat IPv6 route management
authorJamie Cameron <jcameron@webmin.com>
Thu, 20 Jan 2011 02:15:44 +0000 (18:15 -0800)
committerJamie Cameron <jcameron@webmin.com>
Thu, 20 Jan 2011 02:15:44 +0000 (18:15 -0800)
net/lang/en
net/linux-lib.pl
net/list_routes.cgi
net/redhat-linux-lib.pl

index 04f75bc..6e01270 100644 (file)
@@ -113,6 +113,7 @@ routes_default2=Default routes
 routes_none=None (or from DHCP)
 routes_device=Device
 routes_gateway=Gateway
+routes_gateway6=IPv6 gateway
 routes_forward=Act as router?
 routes_routed=Start route discovery daemon?
 routes_edefault='$1' is not a valid default router
@@ -136,6 +137,7 @@ routes_etype='$1' is not a valid route type
 routes_any=Any
 routes_edefault2=Invalid default gateway address number $1
 routes_eclash=Only one default route for any interface can be defined
+routes_eclash6=Only one default route for any IPv6 interface can be defined
 routes_eclash2=Only one default route for $1 can be defined
 routes_none2=None
 routes_auto=Automatic
@@ -144,6 +146,7 @@ routes_dest=Destination
 routes_gw=Gateway
 routes_iface=Interface
 routes_def=Default Route
+routes_def6=Default IPv6 Route
 routes_active=Active Routes
 routes_nogw=None
 routes_delete=Delete Selected Routes
index d7dd75f..86fd2d5 100755 (executable)
@@ -209,17 +209,16 @@ while(<ROUTES>) {
        }
 close(ROUTES);
 &open_execute_command(ROUTES, "netstat -rn -A inet6", 1, 1);
-       while(<ROUTES>) {
-               s/\s+$//;
-               if (/^([0-9a-z:]+)\/([0-9]+)\s+([0-9a-z:]+)\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)$/) {
-                       push(@rv, { 'dest' => $1,
-                               'gateway' => $3,
-                               'netmask' => $2,
-                               'iface' => $4 });
-                                               }
+while(<ROUTES>) {
+       s/\s+$//;
+       if (/^([0-9a-z:]+)\/([0-9]+)\s+([0-9a-z:]+)\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)$/) {
+               push(@rv, { 'dest' => $1,
+                           'gateway' => $3,
+                           'netmask' => $2,
+                           'iface' => $4 });
+               }
        }
-
-       close(ROUTES);
+close(ROUTES);
 return @rv;
 }
 
index e306fd0..c909fcf 100755 (executable)
@@ -56,10 +56,12 @@ if (defined(&list_routes)) {
        $i = 0;
        foreach $route (&list_routes()) {
                local @cols = (
-                       $route->{'dest'} eq "0.0.0.0" ? $text{'routes_def'}
-                                                     : $route->{'dest'},
-                       $route->{'gateway'} eq "0.0.0.0" ? $text{'routes_nogw'}
-                                                        : $route->{'gateway'},
+                       $route->{'dest'} eq "0.0.0.0" ? $text{'routes_def'} :
+                       $route->{'dest'} eq "::" ? $text{'routes_def6'} :
+                                                  $route->{'dest'},
+                       $route->{'gateway'} eq "0.0.0.0" ? $text{'routes_nogw'}:
+                       $route->{'gateway'} eq "::" ? $text{'routes_nogw'}
+                                                   : $route->{'gateway'},
                        $route->{'netmask'} eq "0.0.0.0" ? ""
                                                         : $route->{'netmask'},
                        $route->{'iface'} || $text{'routes_any'},
index c8155f1..1677096 100755 (executable)
@@ -100,6 +100,7 @@ while($f = readdir(CONF)) {
                                                               $b->{'netmask'});
                        }
                $b->{'gateway'} = $conf{'GATEWAY'};
+               $b->{'gateway6'} = $conf{'IPV6_DEFAULTGW'};
                $b->{'mtu'} = $conf{'MTU'};
                $b->{'ether'} = $conf{'MACADDR'};
                $b->{'dhcp'} = ($conf{'BOOTPROTO'} eq 'dhcp');
@@ -158,6 +159,12 @@ else {
        else {
                delete($conf{'GATEWAY'});
                }
+       if ($_[0]->{'gateway6'}) {
+               $conf{'IPV6_DEFAULTGW'} = $_[0]->{'gateway6'};
+               }
+       else {
+               delete($conf{'IPV6_DEFAULTGW'});
+               }
        $conf{'MTU'} = $_[0]->{'mtu'};
        $conf{'MACADDR'} = $_[0]->{'ether'};
        $conf{'ONBOOT'} = $_[0]->{'up'} ? "yes" : "no";
@@ -342,25 +349,31 @@ else {
        # multiple default routers can exist, one per interface
        my @table;
        local $r = 0;
-       if ($conf{'GATEWAY'}) {
-               push(@table, [ &interface_sel("gatewaydev$r",
-                                             $conf{'GATEWAYDEV'} || "*"),
-                              &ui_textbox("gateway$r", $conf{'GATEWAY'}, 15),
-                            ]);
+       if ($conf{'GATEWAY'} || $conf{'IPV6_DEFAULTGW'}) {
+               push(@table, [
+                   &interface_sel("gatewaydev$r",
+                                  $conf{'GATEWAYDEV'} ||
+                                    $conf{'IPV6_DEFAULTGW'} || "*"),
+                   &ui_textbox("gateway$r", $conf{'GATEWAY'}, 15),
+                   &ui_textbox("gateway6$r", $conf{'IPV6_DEFAULTGW'}, 30),
+                   ]);
                $r++;
                }
        local @boot = &boot_interfaces();
        foreach $b (grep { $_->{'gateway'} && $_->{'virtual'} eq '' } @boot) {
                push(@table, [ &interface_sel("gatewaydev$r", $b->{'name'}),
                               &ui_textbox("gateway$r", $b->{'gateway'}, 15),
+                              &ui_textbox("gateway6$r", $b->{'gateway6'}, 30),
                             ]);
                $r++;
                }
        push(@table, [ &interface_sel("gatewaydev$r"),
-                      &ui_textbox("gateway$r", undef, 15) ]);
+                      &ui_textbox("gateway$r", undef, 15),
+                      &ui_textbox("gateway6$r", undef, 30), ]);
        print &ui_table_row($text{'routes_default2'},
                &ui_columns_table(
-                       [ $text{'routes_ifc'}, $text{'routes_gateway'} ],
+                       [ $text{'routes_ifc'}, $text{'routes_gateway'},
+                         $text{'routes_gateway6'} ],
                        undef, \@table, undef, 1));
        }
 
@@ -479,6 +492,8 @@ else {
                }
        delete($conf{'GATEWAY'});
        delete($conf{'GATEWAYDEV'});
+       delete($conf{'IPV6_DEFAULTDEV'});
+       delete($conf{'IPV6_DEFAULTGW'});
 
        for($r=0; defined($in{"gatewaydev$r"}); $r++) {
                next if (!$in{"gatewaydev$r"});
@@ -488,13 +503,18 @@ else {
                        # For any interface
                        $conf{'GATEWAY'} && &error(&text('routes_eclash'));
                        $conf{'GATEWAY'} = $in{"gateway$r"};
+                       $conf{'IPV6_DEFAULTGW'} &&
+                               &error(&text('routes_eclash6'));
+                       $conf{'IPV6_DEFAULTGW'} = $in{"gateway6$r"};
                        }
                else {
                        # For a specific interface
-                       local ($b) = grep { $_->{'fullname'} eq $in{"gatewaydev$r"} } @boot;
+                       local ($b) = grep { $_->{'fullname'} eq
+                                           $in{"gatewaydev$r"} } @boot;
                        $b->{'gateway'} && &error(&text('routes_eclash2',
                                                        $in{"gatewaydev$r"}));
                        $b->{'gateway'} = $in{"gateway$r"};
+                       $b->{'gateway6'} = $in{"gateway6$r"};
                        }
                }
        }
@@ -651,7 +671,6 @@ local %conf;
 local @boot = &boot_interfaces();
 local ($gifc) = grep { $_->{'gateway'} && $_->{'virtual'} eq '' } @boot;
 return ( $gifc->{'gateway'}, $gifc->{'fullname'} ) if ($gifc);
-
 return $conf{'GATEWAY'} ? ( $conf{'GATEWAY'}, $conf{'GATEWAYDEV'} ) : ( );
 }