Manually add directly-connected routes as well as default routes

Currently, the manual routing configuration that we use when
running the tests on a kernel that does not have the
accept_ra_rt_table sysctl does not add directly-connected routes
to the per-interface routing tables. This does not allow us to
test on-link connectivity unless the sysctl is present.

Remove this restriction and enable testOnlinkCommunication.

Also make testLeftoverRoutes conditional on HAVE_AUTOCONF_TABLE,
because without per-interface routing tables, sending an RA does
not result in the creation of a new routing table.

Change-Id: I16177cf374040b87a78e7455b05b11b956f4e7ee
diff --git a/net/test/iproute.py b/net/test/iproute.py
index 3611aeb..804d1e0 100644
--- a/net/test/iproute.py
+++ b/net/test/iproute.py
@@ -62,6 +62,7 @@
 
 # Route scope values (rtm_scope).
 RT_SCOPE_UNIVERSE = 0
+RT_SCOPE_LINK = 253
 
 # Named routing tables.
 RT_TABLE_UNSPEC = 0
@@ -522,8 +523,9 @@
              mark, uid):
     """Adds, deletes, or queries a route."""
     family = self._AddressFamily(version)
+    scope = RT_SCOPE_UNIVERSE if nexthop else RT_SCOPE_LINK
     rtmsg = RTMsg((family, prefixlen, 0, 0, RT_TABLE_UNSPEC,
-                   RTPROT_STATIC, RT_SCOPE_UNIVERSE, RTN_UNICAST, 0)).Pack()
+                   RTPROT_STATIC, scope, RTN_UNICAST, 0)).Pack()
     if command == RTM_NEWROUTE and not table:
       # Don't allow setting routes in table 0, since its behaviour is confusing
       # and differs between IPv4 and IPv6.
diff --git a/net/test/mark_test.py b/net/test/mark_test.py
index cee3e7e..d3b8d9f 100755
--- a/net/test/mark_test.py
+++ b/net/test/mark_test.py
@@ -491,9 +491,15 @@
           cls.iproute.AddNeighbour(version, router, macaddr, ifindex)
         if do_routing:
           cls.iproute.AddRoute(version, table, "default", 0, router, ifindex)
+          if version == 6:
+            cls.iproute.AddRoute(version, table,
+                                 cls.IPv6Prefix(netid), 64, None, ifindex)
       else:
         if do_routing:
           cls.iproute.DelRoute(version, table, "default", 0, router, ifindex)
+          if version == 6:
+            cls.iproute.DelRoute(version, table,
+                                 cls.IPv6Prefix(netid), 64, None, ifindex)
         if version == 4:
           cls.iproute.DelNeighbour(version, router, macaddr, ifindex)
           cls.iproute.DelAddress(cls._MyIPv4Address(netid), 24, ifindex)
@@ -1374,7 +1380,6 @@
         self.SendRA(netid)
       CheckIPv6Connectivity(True)
 
-  @unittest.skipUnless(HAVE_AUTOCONF_TABLE, "our manual routing doesn't do PIO")
   def testOnlinkCommunication(self):
     """Checks that on-link communication goes direct and not through routers."""
     for netid in self.tuns:
@@ -1413,6 +1418,7 @@
       self.ExpectPacketOn(netid, msg, expected)
 
   # This test documents a known issue: routing tables are never deleted.
+  @unittest.skipUnless(HAVE_AUTOCONF_TABLE, "no support for per-table autoconf")
   def testLeftoverRoutes(self):
     def GetNumRoutes():
       return len(open("/proc/net/ipv6_route").readlines())