bugfix: get_default_gw needs to follow the route the node will use to internet.

because of previous bugfix the function needs to check table 31 and 254 (with 254 taking priority)
This commit is contained in:
Conrad Lara - KG6JEI 2014-07-08 00:02:47 -07:00
parent 60b8095c08
commit 88d532a3a1
1 changed files with 16 additions and 6 deletions

View File

@ -417,12 +417,22 @@ sub get_ip6_addr
sub get_default_gw
{
my $gw = "none";
foreach(`route -n`)
{
next unless /^0\.0\.0\.0\s+([\d\.]+)/;
$gw = $1;
last;
}
# Table 31 is populated by OLSR
foreach(`/usr/sbin/ip route list table 31`)
{
next unless /^default\svia\s([\d\.]+)/;
$gw = $1;
last;
}
# However a node with a wired default gw will route via that instead
foreach(`/usr/sbin/ip route list table 254`)
{
next unless /^default\svia\s([\d\.]+)/;
$gw = $1;
last;
}
return $gw;
}