コード例 #1
0
ファイル: multi-table.py プロジェクト: HuaweiSwitch/OpenFlow
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        # Clear flow table
        rv = testutils.initialize_table_config(self)
        self.assertEqual(rv, 0, "Failed to initialize table config")
        rv = testutils.delete_all_flows(self.controller, pa_logger)
        self.assertEqual(rv, 0, "Failed to delete all flows")

        # Set up first match,fengqiang modify at 20130109
        testutils.write_goto_output(self, testutils.EX_ACL_TABLE, testutils.WC_ACL_TABLE, of_ports[0])

        # Set up fourth match,fengqiang modify at 20130109
        testutils.write_output(self, testutils.WC_ACL_TABLE, of_ports[1])    
        
        # Generate a packet matching both flow 1 and flow 2; rcv on port[1]
        pkt = testutils.simple_tcp_packet(ip_src = testutils.MT_TEST_IP)
        self.dataplane.send(of_ports[2], str(pkt))
        (rcv_port, rcv_pkt, _) = self.dataplane.poll(timeout=5)
        self.assertTrue(rcv_pkt is not None, "Did not receive packet")
        pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
                        str(rcv_port))
        self.assertEqual(rcv_port, of_ports[1], "Unexpected receive port")
コード例 #2
0
ファイル: multi-table.py プロジェクト: HuaweiSwitch/OpenFlow
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; do nothing // match but stop pipeline
        Fourth Table; Match IP Src A; send to 2  // not match, just a fake

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_VLAN_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.EX_ACL_TABLE, testutils.WC_ACL_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE, of_ports[0])

        # Set up third match
        testutils.write_output(self, testutils.WC_SERV_TABLE, of_ports[1], of_ports[2])

        # Set up fourth match
        testutils.write_output(self, testutils.EX_VLAN_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[0]
        testutils.reply_check_dp(self, tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[1])
コード例 #3
0
ファイル: multi-table.py プロジェクト: HuaweiSwitch/OpenFlow
    def runTest(self):
        """
        ** Currently, same scenario with "NoGoto" **

        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; do nothing // match but stop pipeline
        Fourth Table; Match IP Src A; send to 2  // not match, just a fake

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE, testutils.EX_L2_TABLE,
                                                                        of_ports[0], of_ports[2])

        # Set up third match, "Empty Instruction"
        pkt = testutils.simple_tcp_packet()
        request = testutils.flow_msg_create(self, pkt, ing_port = of_ports[2], table_id = testutils.EX_L2_TABLE)
        testutils.flow_msg_install(self, request)

        # Set up fourth match
        testutils.write_output(self, testutils.EX_VLAN_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[0]
        testutils.reply_check_dp(self, tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[0])
コード例 #4
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        # Clear flow table
        rv = testutils.initialize_table_config(self)
        self.assertEqual(rv, 0, "Failed to initialize table config")
        rv = testutils.delete_all_flows(self.controller, pa_logger)
        self.assertEqual(rv, 0, "Failed to delete all flows")

        # Set up first match,fengqiang modify at 20130109
        testutils.write_goto_output(self, testutils.EX_ACL_TABLE,
                                    testutils.WC_ACL_TABLE, of_ports[0])

        # Set up fourth match,fengqiang modify at 20130109
        testutils.write_output(self, testutils.WC_ACL_TABLE, of_ports[1])

        # Generate a packet matching both flow 1 and flow 2; rcv on port[1]
        pkt = testutils.simple_tcp_packet(ip_src=testutils.MT_TEST_IP)
        self.dataplane.send(of_ports[2], str(pkt))
        (rcv_port, rcv_pkt, _) = self.dataplane.poll(timeout=5)
        self.assertTrue(rcv_pkt is not None, "Did not receive packet")
        pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
                        str(rcv_port))
        self.assertEqual(rcv_port, of_ports[1], "Unexpected receive port")
コード例 #5
0
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; send to 1, goto Second Table
        Second Table; Match IP Src A; write metadata, goto Third Table
        Third Table; Match IP Src A and metadata; send to 2 // stop, do action
        Fourth Table; Match IP Src A; send to 1 // not match, just a trap

        Then send in 2 packets:
        IP A, TCP C; expect out port 2
        IP A, TCP B; expect out port 2

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_VLAN_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto_output(self, testutils.WC_ACL_TABLE,
                                    testutils.WC_SERV_TABLE, of_ports[0])

        # Set up second match
        inst = instruction.instruction_write_metadata()
        inst.metadata = 0xfedcba9876543210
        inst.metadata_mask = 0xffffffffffffffff
        testutils.write_goto(self,
                             testutils.WC_SERV_TABLE,
                             testutils.EX_L2_TABLE,
                             of_ports[2],
                             add_inst=inst)

        # Set up third match
        pkt_metadata = {
            'metadata_val': inst.metadata,
            'metadata_msk': inst.metadata_mask
        }
        match_fields = testutils.packet_to_exact_flow_match(
            pkt_metadata=pkt_metadata, table_id=testutils.EX_L2_TABLE)

        testutils.write_output(self,
                               testutils.EX_L2_TABLE,
                               of_ports[1],
                               match_fields=match_fields)

        # Set up fourth match
        #write_output(self, testutils.EX_VLAN_TABLE, of_ports[0])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[1])
コード例 #6
0
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; clear action, goto Fourth Table
        Fourth Table; Match IP Src A; send to 2

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_L2_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        #write_goto(self, testutils.EX_ACL_TABLE, testutils.WC_ACL_TABLE)
        act = action.action_set_field()
        field = match.eth_src(parse.parse_mac("aa:aa:aa:aa:aa:aa"))
        act.field.add(field)
        testutils.write_goto_action(self,
                                    testutils.WC_ACL_TABLE,
                                    testutils.WC_SERV_TABLE,
                                    act=act)
        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE,
                                    testutils.EX_L3_TABLE, of_ports[0],
                                    of_ports[2])
        # Set up third match, "Clear Action"
        inst = instruction.instruction_clear_actions()
        testutils.write_goto(self,
                             testutils.EX_L3_TABLE,
                             testutils.WC_L3_TABLE,
                             of_ports[2],
                             add_inst=inst)
        # Set up fourth match
        testutils.write_output(self, testutils.WC_L3_TABLE, of_ports[1])
        #write_output(self, testutils.EX_L2_TABLE, 4)

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[1])
コード例 #7
0
ファイル: multi-table.py プロジェクト: HuaweiSwitch/OpenFlow
    def runTest(self):
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE, testutils.EX_L2_TABLE, of_ports[0], of_ports[1])

        # Set up third match
        testutils.write_output(self, testutils.EX_L2_TABLE, of_ports[2])
        
        # Generate a packet and receive 3 responses
        pkt = testutils.simple_tcp_packet(ip_src = testutils.MT_TEST_IP)
        self.dataplane.send(of_ports[1], str(pkt))

        testutils.receive_pkt_verify(self, of_ports[2], pkt)
コード例 #8
0
ファイル: multi-table.py プロジェクト: HuaweiSwitch/OpenFlow
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; send to 1, goto Second Table
        Second Table; Match IP Src A; write metadata, goto Third Table
        Third Table; Match IP Src A and metadata; send to 2 // stop, do action
        Fourth Table; Match IP Src A; send to 1 // not match, just a trap

        Then send in 2 packets:
        IP A, TCP C; expect out port 2
        IP A, TCP B; expect out port 2

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_VLAN_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto_output(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE, of_ports[0])

        # Set up second match
        inst = instruction.instruction_write_metadata()
        inst.metadata = 0xfedcba9876543210
        inst.metadata_mask = 0xffffffffffffffff
        testutils.write_goto(self, testutils.WC_SERV_TABLE, testutils.EX_L2_TABLE, of_ports[2], add_inst=inst)

        # Set up third match
        pkt_metadata = {'metadata_val':inst.metadata, 'metadata_msk':inst.metadata_mask}
        match_fields = testutils.packet_to_exact_flow_match(pkt_metadata = pkt_metadata,
                                                            table_id = testutils.EX_L2_TABLE)

        testutils.write_output(self, testutils.EX_L2_TABLE, of_ports[1], match_fields=match_fields)

        # Set up fourth match
        #write_output(self, testutils.EX_VLAN_TABLE, of_ports[0])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self, tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[1])
コード例 #9
0
    def runTest(self):
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE,
                             testutils.WC_SERV_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE,
                                    testutils.EX_L2_TABLE, of_ports[0],
                                    of_ports[1])

        # Set up third match
        testutils.write_output(self, testutils.EX_L2_TABLE, of_ports[2])

        # Generate a packet and receive 3 responses
        pkt = testutils.simple_tcp_packet(ip_src=testutils.MT_TEST_IP)
        self.dataplane.send(of_ports[1], str(pkt))

        testutils.receive_pkt_verify(self, of_ports[2], pkt)
コード例 #10
0
    def runTest(self):
        """
        ** Currently, same scenario with "NoGoto" **

        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; do nothing // match but stop pipeline
        Fourth Table; Match IP Src A; send to 2  // not match, just a fake

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.WC_ACL_TABLE,
                             testutils.WC_SERV_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE,
                                    testutils.EX_L2_TABLE, of_ports[0],
                                    of_ports[2])

        # Set up third match, "Empty Instruction"
        pkt = testutils.simple_tcp_packet()
        request = testutils.flow_msg_create(self,
                                            pkt,
                                            ing_port=of_ports[2],
                                            table_id=testutils.EX_L2_TABLE)
        testutils.flow_msg_install(self, request)

        # Set up fourth match
        testutils.write_output(self, testutils.EX_VLAN_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[0]
        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[0])
