shill: when updating the metric for a route, make sure to
update RoutingTable's internal state (in addition to updating
kernel state).

It seems the kernel doesn't echo our routing changes back to
us. So we need to explicitly update this ourselves.

BUG=chromium-os:26529
TEST=updated unit test, manual

manual testing:
- set up device with WiFi config, and plug in Ethernet
- "restart flimflam" five times, observe that every time,
  metric for route on Ethernet interface is 1.

Change-Id: Ib82f8be58b81e316e893e7952345f86f5489cfca
Reviewed-on: https://gerrit.chromium.org/gerrit/16405
Commit-Ready: mukesh agrawal <quiche@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
diff --git a/routing_table_unittest.cc b/routing_table_unittest.cc
index 1ca7a09..e5b2960 100644
--- a/routing_table_unittest.cc
+++ b/routing_table_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
@@ -369,13 +369,20 @@
                    _,
                    0));
   routing_table_->SetDefaultMetric(kTestDeviceIndex0, entry5.metric);
+  // Furthermore, the routing table should reflect the change in the metric
+  // for the default route for the interface.
+  RoutingTableEntry default_route;
+  EXPECT_TRUE(routing_table_->GetDefaultRoute(kTestDeviceIndex0,
+                                              IPAddress::kFamilyIPv4,
+                                              &default_route));
+  EXPECT_EQ(entry5.metric, default_route.metric);
 
   // Ask to flush table0.  We should see a delete message sent.
   EXPECT_CALL(sockets_,
               Send(kTestSocket,
                    IsRoutingPacket(RTNLMessage::kModeDelete,
                                    kTestDeviceIndex0,
-                                   entry0,
+                                   entry5,
                                    0),
                    _,
                    0));