Bug 1174998 - Part 2: Set MTU for connected network interfaces. r=echen

This commit is contained in:
Jessica Jong 2015-09-23 15:35:31 +08:00
parent ed986a674a
commit 9b8f929f77
2 changed files with 26 additions and 1 deletions

View File

@ -99,6 +99,7 @@ function ExtraNetworkInfo(aNetwork) {
this.dnses = aNetwork.info.getDnses();
this.httpProxyHost = aNetwork.httpProxyHost;
this.httpProxyPort = aNetwork.httpProxyPort;
this.mtu = aNetwork.mtu;
}
ExtraNetworkInfo.prototype = {
getAddresses: function(aIps, aPrefixLengths) {
@ -369,6 +370,13 @@ NetworkManager.prototype = {
return this.setSecondaryDefaultRoute(extNetworkInfo);
})
.then(() => this._addSubnetRoutes(extNetworkInfo))
.then(() => {
if (extNetworkInfo.mtu <= 0) {
return;
}
return this._setMtu(extNetworkInfo);
})
.then(() => this.setAndConfigureActive())
.then(() => {
// Update data connection when Wifi connected/disconnected
@ -943,6 +951,18 @@ NetworkManager.prototype = {
});
},
_setMtu: function(aNetworkInfo) {
return new Promise((aResolve, aReject) => {
gNetworkService.setMtu(aNetworkInfo.name, aNetworkInfo.mtu, (aSuccess) => {
if (!aSuccess) {
debug("setMtu failed");
}
// Always resolve.
aResolve();
});
});
},
_createNetwork: function(aInterfaceName) {
return new Promise((aResolve, aReject) => {
gNetworkService.createNetwork(aInterfaceName, (aSuccess) => {

View File

@ -80,7 +80,7 @@ interface nsINetworkInfo : nsISupports
[array, size_is(count), retval] out wstring dnses);
};
[scriptable, uuid(9a025351-8684-4ab5-a0c1-f21a9f83d405)]
[scriptable, uuid(8b1345fa-b34c-41b3-8d21-09f961bf8887)]
interface nsINetworkInterface : nsISupports
{
/**
@ -97,4 +97,9 @@ interface nsINetworkInterface : nsISupports
* The port number of the http proxy server.
*/
readonly attribute long httpProxyPort;
/*
* The Maximun Transmit Unit for this network interface, -1 if not set.
*/
readonly attribute long mtu;
};