macauley_cheng | 6b31161 | 2015-09-04 11:32:27 +0800 | [diff] [blame] | 1 | """
|
| 2 | Flow Test
|
| 3 |
|
| 4 | Test each flow table can set entry, and packet rx correctly.
|
| 5 | """
|
| 6 |
|
| 7 | import logging
|
| 8 |
|
| 9 | from oftest import config
|
| 10 | import oftest.base_tests as base_tests
|
| 11 | import ofp
|
| 12 | from oftest.testutils import *
|
| 13 | from accton_util import *
|
| 14 |
|
| 15 | class qinq(base_tests.SimpleDataPlane):
|
| 16 | def runTest(self):
|
| 17 | delete_all_flows(self.controller)
|
| 18 | delete_all_groups(self.controller)
|
| 19 |
|
| 20 | in_port = config["port_map"].keys()[0]
|
| 21 | out_port=config["port_map"].keys()[1]
|
| 22 | out_vlan=10
|
| 23 | add_vlan_table_flow_pvid(self.controller, in_port, None, out_vlan, False)
|
| 24 | add_vlan_table_flow_pvid(self.controller, in_port, 1,out_vlan, False)
|
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 25 | group_id, msg=add_one_l2_interface_group(self.controller, out_port, out_vlan, True, False)
|
macauley_cheng | 6b31161 | 2015-09-04 11:32:27 +0800 | [diff] [blame] | 26 | #add acl
|
| 27 | match = ofp.match()
|
| 28 | match.oxm_list.append(ofp.oxm.in_port(in_port))
|
| 29 | request = ofp.message.flow_add(
|
| 30 | table_id=60,
|
| 31 | cookie=42,
|
| 32 | match=match,
|
| 33 | instructions=[
|
| 34 | ofp.instruction.write_actions(
|
| 35 | actions=[
|
| 36 | ofp.action.group(msg.group_id)])
|
| 37 | ],
|
| 38 | buffer_id=ofp.OFP_NO_BUFFER,
|
| 39 | priority=1000)
|
| 40 | self.controller.message_send(request)
|
| 41 |
|
| 42 | #input untag packet
|
| 43 |
|
| 44 | parsed_pkt = simple_tcp_packet(pktlen=100)
|
| 45 | pkt = str(parsed_pkt)
|
| 46 | self.dataplane.send(in_port, pkt)
|
| 47 |
|
| 48 | parsed_pkt = simple_tcp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=10)
|
| 49 | verify_packet(self, str(parsed_pkt), out_port)
|
| 50 |
|
| 51 | #input tag packet
|
| 52 | parsed_pkt = simple_tcp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=1)
|
| 53 | pkt = str(parsed_pkt)
|
| 54 | self.dataplane.send(in_port, pkt)
|
| 55 |
|
| 56 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=10,
|
| 57 | in_dl_vlan_enable=True, in_vlan_vid=1)
|
| 58 | verify_packet(self, str(parsed_pkt), out_port)
|