macauley_cheng | 6e6a612 | 2015-11-16 14:19:18 +0800 | [diff] [blame] | 1 | import logging
|
| 2 |
|
| 3 | from oftest import config
|
| 4 | import oftest.base_tests as base_tests
|
| 5 | import ofp
|
| 6 | from oftest.testutils import *
|
| 7 | from accton_util import *
|
| 8 |
|
| 9 | """
|
| 10 | This file test case is copied from NTC EPR bug
|
| 11 | """
|
| 12 |
|
| 13 | class pvidClear(base_tests.SimpleDataPlane):
|
| 14 | """
|
| 15 | AOS5700-54X-00620
|
| 16 | """
|
| 17 | def runTest(self):
|
| 18 | ports = sorted(config["port_map"].keys())
|
| 19 | delete_all_flows(self.controller)
|
| 20 | delete_all_groups(self.controller)
|
| 21 | port1=ports[0]
|
| 22 | port2=ports[1]
|
| 23 |
|
| 24 | vlan_id = 10
|
| 25 |
|
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 26 | gid_p1, req_msg_p1 = add_one_l2_interface_group(self.controller, port=port1, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
|
| 27 | gid_p2, req_msg_p2 = add_one_l2_interface_group(self.controller, port=port2, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
|
macauley_cheng | 6e6a612 | 2015-11-16 14:19:18 +0800 | [diff] [blame] | 28 | #add ACL flow, in port1 out port2
|
| 29 | match = ofp.match()
|
| 30 | match.oxm_list.append(ofp.oxm.in_port(port1))
|
| 31 | request = ofp.message.flow_add(
|
| 32 | table_id=60,
|
| 33 | cookie=42,
|
| 34 | match=match,
|
| 35 | instructions=[
|
| 36 | ofp.instruction.write_actions(
|
| 37 | actions=[
|
| 38 | ofp.action.group(gid_p2)]
|
| 39 | )
|
| 40 | ],
|
| 41 | priority=1)
|
| 42 | #install flow
|
| 43 | self.controller.message_send(request)
|
| 44 | #add ACL flow, in port2 out port1
|
| 45 | match = ofp.match()
|
| 46 | match.oxm_list.append(ofp.oxm.in_port(port2))
|
| 47 | request = ofp.message.flow_add(
|
| 48 | table_id=60,
|
| 49 | cookie=42,
|
| 50 | match=match,
|
| 51 | instructions=[
|
| 52 | ofp.instruction.write_actions(
|
| 53 | actions=[
|
| 54 | ofp.action.group(gid_p1)]
|
| 55 | )
|
| 56 | ],
|
| 57 | priority=1)
|
| 58 | #install flow
|
| 59 | self.controller.message_send(request)
|
| 60 |
|
| 61 | #send packet and verify packet
|
| 62 | parsed_pkt = simple_tcp_packet()
|
| 63 | self.dataplane.send(port1, str(parsed_pkt))
|
| 64 | verify_no_packet(self, str(parsed_pkt), port2)
|
| 65 | self.dataplane.send(port2, str(parsed_pkt))
|
| 66 | verify_no_packet(self, str(parsed_pkt), port1)
|
| 67 |
|
| 68 |
|
| 69 | #add vlan flow table
|
| 70 | add_vlan_table_flow(self.controller, [port1, port2], vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG)
|
| 71 | #send packet and verify packet
|
| 72 | parsed_pkt = simple_tcp_packet()
|
| 73 | self.dataplane.send(port1, str(parsed_pkt))
|
| 74 | verify_packet(self, str(parsed_pkt), port2)
|
| 75 | self.dataplane.send(port2, str(parsed_pkt))
|
| 76 | verify_packet(self, str(parsed_pkt), port1)
|
| 77 |
|
| 78 | #remove vlan table flow
|
| 79 | del_vlan_table_flow(self.controller, [port1, port2], vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG)
|
| 80 | #send packet and verify packet
|
| 81 | parsed_pkt = simple_tcp_packet()
|
| 82 | self.dataplane.send(port1, str(parsed_pkt))
|
Macauley Cheng | 98cc459 | 2015-11-16 15:45:02 +0800 | [diff] [blame] | 83 | verify_no_packet(self, str(parsed_pkt), port2)
|
macauley_cheng | 6e6a612 | 2015-11-16 14:19:18 +0800 | [diff] [blame] | 84 | self.dataplane.send(port2, str(parsed_pkt))
|
| 85 | verify_no_packet(self, str(parsed_pkt), port1)
|
| 86 |
|
| 87 |
|
| 88 |
|
Macauley Cheng | 98cc459 | 2015-11-16 15:45:02 +0800 | [diff] [blame] | 89 |
|