Merge "Setting MTU size for specific network." into klp-dev

This commit is contained in:
Robert Greenwalt
2013-09-06 22:42:10 +00:00
committed by Android (Google) Code Review
3 changed files with 76 additions and 5 deletions

View File

@@ -2299,6 +2299,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
thisNet.setTeardownRequested(false);
updateNetworkSettings(thisNet);
updateMtuSizeSettings(thisNet);
handleConnectivityChange(newNetType, false);
sendConnectedBroadcastDelayed(info, getConnectivityChangeDelay());
@@ -2636,6 +2637,26 @@ public class ConnectivityService extends IConnectivityManager.Stub {
return routesChanged;
}
/**
* Reads the network specific MTU size from reources.
* and set it on it's iface.
*/
private void updateMtuSizeSettings(NetworkStateTracker nt) {
final String iface = nt.getLinkProperties().getInterfaceName();
final int mtu = nt.getLinkProperties().getMtu();
if (mtu < 68 || mtu > 10000) {
loge("Unexpected mtu value: " + nt);
return;
}
try {
if (VDBG) log("Setting MTU size: " + iface + ", " + mtu);
mNetd.setMtu(iface, mtu);
} catch (Exception e) {
Slog.e(TAG, "exception in setMtu()" + e);
}
}
/**
* Reads the network specific TCP buffer sizes from SystemProperties
@@ -4771,4 +4792,3 @@ public class ConnectivityService extends IConnectivityManager.Stub {
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, wakeupTime, intent);
}
}