Beispiel #1
0
def _get_first_router_ip(test, interface, v6):
    addr_len = 16 if v6 else 4
    # just grab any IP as long as it's the right type
    dst_ips = list(filter(lambda prefix: len(prefix.ip.addr) == addr_len,
                            interface.address))
    test.assertGreaterEqual(len(dst_ips), 1,
            "Switch has no %s route IPs" % "v6" if v6 else "v4")
    return ip_addr_to_str(dst_ips[0].ip)
Beispiel #2
0
 def _test_interface_ip_ping(self, host, v4=True):
     with self.test_topology.switch_thrift() as sw_client:
         interfaces = sw_client.getAllInterfaces()
     for intf in interfaces.values():
         ip = ip_addr_to_str(intf.address[0].ip)
         for host_intf in host.intfs():
             ip = _append_outgoing_interface(ip, host_intf, v4)
             if ip is not None:
                 self.log.info("Ping from %s to %s" % (host, ip))
                 with host.thrift_client() as client:
                     self.assertTrue(client.ping(ip))
 def _test_interface_ip_ping(self, host, v4=True):
     with self.test_topology.switch_thrift() as sw_client:
         interfaces = sw_client.getAllInterfaces()
     for intf in interfaces.values():
         ip = ip_addr_to_str(intf.address[0].ip)
         for host_intf in host.intfs():
             ip = _append_outgoing_interface(ip, host_intf, v4)
             if ip is not None:
                 self.log.info("Ping from %s to %s" % (host, ip))
                 with host.thrift_client() as client:
                     self.assertTrue(client.ping(ip))
Beispiel #4
0
 def test_l3_interface_ping(self):
     with self.test_topology.switch_thrift() as sw_client:
         interfaces = sw_client.getAllInterfaces()
     for intf in interfaces.values():
         for host in self.test_topology.hosts():
             ip = ip_addr_to_str(intf.address[0].ip)
             for host_intf in host.intfs():
                 if ":" in ip:
                     # for v6, always ping with "%eth0" in address
                     ip = ip + "%%%s" % host_intf
                 self.log.info("Ping from %s to %s" % (host, ip))
                 with host.thrift_client() as client:
                     self.assertTrue(client.ping(ip))
Beispiel #5
0
    def get_all_intf_subnets_and_ips(self):
        intf_subnets, intf_ips = ([], [])
        for intf in self._get_all_intfs():
            for addr in intf.address:
                ipstr = ip_addr_to_str(addr.ip)
                if not self._is_v6(ipstr):
                    continue

                intf_subnets.append(
                    ipaddress.ip_network(f'{ipstr}/{addr.prefixLength}',
                                         strict=False))
                intf_ips.append(ipaddress.ip_address(ipstr))
        return intf_subnets, intf_ips
 def test_l3_interface_ping(self):
     with self.test_topology.switch_thrift() as sw_client:
         interfaces = sw_client.getAllInterfaces()
     for intf in interfaces.values():
         for host in self.test_topology.hosts():
             ip = ip_addr_to_str(intf.address[0].ip)
             for host_intf in host.intfs():
                 if ":" in ip:
                     # for v6, always ping with "%eth0" in address
                     ip = ip + "%%%s" % host_intf
                 self.log.info("Ping from %s to %s" % (host, ip))
                 with host.thrift_client() as client:
                     self.assertTrue(client.ping(ip))
Beispiel #7
0
 def test_all_router_ips(self):
     """ Does every router IP get COPP classified correctly?
     """
     with self.test_topology.switch_thrift() as switch_thrift:
         interfaces = switch_thrift.getAllInterfaces()
         self.assertIsNotNone(interfaces)
     test_bgp_pkts = []
     test_non_bgp_pkts = []
     for intf in interfaces.values():
         for prefix in intf.address:
             test_bgp_pkts.append(
                 packet.gen_pkt_to_switch(self,
                                          dst_ip=ip_addr_to_str(prefix.ip),
                                          dst_port=179))
             test_non_bgp_pkts.append(
                 packet.gen_pkt_to_switch(self,
                                          dst_ip=ip_addr_to_str(prefix.ip),
                                          dst_port=12345))
     # make sure each bgp-like pkt bumps the hi-pri counter
     self.send_pkts_verify_counter_bump(
         test_bgp_pkts, "cpu.queue%d.in_pkts.sum" % HIGH_PRI_QUEUE)
     # make sure each non-bgp pkt bumps the mid-pri counter
     self.send_pkts_verify_counter_bump(
         test_non_bgp_pkts, "cpu.queue%d.in_pkts.sum" % MID_PRI_QUEUE)