blob: a040089d7033d7cf0cd5292cde9b379e3ace779f [file] [log] [blame]
macauleyeebec632015-08-04 17:34:48 +08001import logging
2
3from oftest import config
4import oftest.base_tests as base_tests
5import ofp
6from oftest.testutils import *
7from accton_util import *
8
9
10class 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_cheng8f538dc2015-08-19 17:04:57 +080017 test_vid =2
macauleyeebec632015-08-04 17:34:48 +080018 #add vlan flow to pass vlan verification
macauley_cheng8f538dc2015-08-19 17:04:57 +080019 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)
macauleyeebec632015-08-04 17:34:48 +080021
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_cheng8f538dc2015-08-19 17:04:57 +080025 l2_mcast_group=add_l2_mcast_group(self.controller, [FLOOD_TO_PORT], vlanid=test_vid, mcast_grp_index=test_vid)
macauleyeebec632015-08-04 17:34:48 +080026
27 #match ether_type=arp and da=bcast
28
29 match = ofp.match()
macauley_cheng8f538dc2015-08-19 17:04:57 +080030 match.oxm_list.append(ofp.oxm.vlan_vid(test_vid)) #match arp ethertype
macauleyeebec632015-08-04 17:34:48 +080031 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_cheng8f538dc2015-08-19 17:04:57 +080043 priority=10)
macauleyeebec632015-08-04 17:34:48 +080044
45 self.controller.message_send(request)
46
macauley_cheng8f538dc2015-08-19 17:04:57 +080047 arp=simple_arp_packet(vlan_vid=test_vid)
macauleyeebec632015-08-04 17:34:48 +080048
49 for port in test_ports:
macauley_cheng8f538dc2015-08-19 17:04:57 +080050 print "send on port %ld"%port
macauleyeebec632015-08-04 17:34:48 +080051 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