Ejemplo n.º 1
0
    def runTest(self):
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[3]
        
        # Remove all entries Add entry match all
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")

        # Add entry match 

        request = message.flow_mod()
        request.match.type = ofp.OFPMT_OXM
        port = match.in_port(of_ports[0])
        eth_type = match.eth_type(IPV6_ETHERTYPE)
        ipv6_src = match.ipv6_src(ipaddr.IPv6Address('fe80::2420:52ff:fe8f:5189'))
        
        request.match_fields.tlvs.append(port)
        request.match_fields.tlvs.append(eth_type)
        request.match_fields.tlvs.append(ipv6_src)
        
        field_2b_set = match.ipv6_dst(ipaddr.IPv6Address('fe80::2420:52ff:fe8f:DDDD'))
        act_setfield = action.action_set_field()
        act_setfield.field = field_2b_set
        
#       TODO: insert action set field properly
        act_out = action.action_output()
        act_out.port = of_ports[3]
        
        
        inst = instruction.instruction_apply_actions()
        inst.actions.add(act_setfield)
        inst.actions.add(act_out)
        request.instructions.add(inst)
        request.buffer_id = 0xffffffff
        
        request.priority = 1000
        ipv6_logger.debug("Adding flow ")
        
        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Failed to insert test flow")

        #Send packet
        pkt = testutils.simple_ipv6_packet(ip_src='fe80::2420:52ff:fe8f:5189',ip_dst='fe80::2420:52ff:fe8f:5190')
        ipv6_logger.info("Sending IPv6 packet to " + str(ing_port))
        ipv6_logger.debug("Data: " + str(pkt).encode('hex'))
        self.dataplane.send(ing_port, str(pkt))
        
        #Receive packet
        exp_pkt = testutils.simple_ipv6_packet(ip_dst='fe80::2420:52ff:fe8f:DDDD')
        testutils.receive_pkt_verify(self, egr_port, exp_pkt)

        #See flow match
        response = testutils.flow_stats_get(self)
        ipv6_logger.debug("Response" + response.show())
        
        #Remove flows
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")    
Ejemplo n.º 2
0
    def runTest(self):
        ing_port = flow_mods_port_map.keys()[0]
        egr_port = flow_mods_port_map.keys()[1]
        table_id = testutils.EX_L3_TABLE
        flow_count = 10

        testutils.delete_all_flows_one_table(self.controller, self.logger,
                                             table_id)
        match_fields_ls = []
        ipv6_src_addr = 'fe80::2420:52ff:fe8f:5188'
        metadata_val = 0xaa22334455667788
        for i in range(flow_count):
            match_fields_ls.append(match_list())
            match_fields_ls[i].add(match.eth_type(testutils.IPV6_ETHERTYPE))
            match_fields_ls[i].add(
                match.ipv6_src(ipaddr.IPv6Address(ipv6_src_addr)))
            ipv6_dst_addr = 'fe80::2420:52ff:fe8f:' + str(5190 + i)
            match_fields_ls[i].add(
                match.ipv6_dst(ipaddr.IPv6Address(ipv6_dst_addr)))
            match_fields_ls[i].add(match.metadata(metadata_val))

            request = testutils.flow_msg_create(
                self,
                None,
                ing_port=ing_port,
                match_fields=match_fields_ls[i],
                egr_port=egr_port,
                table_id=table_id)
            testutils.flow_msg_install(self, request, False)

        match_fields = match_list()
        match_fields.add(match.eth_type(testutils.IPV6_ETHERTYPE))
        match_fields.add(match.ipv6_src(ipaddr.IPv6Address(ipv6_src_addr)))

        response = testutils.flow_stats_get(self, table_id=table_id)
        self.assertTrue(
            len(response.stats) == flow_count,
            'Did not add all flows successfully! Get table entry num is %d' %
            len(response.stats))

        request = testutils.flow_msg_create(self,
                                            None,
                                            None,
                                            ing_port,
                                            match_fields,
                                            table_id=table_id)
        request.command = ofp.OFPFC_DELETE
        testutils.flow_msg_install(self, request, False)

        response = testutils.flow_stats_get(self, table_id=table_id)

        self.assertTrue(
            len(response.stats) == 0,
            'Switch did not del the flow entry! Current table entry num is %d'
            % len(response.stats))
