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_cheng | 79927b6 | 2015-08-27 14:31:41 +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 | class PacketInMiss(base_tests.SimpleDataPlane):
|
| 26 | """
|
| 27 | Test packet in function for a table-miss flow
|
| 28 |
|
| 29 | Send a packet to each dataplane port and verify that a packet
|
| 30 | in message is received from the controller for each
|
| 31 |
|
| 32 | NOTE: Verify This case the oft option shall not use --switch-ip
|
| 33 | """
|
| 34 |
|
| 35 | def runTest(self):
|
| 36 | delete_all_flows(self.controller)
|
| 37 | delete_all_groups(self.controller)
|
| 38 |
|
| 39 | # table 10: vlan
|
| 40 | # send to table 20
|
| 41 | add_vlan_table_flow(self.controller, config["port_map"].keys(), 1)
|
| 42 |
|
| 43 | # group table
|
| 44 | # set up untag groups for each port
|
| 45 | add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, 1)
|
| 46 |
|
| 47 | verify_port = config["port_map"].keys()[0]
|
| 48 |
|
| 49 | # create match
|
| 50 | match = ofp.match()
|
| 51 | match.oxm_list.append(ofp.oxm.in_port(verify_port))
|
| 52 | match.oxm_list.append(ofp.oxm.eth_type(0x0800))
|
| 53 | match.oxm_list.append(ofp.oxm.ipv4_dst_masked(0xa0a0a0a, 0xffffffff))
|
| 54 | request = ofp.message.flow_add(
|
| 55 | table_id=60,
|
| 56 | cookie=42,
|
| 57 | match=match,
|
| 58 | instructions=[
|
| 59 | ofp.instruction.apply_actions(
|
| 60 | actions=[
|
| 61 | ofp.action.output(
|
| 62 | port=ofp.OFPP_CONTROLLER,
|
| 63 | max_len=ofp.OFPCML_NO_BUFFER)]),
|
| 64 | ],
|
| 65 | buffer_id=ofp.OFP_NO_BUFFER,
|
| 66 | priority=1)
|
| 67 |
|
| 68 | logging.info("Inserting packet in flow to controller")
|
| 69 | self.controller.message_send(request)
|
| 70 | do_barrier(self.controller)
|
| 71 |
|
| 72 |
|
| 73 | logging.info("PacketInMiss test, port %d", verify_port)
|
| 74 | parsed_pkt = simple_tcp_packet(pktlen=100, ip_dst="10.10.10.10")
|
| 75 | pkt = str(parsed_pkt)
|
| 76 | self.dataplane.send(verify_port, pkt)
|
| 77 |
|
| 78 | #AOS current packet in will not have vlan tag
|
| 79 | verify_packet_in(self, pkt, verify_port, ofp.OFPR_ACTION)
|
| 80 |
|
| 81 | verify_no_other_packets(self)
|