blob: 76a72b149bb1974f3606bbb8d1dd8179f91f1f53 [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
macauleyeebec632015-08-04 17:34:48 +080017import logging
18
19from oftest import config
20import oftest.base_tests as base_tests
21import ofp
22from oftest.testutils import *
23from accton_util import *
24
25
26class RedirectArpToSpecifyPortOrController(base_tests.SimpleDataPlane):
27 def runTest(self):
28 delete_all_flows(self.controller)
29 delete_all_groups(self.controller)
30
31 test_ports = sorted(config["port_map"].keys())
32
macauley_cheng8f538dc2015-08-19 17:04:57 +080033 test_vid =2
macauleyeebec632015-08-04 17:34:48 +080034 #add vlan flow to pass vlan verification
macauley_cheng8f538dc2015-08-19 17:04:57 +080035 add_l2_interface_grouop(self.controller, test_ports, vlan_id=test_vid, is_tagged=True, send_barrier=False)
36 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 +080037
38 #get a port to be the flood destination port,
39 #remember test_ports already mius FLOOD_TO_PORT
40 FLOOD_TO_PORT = test_ports.pop();
macauley_cheng8f538dc2015-08-19 17:04:57 +080041 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 +080042
43 #match ether_type=arp and da=bcast
44
45 match = ofp.match()
macauley_cheng8f538dc2015-08-19 17:04:57 +080046 match.oxm_list.append(ofp.oxm.vlan_vid(test_vid)) #match arp ethertype
macauleyeebec632015-08-04 17:34:48 +080047 match.oxm_list.append(ofp.oxm.eth_type(0x0806)) #match arp ethertype
48 match.oxm_list.append(ofp.oxm.eth_dst([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) #match DA is bcast
49 request = ofp.message.flow_add(
50 table_id=60,
51 cookie=42,
52 match=match,
53 instructions=[ofp.instruction.write_actions(
54 actions=[ofp.action.group(l2_mcast_group.group_id)
55 ,ofp.action.output(port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER)
56 ])
57 ],
58 buffer_id=ofp.OFP_NO_BUFFER,
macauley_cheng8f538dc2015-08-19 17:04:57 +080059 priority=10)
macauleyeebec632015-08-04 17:34:48 +080060
61 self.controller.message_send(request)
62
macauley_cheng8f538dc2015-08-19 17:04:57 +080063 arp=simple_arp_packet(vlan_vid=test_vid)
macauleyeebec632015-08-04 17:34:48 +080064
65 for port in test_ports:
macauley_cheng8f538dc2015-08-19 17:04:57 +080066 print "send on port %ld"%port
macauleyeebec632015-08-04 17:34:48 +080067 self.dataplane.send(port, str(arp))
68 verify_packet(self, str(arp), FLOOD_TO_PORT)
69 verify_packet_in(self, str(arp), port, ofp.OFPR_ACTION)
70 verify_no_other_packets(self)
71