Ejemplo n.º 1
0
 def _add_route_to_switch(self, host, loopback_address):
     subnet = get_subnet_from_ip_and_prefixlen(loopback_address, 64)
     dst = ip_str_to_addr(subnet)
     prefix = IpPrefix(ip=dst, prefixLength=64)
     nexthops = [ip_str_to_addr(next(host.ips()))]
     unicast_route = UnicastRoute(dest=prefix, nextHopAddrs=nexthops)
     return self._add_unicast_route(unicast_route)
Ejemplo n.º 2
0
 def insert_routes(self, routes):
     uniRoutes = []
     for route in routes:
         ip, prefix = route.split("/")
         addr = utils.ip_to_binary(ip)
         ipRoute = IpPrefix(ip=addr, prefixLength=prefix)
         uniRoutes.append(UnicastRoute(dest=ipRoute, nextHopAddrs=self.nexthops))
     self.client.addUnicastRoutes(self.client_id, uniRoutes)
Ejemplo n.º 3
0
 def run(self, client_id, admin_distance, prefix, nexthops):
     prefix = parse_prefix(prefix)
     nexthops = parse_nexthops(nexthops)
     with self._create_agent_client() as client:
         client.addUnicastRoutes(client_id, [
             UnicastRoute(dest=prefix,
                          nextHops=nexthops,
                          adminDistance=admin_distance)
         ])
Ejemplo n.º 4
0
    def _add_route_to_switch(self, host, loopback_address):
        subnet = get_subnet_from_ip_and_prefixlen(loopback_address, 64)
        dst = ip_str_to_addr(subnet)
        prefix = IpPrefix(ip=dst, prefixLength=64)
        nexthops = [ip_str_to_addr(next(host.ips()))]
        unicast_route = UnicastRoute(dest=prefix, nextHopAddrs=nexthops)

        with self.test_topology.switch_thrift() as client:
            client.addUnicastRoute(1, unicast_route)
        return unicast_route
Ejemplo n.º 5
0
 def test_basic_l3_route_install(self):
     # This route just needs to not ecplipse anything
     # in the test harness, e.g., the control channel
     ipRoute = IpPrefix(ip="1:2:3:4:5:6::", prefixLength=24)
     self.test_topology.min_hosts_or_skip(2)
     host1 = self.test_topology.hosts[0]
     host2 = self.test_topology.hosts[1]
     nextHops = [ip_str_to_addr(host2.ips[0])]
     route = UnicastRoute(dest=ipRoute, nextHopAddrs=nextHops)
     # Install the route
     with self.test_topology.switch_thrift as sw_client:
         sw_client.addUnicastRoute(self.client_id, route)
     target_intf = host2.intfs[0]
     beforePkt = make_packet(src_host=host1, dst_host=host2, ttl=32)
     afterPkt = make_packet(src_host=host1, dst_host=host2, ttl=31)
     # Now try the test packet
     with host2.thrift_client() as client2:
         with host1.thrift_client() as client1:
             client2.expect(target_intf, afterPkt)
             client1.sendPkt(beforePkt)
             client2.expectVerify(target_intf, afterPkt, timeout=1)
Ejemplo n.º 6
0
    def test_update_route(self):
        dst = ip_str_to_addr("2804:6082:2040:97f::")
        prefix = IpPrefix(
            ip=dst,
            prefixLength=64)

        host = next(iter(self.test_topology.hosts()))
        ip = next(host.ips())
        nexthops = [ip_str_to_addr(ip)]

        unicast_route = UnicastRoute(dest=prefix, nextHopAddrs=nexthops)

        with self.test_topology.switch_thrift() as switch_client:
            fboss_routes = switch_client.getRouteTableByClient(
                self.NETLINK_MANAGER_CLIENT_ID)
            self.assertFalse(unicast_route in fboss_routes)

        with self.test_topology.netlink_manager_thrift() as netlink_client:
            response = netlink_client.addRoute(unicast_route, socket.AF_INET6)
            netlink_client._socket.close()
            self.assertEqual(response, 0)

        with self.test_topology.switch_thrift() as switch_client:
            fboss_routes = switch_client.getRouteTableByClient(
                self.NETLINK_MANAGER_CLIENT_ID)
            self.assertTrue(unicast_route in fboss_routes)

        with self.test_topology.netlink_manager_thrift() as netlink_client:
            response = netlink_client.deleteRoute(unicast_route, socket.AF_INET6)
            netlink_client._socket.close()
            self.assertEqual(response, 0)

        with self.test_topology.switch_thrift() as switch_client:
            fboss_routes = switch_client.getRouteTableByClient(
                self.NETLINK_MANAGER_CLIENT_ID)
            self.assertFalse(unicast_route in fboss_routes)
Ejemplo n.º 7
0
    def _get_unicast_route(self):
        prefix = self._get_prefix()
        nexthops = self._get_nexthops()

        return UnicastRoute(dest=prefix, nextHopAddrs=nexthops)
Ejemplo n.º 8
0
 def insert_route(self, route):
     ip, prefix = route.split("/")
     addr = utils.ip_to_binary(ip)
     ipRoute = IpPrefix(ip=addr, prefixLength=prefix)
     uniRoute = UnicastRoute(dest=ipRoute, nextHopAddrs=self.nexthops)
     self.client.addUnicastRoute(self.client_id, uniRoute)
Ejemplo n.º 9
0
def add_route(args):
    prefix = parse_prefix(args)
    nexthops = parse_nexthops(args)
    with get_client(args) as client:
        client.addUnicastRoutes(
            args.client, [UnicastRoute(dest=prefix, nextHopAddrs=nexthops)])