shill: connection: Work around broken netmasks
It has been observed in the field that some network infrastructures
send a gateway/netmask pair that is inconsistent and prevents the
client from contacting the gateway. Work around this by expanding
the netmask, assuming that this parameter is incorrect. However,
use sane defaults for maximum expansion of the netmask, so that
we do not completely break things.
BUG=chromium-os:29416
TEST=New unit tests.
Change-Id: Id4730a8c1555fb09033175bdf2bfba1abe93a125
Reviewed-on: https://gerrit.chromium.org/gerrit/20465
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/routing_table.cc b/routing_table.cc
index f5d84af..fa280f6 100644
--- a/routing_table.cc
+++ b/routing_table.cc
@@ -137,19 +137,14 @@
}
bool RoutingTable::SetDefaultRoute(int interface_index,
- const IPConfigRefPtr &ipconfig,
+ const IPAddress &gateway_address,
uint32 metric) {
VLOG(2) << __func__ << " index " << interface_index << " metric " << metric;
- const IPConfig::Properties &ipconfig_props = ipconfig->properties();
RoutingTableEntry *old_entry;
- IPAddress gateway_address(ipconfig_props.address_family);
- if (!gateway_address.SetAddressFromString(ipconfig_props.gateway)) {
- return false;
- }
if (GetDefaultRouteInternal(interface_index,
- ipconfig_props.address_family,
+ gateway_address.family(),
&old_entry)) {
if (old_entry->gateway.Equals(gateway_address)) {
if (old_entry->metric != metric) {
@@ -165,7 +160,7 @@
}
}
- IPAddress default_address(ipconfig_props.address_family);
+ IPAddress default_address(gateway_address.family());
default_address.SetAddressToDefault();
return AddRoute(interface_index,