Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame^] | 1 | |
| 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 | |
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 17 | import logging
|
| 18 |
|
| 19 | from oftest import config
|
| 20 | import oftest.base_tests as base_tests
|
| 21 | import ofp
|
| 22 | from oftest.testutils import *
|
| 23 | from accton_util import *
|
| 24 |
|
| 25 |
|
| 26 | class 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_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 33 | test_vid =2
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 34 | #add vlan flow to pass vlan verification
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 35 | 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)
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 37 |
|
| 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_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 41 | 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] | 42 |
|
| 43 | #match ether_type=arp and da=bcast
|
| 44 |
|
| 45 | match = ofp.match()
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 46 | match.oxm_list.append(ofp.oxm.vlan_vid(test_vid)) #match arp ethertype
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 47 | 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_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 59 | priority=10)
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 60 |
|
| 61 | self.controller.message_send(request)
|
| 62 |
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 63 | arp=simple_arp_packet(vlan_vid=test_vid)
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 64 |
|
| 65 | for port in test_ports:
|
macauley_cheng | 8f538dc | 2015-08-19 17:04:57 +0800 | [diff] [blame] | 66 | print "send on port %ld"%port
|
macauley | eebec63 | 2015-08-04 17:34:48 +0800 | [diff] [blame] | 67 | 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 |
|