blob: 641f5080095726b4cb1841f5518e7ee60cc6662a [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
17 test_vid =1
18 #add vlan flow to pass vlan verification
19 add_l2_interface_grouop(self.controller, test_ports, vlan_id=test_vid, is_tagged=False, send_barrier=False)
20 add_vlan_table_flow(self.controller, test_ports, vlan_id=test_vid, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False)
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();
25 l2_mcast_group=add_l2_mcast_group(self.controller, [FLOOD_TO_PORT], vlanid=test_vid, mcast_grp_index=1)
26
27 #match ether_type=arp and da=bcast
28
29 match = ofp.match()
30 match.oxm_list.append(ofp.oxm.eth_type(0x0806)) #match arp ethertype
31 match.oxm_list.append(ofp.oxm.eth_dst([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) #match DA is bcast
32 request = ofp.message.flow_add(
33 table_id=60,
34 cookie=42,
35 match=match,
36 instructions=[ofp.instruction.write_actions(
37 actions=[ofp.action.group(l2_mcast_group.group_id)
38 ,ofp.action.output(port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER)
39 ])
40 ],
41 buffer_id=ofp.OFP_NO_BUFFER,
42 priority=1)
43
44 self.controller.message_send(request)
45
46 arp=simple_arp_packet()
47
48 for port in test_ports:
49 self.dataplane.send(port, str(arp))
50 verify_packet(self, str(arp), FLOOD_TO_PORT)
51 verify_packet_in(self, str(arp), port, ofp.OFPR_ACTION)
52 verify_no_other_packets(self)
53