Ignore failure when adding directly-connected routes to the main table.
Change-Id: I12f65cdfbe2285820bd24b047f794ec9b9b5110f
diff --git a/RouteController.cpp b/RouteController.cpp
index e3bbef4..e771c74 100644
--- a/RouteController.cpp
+++ b/RouteController.cpp
@@ -210,9 +210,12 @@
// let the kernel find it when validating nexthops when global routes are added. Don't do this
// for IPv6, since all directly-connected routes in v6 are link-local and should already be in
// the main table.
- if (!nexthop && !strchr(destination, ':') &&
- !runIpRouteCommand(action, RT_TABLE_MAIN, interface, destination, NULL)) {
- return false;
+ // TODO: A failure here typically means that the route already exists in the main table, so we
+ // ignore it. It's wrong to ignore other kinds of failures, but we have no way to distinguish
+ // them based on the return status of the 'ip' command. Fix this situation by ignoring errors
+ // only when action == ADD && error == EEXIST.
+ if (!nexthop && !strchr(destination, ':')) {
+ runIpRouteCommand(action, RT_TABLE_MAIN, interface, destination, NULL);
}
return true;