コード例 #11
0
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; do nothing // match but stop pipeline
        Fourth Table; Match IP Src A; send to 2  // not match, just a fake

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_VLAN_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        testutils.write_goto(self, testutils.EX_ACL_TABLE,
                             testutils.WC_ACL_TABLE)

        # Set up second match
        testutils.write_goto_output(self, testutils.WC_ACL_TABLE,
                                    testutils.WC_SERV_TABLE, of_ports[0])

        # Set up third match
        testutils.write_output(self, testutils.WC_SERV_TABLE, of_ports[1],
                               of_ports[2])

        # Set up fourth match
        testutils.write_output(self, testutils.EX_VLAN_TABLE, of_ports[1])

        # Generate a packet matching flow 1, 2, and 3; rcv on port[0]
        testutils.reply_check_dp(self,
                                 tcp_sport=1234,
                                 ing_port=of_ports[2],
                                 egr_port=of_ports[1])
コード例 #12
0
ファイル: multi-table.py プロジェクト: HuaweiSwitch/OpenFlow
    def runTest(self):
        """
        Add four flow entries:
        First Table; Match IP Src A; goto Second Table
        Second Table; Match IP Src A; send to 1, goto Third Table
        Third Table; Match IP Src A; clear action, goto Fourth Table
        Fourth Table; Match IP Src A; send to 2

        Then send in 2 packets:
        IP A, TCP C; expect out port 1
        IP A, TCP B; expect out port 1

        @param self object instance
        @param EX_ACL_TABLE first table
        @param WC_ACL_TABLE second table
        @param WC_SERV_TABLE third table
        @param EX_L2_TABLE fourth table
        """
        of_ports = testutils.clear_switch(self, pa_port_map.keys(), pa_logger)

        # Set up first match
        #write_goto(self, testutils.EX_ACL_TABLE, testutils.WC_ACL_TABLE)
        act = action.action_set_field()
        field = match.eth_src(parse.parse_mac("aa:aa:aa:aa:aa:aa"))
        act.field.add(field)
        testutils.write_goto_action(self, testutils.WC_ACL_TABLE, testutils.WC_SERV_TABLE ,act = act)
        # Set up second match
        testutils.write_goto_output(self, testutils.WC_SERV_TABLE, testutils.EX_L3_TABLE, of_ports[0], of_ports[2])
        # Set up third match, "Clear Action"
        inst = instruction.instruction_clear_actions()
        testutils.write_goto(self, testutils.EX_L3_TABLE, testutils.WC_L3_TABLE, of_ports[2], add_inst=inst)
        # Set up fourth match
        testutils.write_output(self, testutils.WC_L3_TABLE, of_ports[1])
        #write_output(self, testutils.EX_L2_TABLE, 4)

        # Generate a packet matching flow 1, 2, and 3; rcv on port[1]
        testutils.reply_check_dp(self, tcp_sport=1234,
                       ing_port = of_ports[2], egr_port = of_ports[1])