Ejemplo n.º 3
0
    def runTest(self):
        ing_port = flow_mods_port_map.keys()[0]
        egr_port = flow_mods_port_map.keys()[1]
        table_id = testutils.EX_L3_TABLE
        flow_count = 10

        testutils.delete_all_flows_one_table(self.controller, self.logger, table_id)
        match_fields_ls = []
        ipv6_src_addr = 'fe80::2420:52ff:fe8f:5188'
        metadata_val = 0xaa22334455667788
        for i in range(flow_count):
            match_fields_ls.append(match_list())
            match_fields_ls[i].add(match.eth_type(testutils.IPV6_ETHERTYPE))
            match_fields_ls[i].add(match.ipv6_src(ipaddr.IPv6Address(ipv6_src_addr)))
            ipv6_dst_addr = 'fe80::2420:52ff:fe8f:' + str(5190+i)
            match_fields_ls[i].add(match.ipv6_dst(ipaddr.IPv6Address(ipv6_dst_addr)))
            match_fields_ls[i].add(match.metadata(metadata_val))

            request = testutils.flow_msg_create(self, None, ing_port=ing_port, 
                                    match_fields = match_fields_ls[i], egr_port = egr_port, table_id = table_id)
            testutils.flow_msg_install(self, request, False)

        match_fields = match_list()
        match_fields.add(match.eth_type(testutils.IPV6_ETHERTYPE))
        match_fields.add(match.ipv6_src(ipaddr.IPv6Address(ipv6_src_addr)))

        response = testutils.flow_stats_get(self, table_id = table_id)
        self.assertTrue(len(response.stats) == flow_count,
                    'Did not add all flows successfully! Get table entry num is %d'  %len(response.stats))

        request = testutils.flow_msg_create(self, None, None, ing_port, match_fields, table_id = table_id)
        request.command = ofp.OFPFC_DELETE
        testutils.flow_msg_install(self, request, False)

        response = testutils.flow_stats_get(self, table_id = table_id)
        
        self.assertTrue(len(response.stats) == 0,
                    'Switch did not del the flow entry! Current table entry num is %d' %len(response.stats))
