Bug 1175817 - [NetworkManager] remove old default routes explicitly. r=echen,smaug

--HG--
extra : commitid : 6xQMx4MoezU
This commit is contained in:
Jessica Jong 2015-09-11 15:26:58 +08:00
parent 47f5d88572
commit 9a44f07882
6 changed files with 10 additions and 21 deletions

View File

@ -993,13 +993,18 @@ NetworkManager.prototype = {
});
},
_setDefaultRouteAndProxy: function(aNetwork, aOldInterface) {
_setDefaultRouteAndProxy: function(aNetwork, aOldNetwork) {
if (aOldNetwork) {
return this._removeDefaultRoute(aOldNetwork.info)
.then(() => this._setDefaultRouteAndProxy(aNetwork, null));
}
return new Promise((aResolve, aReject) => {
let networkInfo = aNetwork.info;
let gateways = networkInfo.getGateways();
let oldInterfaceName = (aOldInterface ? aOldInterface.info.name : "");
gNetworkService.setDefaultRoute(networkInfo.name, gateways.length, gateways,
oldInterfaceName, (aSuccess) => {
(aSuccess) => {
if (!aSuccess) {
gNetworkService.destroyNetwork(networkInfo.name, function() {
aReject("setDefaultRoute failed");

View File

@ -463,14 +463,11 @@ NetworkService.prototype = {
});
},
setDefaultRoute: function(aInterfaceName, aCount, aGateways,
aOldInterfaceName, aCallback) {
setDefaultRoute: function(aInterfaceName, aCount, aGateways, aCallback) {
debug("Going to change default route to " + aInterfaceName);
let options = {
cmd: "setDefaultRoute",
ifname: aInterfaceName,
oldIfname: (aOldInterfaceName && aOldInterfaceName !== aInterfaceName) ?
aOldInterfaceName : null,
gateways: aGateways
};
this.controlMessage(options, function(aResult) {

View File

@ -2007,13 +2007,6 @@ CommandResult NetworkUtils::setDefaultRouteLegacy(NetworkParams& aOptions)
{
NS_ConvertUTF16toUTF8 autoIfname(aOptions.mIfname);
if (!aOptions.mOldIfname.IsEmpty()) {
// Remove IPv4's default route.
WARN_IF_FAILED(mNetUtils->do_ifc_remove_default_route(GET_CHAR(mOldIfname)));
// Remove IPv6's default route.
WARN_IF_FAILED(mNetUtils->do_ifc_remove_route(GET_CHAR(mOldIfname), "::", 0, NULL));
}
uint32_t length = aOptions.mGateways.Length();
if (length > 0) {
for (uint32_t i = 0; i < length; i++) {

View File

@ -110,7 +110,6 @@ public:
COPY_OPT_STRING_FIELD(mIfname, EmptyString())
COPY_OPT_STRING_FIELD(mIp, EmptyString())
COPY_OPT_FIELD(mPrefixLength, 0)
COPY_OPT_STRING_FIELD(mOldIfname, EmptyString())
COPY_OPT_STRING_FIELD(mMode, EmptyString())
COPY_OPT_FIELD(mReport, false)
COPY_OPT_FIELD(mEnabled, false)
@ -163,7 +162,6 @@ public:
nsString mIfname;
nsString mIp;
uint32_t mPrefixLength;
nsString mOldIfname;
nsString mMode;
bool mReport;
bool mEnabled;

View File

@ -157,7 +157,7 @@ interface nsIDhcpRequestCallback : nsISupports
/**
* Provide network services.
*/
[scriptable, uuid(5d6b1877-890a-4c7f-8403-94d57ceba6cf)]
[scriptable, uuid(fcd0abd4-8525-469f-a166-12edb4081f3e)]
interface nsINetworkService : nsISupports
{
const long MODIFY_ROUTE_ADD = 0;
@ -310,8 +310,6 @@ interface nsINetworkService : nsISupports
* Number of elements in gateways.
* @param gateways
* Default gateways for setting default route.
* @param oldInterfaceName
* The previous network interface name.
*
* @param callback
* Callback to notify the result of setting default route.
@ -319,7 +317,6 @@ interface nsINetworkService : nsISupports
void setDefaultRoute(in DOMString interfaceName,
in unsigned long count,
[array, size_is(count)] in wstring gateways,
in DOMString oldInterfaceName,
in nsINativeCommandCallback callback);
/**

View File

@ -17,7 +17,6 @@ dictionary NetworkCommandOptions
unsigned long prefixLength; // for "removeNetworkRoute".
DOMString domain; // for "setDNS"
sequence<DOMString> dnses; // for "setDNS", "setDefaultRouteAndDNS".
DOMString oldIfname; // for "setDefaultRouteAndDNS".
DOMString gateway; // for "addSecondaryRoute", "removeSecondaryRoute".
sequence<DOMString> gateways; // for "setDefaultRouteAndDNS", "removeDefaultRoute".
DOMString mode; // for "setWifiOperationMode".