summaryrefslogtreecommitdiffstats
path: root/cnd/src/cnd_iproute2.cpp
diff options
context:
space:
mode:
authorChinh Tran <chinht@codeaurora.org>2010-11-02 14:27:40 -0700
committerChinh Tran <chinht@codeaurora.org>2010-11-02 14:27:40 -0700
commit8621b5f2d863c5db0aac4464d5ce70b1b7558f89 (patch)
tree8752060e6d9a1807c82535be29c89dc1637dfa29 /cnd/src/cnd_iproute2.cpp
parent8d0860a47146126fea6395b8fd3a4059b5dc0903 (diff)
downloadandroid_external_connectivity-8621b5f2d863c5db0aac4464d5ce70b1b7558f89.tar.gz
android_external_connectivity-8621b5f2d863c5db0aac4464d5ce70b1b7558f89.tar.bz2
android_external_connectivity-8621b5f2d863c5db0aac4464d5ce70b1b7558f89.zip
external/connectivity: Use active gatewayAddress for default route
Cne should use the active gatewayAddress for default route if the gatewayAddress saved by iproute2 is not available. And Cne should not delete the default entry when Cne detects no routing table exists. Change-Id: I3027b277c72eec415eea67af1b1bc3d60350fc14 CRs-fixed: 262357
Diffstat (limited to 'cnd/src/cnd_iproute2.cpp')
-rw-r--r--cnd/src/cnd_iproute2.cpp27
1 files changed, 20 insertions, 7 deletions
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));
}
/*----------------------------------------------------------------------------