Ejemplo n.º 4
0
    def runTest(self):
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[2]
        table_id1 = testutils.EX_L3_TABLE
        table_id2 = testutils.WC_ALL_TABLE

        # Remove all entries Add entry match all
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")

        rv = testutils.set_table_config(self, table_id = table_id1)
        self.assertEqual(rv, 0, "Failed to set table config")

        # Add entry match
        pkt = testutils.simple_ipv6_packet(ip_dst='fe80::1:0:1234')
        pkt_metadata = {'metadata_val':0xabcdef0123456789,
                        'metadata_msk':0xffffffffffffffff}

        inst_ls1 = []
        inst1_write = instruction.instruction_write_metadata()
        inst1_write.metadata = pkt_metadata['metadata_val']
        inst1_write.metadata_mask = pkt_metadata['metadata_msk']

        inst1_goto = instruction.instruction_goto_table()
        inst1_goto.table_id = table_id2

        inst_ls1.append(inst1_write)
        inst_ls1.append(inst1_goto)
        request1 = testutils.flow_msg_create(self, pkt, ing_port = ing_port,
                            instruction_list = inst_ls1,
                            table_id = table_id1)

        testutils.flow_msg_install(self, request1)

        act_ls2 = []
        act2_setfld = action.action_set_field()
        act2_setfld.field = match.ipv6_dst(ipaddr.IPv6Address('fe80::1:6554:3e7f:1'))

        act2_out = action.action_output()
        act2_out.port = egr_port

        act_ls2.append(act2_setfld)
        act_ls2.append(act2_out)
        pkt_metadata = {'metadata_val':0xabcdef0100000000,
                        'metadata_msk':0xffffffff00000000}
        request2 = testutils.flow_msg_create(self, pkt, pkt_metadata, ing_port, 
                            action_list = act_ls2, table_id = table_id2)

        testutils.flow_msg_install(self, request2)

        #Send packet
        ipv6_logger.info("Sending IPv6 packet to " + str(ing_port))
        ipv6_logger.debug("Data: " + str(pkt).encode('hex'))
        self.dataplane.send(ing_port, str(pkt))

        #Receive packet
        exp_pkt = testutils.simple_ipv6_packet(ip_dst='fe80::1:6554:3e7f:1')
        testutils.receive_pkt_verify(self, egr_port, exp_pkt)

        #See flow match
        response = testutils.flow_stats_get(self)
        ipv6_logger.debug("Response" + response.show())

        #Remove flows
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")
Ejemplo n.º 5
0
    def runTest(self):
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[3]

        # Remove all entries Add entry match all
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")

        # Add entry match

        request = message.flow_mod()
        request.match.type = ofp.OFPMT_OXM
        port = match.in_port(of_ports[0])
        eth_type = match.eth_type(IPV6_ETHERTYPE)
        ipv6_src = match.ipv6_src(
            ipaddr.IPv6Address('fe80::2420:52ff:fe8f:5189'))

        request.match_fields.tlvs.append(port)
        request.match_fields.tlvs.append(eth_type)
        request.match_fields.tlvs.append(ipv6_src)

        field_2b_set = match.ipv6_dst(
            ipaddr.IPv6Address('fe80::2420:52ff:fe8f:DDDD'))
        act_setfield = action.action_set_field()
        act_setfield.field = field_2b_set

        #       TODO: insert action set field properly
        act_out = action.action_output()
        act_out.port = of_ports[3]

        inst = instruction.instruction_apply_actions()
        inst.actions.add(act_setfield)
        inst.actions.add(act_out)
        request.instructions.add(inst)
        request.buffer_id = 0xffffffff

        request.priority = 1000
        ipv6_logger.debug("Adding flow ")

        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Failed to insert test flow")

        #Send packet
        pkt = testutils.simple_ipv6_packet(ip_src='fe80::2420:52ff:fe8f:5189',
                                           ip_dst='fe80::2420:52ff:fe8f:5190')
        ipv6_logger.info("Sending IPv6 packet to " + str(ing_port))
        ipv6_logger.debug("Data: " + str(pkt).encode('hex'))
        self.dataplane.send(ing_port, str(pkt))

        #Receive packet
        exp_pkt = testutils.simple_ipv6_packet(
            ip_dst='fe80::2420:52ff:fe8f:DDDD')
        testutils.receive_pkt_verify(self, egr_port, exp_pkt)

        #See flow match
        response = testutils.flow_stats_get(self)
        ipv6_logger.debug("Response" + response.show())

        #Remove flows
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")
Ejemplo n.º 6
0
    def runTest(self):
        of_ports = ipv6_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[2]
        table_id1 = testutils.EX_L3_TABLE
        table_id2 = testutils.WC_ALL_TABLE

        # Remove all entries Add entry match all
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")

        rv = testutils.set_table_config(self, table_id=table_id1)
        self.assertEqual(rv, 0, "Failed to set table config")

        # Add entry match
        pkt = testutils.simple_ipv6_packet(ip_dst='fe80::1:0:1234')
        pkt_metadata = {
            'metadata_val': 0xabcdef0123456789,
            'metadata_msk': 0xffffffffffffffff
        }

        inst_ls1 = []
        inst1_write = instruction.instruction_write_metadata()
        inst1_write.metadata = pkt_metadata['metadata_val']
        inst1_write.metadata_mask = pkt_metadata['metadata_msk']

        inst1_goto = instruction.instruction_goto_table()
        inst1_goto.table_id = table_id2

        inst_ls1.append(inst1_write)
        inst_ls1.append(inst1_goto)
        request1 = testutils.flow_msg_create(self,
                                             pkt,
                                             ing_port=ing_port,
                                             instruction_list=inst_ls1,
                                             table_id=table_id1)

        testutils.flow_msg_install(self, request1)

        act_ls2 = []
        act2_setfld = action.action_set_field()
        act2_setfld.field = match.ipv6_dst(
            ipaddr.IPv6Address('fe80::1:6554:3e7f:1'))

        act2_out = action.action_output()
        act2_out.port = egr_port

        act_ls2.append(act2_setfld)
        act_ls2.append(act2_out)
        pkt_metadata = {
            'metadata_val': 0xabcdef0100000000,
            'metadata_msk': 0xffffffff00000000
        }
        request2 = testutils.flow_msg_create(self,
                                             pkt,
                                             pkt_metadata,
                                             ing_port,
                                             action_list=act_ls2,
                                             table_id=table_id2)

        testutils.flow_msg_install(self, request2)

        #Send packet
        ipv6_logger.info("Sending IPv6 packet to " + str(ing_port))
        ipv6_logger.debug("Data: " + str(pkt).encode('hex'))
        self.dataplane.send(ing_port, str(pkt))

        #Receive packet
        exp_pkt = testutils.simple_ipv6_packet(ip_dst='fe80::1:6554:3e7f:1')
        testutils.receive_pkt_verify(self, egr_port, exp_pkt)

        #See flow match
        response = testutils.flow_stats_get(self)
        ipv6_logger.debug("Response" + response.show())

        #Remove flows
        rc = testutils.delete_all_flows(self.controller, ipv6_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")