shill: Connection: UnPin routes on destruction

Tag pinned routes with the interface index associated with the request,
so they can be removed when the connection is destroyed.  Also move
PinHostRoute() out of the VPN code and into the Connection.

BUG=chromium-os:29911
TEST=New unit tests

Change-Id: I46019255276469929642db4a6395e64f53e3b7d5
Reviewed-on: https://gerrit.chromium.org/gerrit/20982
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/routing_table_entry.h b/routing_table_entry.h
index 9cf41de..8a42de7 100644
--- a/routing_table_entry.h
+++ b/routing_table_entry.h
@@ -16,13 +16,16 @@
 // operator=.
 struct RoutingTableEntry {
  public:
+  static const int kDefaultTag = -1;
+
   RoutingTableEntry()
       : dst(IPAddress::kFamilyUnknown),
         src(IPAddress::kFamilyUnknown),
         gateway(IPAddress::kFamilyUnknown),
         metric(0),
         scope(0),
-        from_rtnl(false) {}
+        from_rtnl(false),
+        tag(kDefaultTag) {}
 
   RoutingTableEntry(const IPAddress &dst_in,
                     const IPAddress &src_in,
@@ -35,7 +38,23 @@
         gateway(gateway_in),
         metric(metric_in),
         scope(scope_in),
-        from_rtnl(from_rtnl_in) {}
+        from_rtnl(from_rtnl_in),
+        tag(kDefaultTag) {}
+
+  RoutingTableEntry(const IPAddress &dst_in,
+                    const IPAddress &src_in,
+                    const IPAddress &gateway_in,
+                    uint32 metric_in,
+                    unsigned char scope_in,
+                    bool from_rtnl_in,
+                    int tag_in)
+      : dst(dst_in),
+        src(src_in),
+        gateway(gateway_in),
+        metric(metric_in),
+        scope(scope_in),
+        from_rtnl(from_rtnl_in),
+        tag(tag_in) {}
 
   RoutingTableEntry(const RoutingTableEntry &b)
       : dst(b.dst),
@@ -43,7 +62,8 @@
         gateway(b.gateway),
         metric(b.metric),
         scope(b.scope),
-        from_rtnl(b.from_rtnl) {}
+        from_rtnl(b.from_rtnl),
+        tag(b.tag) {}
 
   RoutingTableEntry &operator=(const RoutingTableEntry &b) {
     dst = b.dst;
@@ -52,6 +72,7 @@
     metric = b.metric;
     scope = b.scope;
     from_rtnl = b.from_rtnl;
+    tag = b.tag;
 
     return *this;
   }
@@ -64,7 +85,8 @@
             gateway.Equals(b.gateway) &&
             metric == b.metric &&
             scope == b.scope &&
-            from_rtnl == b.from_rtnl);
+            from_rtnl == b.from_rtnl &&
+            tag == b.tag);
   }
 
   IPAddress dst;
@@ -73,6 +95,7 @@
   uint32 metric;
   unsigned char scope;
   bool from_rtnl;
+  int tag;
 };
 
 }  // namespace shill