Rich Lane | 1568b65 | 2013-01-04 16:53:13 -0800 | [diff] [blame] | 1 | """ |
| 2 | These tests require a switch that drops packet-ins. |
| 3 | """ |
| 4 | |
| 5 | import logging |
| 6 | |
| 7 | from oftest import config |
| 8 | import oftest.controller as controller |
| 9 | import oftest.cstruct as ofp |
| 10 | import oftest.message as message |
| 11 | import oftest.dataplane as dataplane |
| 12 | import oftest.action as action |
| 13 | import oftest.base_tests as base_tests |
| 14 | |
| 15 | from oftest.testutils import * |
| 16 | |
| 17 | @nonstandard |
| 18 | class PacketInDefaultDrop(base_tests.SimpleDataPlane): |
| 19 | """ |
| 20 | Verify that packet-ins are not received. |
| 21 | """ |
| 22 | |
| 23 | def runTest(self): |
| 24 | delete_all_flows(self.controller) |
| 25 | do_barrier(self.controller) |
| 26 | |
| 27 | for of_port in config["port_map"].keys(): |
| 28 | pkt = simple_tcp_packet() |
| 29 | self.dataplane.send(of_port, str(pkt)) |
| 30 | count = 0 |
| 31 | while True: |
| 32 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN) |
| 33 | if not response: # Timeout |
| 34 | break |
| 35 | if dataplane.match_exp_pkt(pkt, response.data): # Got match |
| 36 | break |
| 37 | if not config["relax"]: # Only one attempt to match |
| 38 | break |
| 39 | count += 1 |
| 40 | if count > 10: # Too many tries |
| 41 | break |
| 42 | |
| 43 | self.assertTrue(response is None, |
| 44 | 'Packet in message received on port ' + |
| 45 | str(of_port)) |