shill: Connection: Add facility to add host routes
This requires a facility for tracking outstanding RTNL route requests,
and adding routes when they the response arrives. A few small fixes
to RTNL handling needed to be added.
BUG=chromium-os:27483
TEST=New Unit Tests, manual: Assocated my new Neptune proto to test
network.
Change-Id: I701fa244041ad9e0d0a502a263d83792ab3c9114
Reviewed-on: https://gerrit.chromium.org/gerrit/17889
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/connection.cc b/connection.cc
index fde6b0a..a69a690 100644
--- a/connection.cc
+++ b/connection.cc
@@ -10,6 +10,7 @@
#include "shill/device_info.h"
#include "shill/resolver.h"
#include "shill/routing_table.h"
+#include "shill/routing_table_entry.h"
#include "shill/rtnl_handler.h"
using std::string;
@@ -127,6 +128,19 @@
}
}
+bool Connection::RequestHostRoute(const IPAddress &address) {
+ // Set the prefix to be the entire address size.
+ IPAddress address_prefix(address);
+ address_prefix.set_prefix(address_prefix.GetLength() * 8);
+
+ if (!routing_table_->RequestRouteToHost(address_prefix, interface_index_)) {
+ LOG(ERROR) << "Could not request route to " << address.ToString();
+ return false;
+ }
+
+ return true;
+}
+
uint32 Connection::GetMetric(bool is_default) {
// If this is not the default route, assign a metric based on the interface
// index. This way all non-default routes (even to the same gateway IP) end