diff options
author | Linux Build Service Account <lnxbuild@qualcomm.com> | 2010-11-09 19:02:38 -0800 |
---|---|---|
committer | QuIC Gerrit Code Review <code-review@localhost> | 2010-11-09 19:02:38 -0800 |
commit | ada020c927243c1eac2b0e8b0e4fb29d76f97532 (patch) | |
tree | ec357e5834dfa31590fbbb4dce07fd2641b06fa7 | |
parent | 88c9b15b3a9937c3c2531c532cd644dfcd12f5fd (diff) | |
parent | 8621b5f2d863c5db0aac4464d5ce70b1b7558f89 (diff) | |
download | android_external_connectivity-ada020c927243c1eac2b0e8b0e4fb29d76f97532.tar.gz android_external_connectivity-ada020c927243c1eac2b0e8b0e4fb29d76f97532.tar.bz2 android_external_connectivity-ada020c927243c1eac2b0e8b0e4fb29d76f97532.zip |
Merge "external/connectivity: Use active gatewayAddress for default route" into froyo
-rw-r--r-- | cnd/inc/cnd_iproute2.h | 3 | ||||
-rw-r--r-- | cnd/src/cnd_iproute2.cpp | 27 | ||||
-rw-r--r-- | cnd/src/cnd_process.cpp | 2 |
3 files changed, 23 insertions, 9 deletions
diff --git a/cnd/inc/cnd_iproute2.h b/cnd/inc/cnd_iproute2.h index 0c41875..24b8080 100644 --- a/cnd/inc/cnd_iproute2.h +++ b/cnd/inc/cnd_iproute2.h @@ -214,7 +214,8 @@ class cnd_iproute2 */ bool replaceDefaultEntryInMainTable ( - uint8_t *deviceName + uint8_t *deviceName, + uint8_t *gatewayAddress ); /** diff --git a/cnd/src/cnd_iproute2.cpp b/cnd/src/cnd_iproute2.cpp index 8329647..311f682 100644 --- a/cnd/src/cnd_iproute2.cpp +++ b/cnd/src/cnd_iproute2.cpp @@ -187,6 +187,7 @@ bool modifyCustomRouteInMainTable bool modifyDefaultRoute ( uint8_t *deviceName, + uint8_t *gatewayAddress, Cmd_line_actions commandAction ); @@ -787,11 +788,15 @@ bool modifyCustomRouteInMainTable bool modifyDefaultRoute ( uint8_t *deviceName, + uint8_t *cmdGatewayAddress, Cmd_line_actions commandAction ) { uint8_t *gatewayAddress = NULL; + CNE_LOGV("modifyDefaultRoute: devName:%s, cmdGateway:%s, action:%d", + deviceName, cmdGatewayAddress, commandAction); + switch(commandAction) { case ACTIONS_REPLACE_ENUM: @@ -905,6 +910,9 @@ bool modifyDefaultRoute // These commands may fail if the kernel has already executed an operation on // its own. Treat a call to modify the main table as if was successful. if (NULL == gatewayAddress) + gatewayAddress = cmdGatewayAddress; + + if (NULL == gatewayAddress) { cmdLineCaller(ROUTING_CMD, cmdLineActionEnumToString(commandAction), @@ -979,7 +987,6 @@ bool modifyRoutingTable CNE_LOGD("A null device name was passed while modifying a routing table"); return false; } - switch(commandAction) { case ACTIONS_ADD_ENUM: @@ -1209,7 +1216,7 @@ bool modifyRoutingTable if (NULL == defaultDevice) { CNE_LOGV("Routing table added when no default exists. Adding new default."); - modifyDefaultRoute(deviceName, ACTIONS_REPLACE_ENUM); + modifyDefaultRoute(deviceName, gatewayAddress, ACTIONS_REPLACE_ENUM); } break; @@ -1221,10 +1228,13 @@ bool modifyRoutingTable tableNumberSet.erase(tableNumber); // If there are no more tables, then there should be no default device. + // There is a scenarios where iproute2 is recorded having no table since + // iproute2 not adding it, but there is default entry in main table + // created by system when network comes up, and if the default entry is + // removed, then there will be no default. Need to revisit iproute2. if (0 == tableNumberSet.size()) { - CNE_LOGV("Removing default table after no devices are known to be up"); - modifyDefaultRoute(NULL, ACTIONS_DELETE_ENUM); + CNE_LOGW("Warning: There are no tables"); } // If the default table has been deleted and another device is available, @@ -1235,7 +1245,7 @@ bool modifyRoutingTable uint8_t *newDefaultName = routingTableMap.begin()->first; CNE_LOGV("Replacing old default device with %s", newDefaultName); - modifyDefaultRoute(newDefaultName, ACTIONS_REPLACE_ENUM); + modifyDefaultRoute(newDefaultName, gatewayAddress, ACTIONS_REPLACE_ENUM); } break; @@ -1706,10 +1716,13 @@ bool cnd_iproute2::deleteDefaultEntryInMainTable *--------------------------------------------------------------------------*/ bool cnd_iproute2::replaceDefaultEntryInMainTable ( - uint8_t *deviceName + uint8_t *deviceName, + uint8_t *gatewayAddress ) { - return (modifyDefaultRoute(deviceName, ACTIONS_REPLACE_ENUM)); + CNE_LOGV("replaceDefaultEntryInMainTable: devName:%s, gatewayAddress:%s", + deviceName, gatewayAddress); + return (modifyDefaultRoute(deviceName, gatewayAddress, ACTIONS_REPLACE_ENUM)); } /*---------------------------------------------------------------------------- diff --git a/cnd/src/cnd_process.cpp b/cnd/src/cnd_process.cpp index 224d2fb..731d1d0 100644 --- a/cnd/src/cnd_process.cpp +++ b/cnd/src/cnd_process.cpp @@ -236,7 +236,7 @@ processCommand (int command, void *data, size_t datalen, CND_Token t) break; case CNE_IPROUTE2_REPLACE_DEFAULT_ENTRY_IN_MAIN: case CNE_IPROUTE2_REPLACE_HOST_DEFAULT_ENTRY_IN_MAIN: - cnd_iproute2::getInstance()->replaceDefaultEntryInMainTable(ifName); + cnd_iproute2::getInstance()->replaceDefaultEntryInMainTable(ifName, gatewayAddr); break; case CNE_IPROUTE2_ADD_HOST_IN_MAIN: cnd_iproute2::getInstance()->addCustomEntryInMainTable(ipAddr, ifName, gatewayAddr); |