macauley | eebec63 | 2015-08-04 17:34:48 +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 | class RedirectArpToSpecifyPortOrController(base_tests.SimpleDataPlane):
|
| 11 | def runTest(self):
|
| 12 | delete_all_flows(self.controller)
|
| 13 | delete_all_groups(self.controller)
|
| 14 |
|
| 15 | test_ports = sorted(config["port_map"].keys())
|
| 16 |
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 17 | test_vid =2
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 18 | #add vlan flow to pass vlan verification
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 19 | add_l2_interface_grouop(self.controller, test_ports, vlan_id=test_vid, is_tagged=True, send_barrier=False)
|
| 20 | add_vlan_table_flow(self.controller, test_ports, vlan_id=test_vid, flag=VLAN_TABLE_FLAG_ONLY_TAG, send_barrier=False)
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 21 |
|
| 22 | #get a port to be the flood destination port,
|
| 23 | #remember test_ports already mius FLOOD_TO_PORT
|
| 24 | FLOOD_TO_PORT = test_ports.pop();
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 25 | l2_mcast_group=add_l2_mcast_group(self.controller, [FLOOD_TO_PORT], vlanid=test_vid, mcast_grp_index=test_vid)
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 26 |
|
| 27 | #match ether_type=arp and da=bcast
|
| 28 |
|
| 29 | match = ofp.match()
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 30 | match.oxm_list.append(ofp.oxm.vlan_vid(test_vid)) #match arp ethertype
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 31 | match.oxm_list.append(ofp.oxm.eth_type(0x0806)) #match arp ethertype
|
| 32 | match.oxm_list.append(ofp.oxm.eth_dst([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) #match DA is bcast
|
| 33 | request = ofp.message.flow_add(
|
| 34 | table_id=60,
|
| 35 | cookie=42,
|
| 36 | match=match,
|
| 37 | instructions=[ofp.instruction.write_actions(
|
| 38 | actions=[ofp.action.group(l2_mcast_group.group_id)
|
| 39 | ,ofp.action.output(port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER)
|
| 40 | ])
|
| 41 | ],
|
| 42 | buffer_id=ofp.OFP_NO_BUFFER,
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 43 | priority=10)
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 44 |
|
| 45 | self.controller.message_send(request)
|
| 46 |
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 47 | arp=simple_arp_packet(vlan_vid=test_vid)
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 48 |
|
| 49 | for port in test_ports:
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 50 | print "send on port %ld"%port
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 51 | self.dataplane.send(port, str(arp))
|
| 52 | verify_packet(self, str(arp), FLOOD_TO_PORT)
|
| 53 | verify_packet_in(self, str(arp), port, ofp.OFPR_ACTION)
|
| 54 | verify_no_other_packets(self)
|
| 55 |
|