Fix adding of default route.

If you deleted the host routes (started a secondary network like mms, supl
of hipri and then ended it) you would lose the host route to the default
gateway.  Then if you needed to re-add the default gateway route (lost
the connection and removed the default route and then re-established)
you couldn't - can't add a gateway that isn't routable apparently.

This happens if you are in a video chat and lose your connection without
losing the interface (PPP keeps it up for a bit).

Fixed it by having addDefaultRoute first add a hsot route for the gateway
before adding the default route.  This allows the default add to succeed.

bug:3490353
Change-Id: I415e7319832e6456f8757b14c4f79f098a08839b
This commit is contained in:
Robert Greenwalt
2011-03-22 18:47:42 -07:00
parent bbba216fe3
commit 03d53da1f5

View File

@@ -1415,13 +1415,16 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (TextUtils.isEmpty(interfaceName)) return; if (TextUtils.isEmpty(interfaceName)) return;
for (InetAddress gateway : p.getGateways()) { for (InetAddress gateway : p.getGateways()) {
if (!NetworkUtils.addDefaultRoute(interfaceName, gateway) && DBG) { if (NetworkUtils.addHostRoute(interfaceName, gateway, null) &&
NetworkUtils.addDefaultRoute(interfaceName, gateway)) {
if (DBG) {
NetworkInfo networkInfo = nt.getNetworkInfo(); NetworkInfo networkInfo = nt.getNetworkInfo();
log("addDefaultRoute for " + networkInfo.getTypeName() + log("addDefaultRoute for " + networkInfo.getTypeName() +
" (" + interfaceName + "), GatewayAddr=" + gateway.getHostAddress()); " (" + interfaceName + "), GatewayAddr=" + gateway.getHostAddress());
} }
} }
} }
}
public void removeDefaultRoute(NetworkStateTracker nt) { public void removeDefaultRoute(NetworkStateTracker nt) {
@@ -1430,13 +1433,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
String interfaceName = p.getInterfaceName(); String interfaceName = p.getInterfaceName();
if (interfaceName != null) { if (interfaceName != null) {
if ((NetworkUtils.removeDefaultRoute(interfaceName) >= 0) && DBG) { if (NetworkUtils.removeDefaultRoute(interfaceName) >= 0) {
if (DBG) {
NetworkInfo networkInfo = nt.getNetworkInfo(); NetworkInfo networkInfo = nt.getNetworkInfo();
log("removeDefaultRoute for " + networkInfo.getTypeName() + " (" + log("removeDefaultRoute for " + networkInfo.getTypeName() + " (" +
interfaceName + ")"); interfaceName + ")");
} }
} }
} }
}
/** /**
* Reads the network specific TCP buffer sizes from SystemProperties * Reads the network specific TCP buffer sizes from SystemProperties