shill: Assign unique metrics to non-default interfaces
Assign a metric based on the interface index to routes
for interfaces that are not default. As a result even
if the gateway address is the same (e.g, if you're connected
to a home AP via both wireless and wired) that the routes
do not conflict with each other.
BUG=chromium-os:23917
TEST=Manual: As above, connect to a home AP over Ethernet
and WiFi, and ensure that both gateway routes appear.
Change-Id: I85ffad74ec53dda535578367242114b30846b7ac
Reviewed-on: https://gerrit.chromium.org/gerrit/12651
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_unittest.cc b/connection_unittest.cc
index dd1fe4b..130302c 100644
--- a/connection_unittest.cc
+++ b/connection_unittest.cc
@@ -96,9 +96,11 @@
TEST_F(ConnectionTest, AddConfig) {
EXPECT_CALL(rtnl_handler_,
AddInterfaceAddress(kTestDeviceInterfaceIndex0, _, _));
- EXPECT_CALL(routing_table_, SetDefaultRoute(kTestDeviceInterfaceIndex0,
- ipconfig_,
- Connection::kNonDefaultMetric));
+ EXPECT_CALL(routing_table_,
+ SetDefaultRoute(kTestDeviceInterfaceIndex0,
+ ipconfig_,
+ Connection::kNonDefaultMetricBase +
+ kTestDeviceInterfaceIndex0));
connection_->UpdateFromIPConfig(ipconfig_);
EXPECT_CALL(routing_table_, SetDefaultMetric(kTestDeviceInterfaceIndex0,
@@ -110,8 +112,10 @@
connection_->SetDefault(true);
EXPECT_TRUE(connection_->is_default());
- EXPECT_CALL(routing_table_, SetDefaultMetric(kTestDeviceInterfaceIndex0,
- Connection::kNonDefaultMetric));
+ EXPECT_CALL(routing_table_,
+ SetDefaultMetric(kTestDeviceInterfaceIndex0,
+ Connection::kNonDefaultMetricBase +
+ kTestDeviceInterfaceIndex0));
connection_->SetDefault(false);
EXPECT_FALSE(connection_->is_default());
}