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 | |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 17 | """These tests fall under Conformance Test-Suite (OF-SWITCH-1.0.0 TestCases). |
| 18 | Refer Documentation -- Detailed testing methodology |
| 19 | <Some of test-cases are directly taken from oftest> """ |
| 20 | |
| 21 | "Test Suite 3 --> Detailed Controller to switch messages" |
| 22 | |
| 23 | import logging |
| 24 | |
| 25 | import unittest |
| 26 | import random |
| 27 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 28 | from oftest import config |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 29 | import oftest.controller as controller |
Rich Lane | d7b0ffa | 2013-03-08 15:53:42 -0800 | [diff] [blame] | 30 | import ofp |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 31 | import oftest.dataplane as dataplane |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 32 | import oftest.parse as parse |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 33 | import oftest.base_tests as base_tests |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 34 | |
Rich Lane | da3b5ad | 2012-10-03 09:05:32 -0700 | [diff] [blame] | 35 | from oftest.testutils import * |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 36 | from time import sleep |
| 37 | from FuncUtils import * |
| 38 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 39 | class OverlapChecking(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 40 | |
| 41 | """Verify that if overlap check flag is set in the flow entry and an overlapping flow is inserted then an error |
| 42 | is generated and switch refuses flow entry""" |
| 43 | |
| 44 | def runTest(self): |
| 45 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 46 | logging.info("Running Overlap_Checking test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 47 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 48 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 49 | of_ports.sort() |
| 50 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 51 | |
| 52 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 53 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 54 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 55 | logging.info("Inserting two overlapping flows") |
| 56 | logging.info("Expecting switch to return an error") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 57 | |
| 58 | #Insert a flow F with wildcarded all fields |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 59 | (pkt,match) = wildcard_all(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 60 | |
| 61 | #Verify flow is active |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 62 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 63 | |
| 64 | # Build a overlapping flow F'-- Wildcard All except ingress with check overlap bit set |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 65 | pkt_matchingress = simple_tcp_packet() |
| 66 | match3 = parse.packet_to_flow_match(pkt_matchingress) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 67 | self.assertTrue(match3 is not None, "Could not generate flow match from pkt") |
| 68 | match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT |
| 69 | match3.in_port = of_ports[0] |
| 70 | |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 71 | msg3 = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 72 | msg3.match = match3 |
| 73 | msg3.flags |= ofp.OFPFF_CHECK_OVERLAP |
| 74 | msg3.cookie = random.randint(0,9007199254740992) |
| 75 | msg3.buffer_id = 0xffffffff |
| 76 | |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 77 | act3 = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 78 | act3.port = of_ports[1] |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 79 | msg3.actions.append(act3) |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 80 | self.controller.message_send(msg3) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 81 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 82 | |
| 83 | # Verify Flow does not get inserted |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 84 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 85 | |
| 86 | #Verify OFPET_FLOW_MOD_FAILED/OFPFMFC_OVERLAP error is recieved on the control plane |
| 87 | (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR, |
| 88 | timeout=5) |
| 89 | self.assertTrue(response is not None, |
| 90 | 'Switch did not reply with error message') |
Rich Lane | 4e361bb | 2013-03-11 13:57:31 -0700 | [diff] [blame] | 91 | self.assertTrue(response.err_type==ofp.OFPET_FLOW_MOD_FAILED, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 92 | 'Error message type is not flow mod failed ') |
| 93 | self.assertTrue(response.code==ofp.OFPFMFC_OVERLAP, |
| 94 | 'Error Message code is not overlap') |
| 95 | |
| 96 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 97 | class NoOverlapChecking(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 98 | |
| 99 | """Verify that without overlap check flag set, overlapping flows can be created.""" |
| 100 | |
| 101 | def runTest(self): |
| 102 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 103 | logging.info("Running No_Overlap_Checking test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 104 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 105 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 106 | of_ports.sort() |
| 107 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 108 | |
| 109 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 110 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 111 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 112 | logging.info("Inserting two overlapping flows") |
| 113 | logging.info("Expecting switch to insert the flows without generating errors") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 114 | |
| 115 | #Build a flow F with wildcarded all fields. |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 116 | (pkt,match) = wildcard_all(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 117 | |
| 118 | #Verify flow is active |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 119 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 120 | |
| 121 | # Build a overlapping flow F' without check overlap bit set. |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 122 | wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 123 | |
| 124 | # Verify Flow gets inserted |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 125 | verify_tablestats(self,expect_active=2) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 126 | |
| 127 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 128 | class IdenticalFlows(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 129 | |
| 130 | """Verify that adding two identical flows overwrites the existing one and clears counters""" |
| 131 | |
| 132 | def runTest(self): |
| 133 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 134 | logging.info("Running Identical_Flows test ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 135 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 136 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 137 | of_ports.sort() |
| 138 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 139 | |
| 140 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 141 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 142 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 143 | logging.info("Inserting two identical flows one by one") |
| 144 | logging.info("Expecting switch to overwrite the first flow and clear the counters associated with it ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 145 | |
| 146 | # Create and add flow-1, check on dataplane it is active. |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 147 | (pkt,match) = wildcard_all(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 148 | |
| 149 | # Verify active_entries in table_stats_request =1 |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 150 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 151 | |
| 152 | # Send Packet (to increment counters like byte_count and packet_count) |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 153 | send_packet(self,pkt,of_ports[0],of_ports[1]) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 154 | |
| 155 | # Verify Flow counters have incremented |
Rich Lane | ae3428c | 2013-03-07 14:37:42 -0800 | [diff] [blame] | 156 | verify_flow_stats(self, match, pkts=1, bytes=len(str(pkt))) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 157 | |
| 158 | #Send Identical flow |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 159 | (pkt1,match1) = wildcard_all(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 160 | |
| 161 | # Verify active_entries in table_stats_request =1 |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 162 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 163 | |
| 164 | # Verify Flow counters reset |
Rich Lane | ae3428c | 2013-03-07 14:37:42 -0800 | [diff] [blame] | 165 | verify_flow_stats(self, match, pkts=0, bytes=0) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 166 | |
| 167 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 168 | class EmerFlowTimeout(base_tests.SimpleProtocol): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 169 | |
| 170 | """Timeout values are not allowed for emergency flows""" |
| 171 | |
| 172 | def runTest(self): |
| 173 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 174 | logging.info("Running Emergency_Flow_Timeout test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 175 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 176 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 177 | of_ports.sort() |
| 178 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 179 | |
| 180 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 181 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 182 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 183 | logging.info("Inserting an emergency flow with timeout values") |
| 184 | logging.info("Expecting switch to generate error ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 185 | |
| 186 | #Insert an emergency flow |
| 187 | pkt = simple_tcp_packet() |
| 188 | match = parse.packet_to_flow_match(pkt) |
| 189 | match.in_port = of_ports[0] |
| 190 | |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 191 | request = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 192 | request.match = match |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 193 | request.flags = request.flags|ofp.OFPFF_EMERG |
| 194 | request.hard_timeout =9 |
| 195 | request.idle_timeout =9 |
| 196 | |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 197 | act = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 198 | act.port = of_ports[1] |
| 199 | |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 200 | request.actions.append(act) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 201 | logging.info("Inserting flow") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 202 | self.controller.message_send(request) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 203 | |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 204 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 205 | |
| 206 | #Verify OFPET_FLOW_MOD_FAILED/OFPFMFC_OVERLAP error is recieved on the control plane |
| 207 | (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR, |
| 208 | timeout=5) |
| 209 | self.assertTrue(response is not None, |
| 210 | 'Switch did not reply with error message') |
Rich Lane | 4e361bb | 2013-03-11 13:57:31 -0700 | [diff] [blame] | 211 | self.assertTrue(response.err_type==ofp.OFPET_FLOW_MOD_FAILED, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 212 | 'Error message type is not flow mod failed ') |
| 213 | self.assertTrue(response.code==ofp.OFPFMFC_BAD_EMERG_TIMEOUT, |
| 214 | 'Error Message code is not bad emergency timeout') |
| 215 | |
| 216 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 217 | class MissingModifyAdd(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 218 | |
| 219 | """If a modify does not match an existing flow, the flow gets added """ |
| 220 | |
| 221 | def runTest(self): |
| 222 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 223 | logging.info("Running Missing_Modify_Add test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 224 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 225 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 226 | of_ports.sort() |
| 227 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 228 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 229 | logging.info("Inserting a flow-modify that does not match an existing flow") |
| 230 | logging.info("Expecting flow to get added i.e OFPFC_MODIFY command should be taken as OFPFC_ADD ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 231 | |
| 232 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 233 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 234 | |
| 235 | #Generate a flow-mod,command OFPC_MODIFY |
| 236 | |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 237 | request = ofp.message.flow_modify() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 238 | request.match.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT |
| 239 | request.match.in_port = of_ports[0] |
| 240 | request.cookie = random.randint(0,9007199254740992) |
| 241 | request.buffer_id = 0xffffffff |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 242 | act3 = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 243 | act3.port = of_ports[1] |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 244 | request.actions.append(act3) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 245 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 246 | logging.info("Inserting flow") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 247 | self.controller.message_send(request) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 248 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 249 | |
| 250 | #Verify the flow gets added i.e. active_count= 1 |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 251 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 252 | |
| 253 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 254 | class ModifyAction(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 255 | |
| 256 | """A modified flow preserves counters""" |
| 257 | |
| 258 | def runTest(self): |
| 259 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 260 | logging.info("Running Modify_Action test ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 261 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 262 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 263 | of_ports.sort() |
| 264 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 265 | |
| 266 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 267 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 268 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 269 | logging.info("Inserting a Flow and incrementing flow counters. Modifying the flow action") |
| 270 | logging.info("Expecting the flow action to be modified , but the flow-counters should be preserved") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 271 | |
| 272 | #Create and add flow-1 Match on all, except one wildcarded (src adddress).Action A , output to of_port[1] |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 273 | (pkt,match) = match_all_except_source_address(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 274 | |
| 275 | #Send Packet matching the flow thus incrementing counters like packet_count,byte_count |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 276 | send_packet(self,pkt,of_ports[0],of_ports[1]) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 277 | |
| 278 | #Verify flow counters |
Rich Lane | ae3428c | 2013-03-07 14:37:42 -0800 | [diff] [blame] | 279 | verify_flow_stats(self, match, pkts=1, bytes=len(str(pkt))) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 280 | |
| 281 | #Modify flow- 1 |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 282 | modify_flow_action(self,of_ports,match) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 283 | |
| 284 | # Send Packet matching the flow-1 i.e ingress_port=port[0] and verify it is recieved on corret dataplane port i.e port[2] |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 285 | send_packet(self,pkt,of_ports[0],of_ports[2]) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 286 | |
| 287 | #Verify flow counters are preserved |
Rich Lane | ae3428c | 2013-03-07 14:37:42 -0800 | [diff] [blame] | 288 | verify_flow_stats(self, match, pkts=2, bytes=len(str(pkt))*2) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 289 | |
| 290 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 291 | class StrictModifyAction(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 292 | |
| 293 | """Strict Modify Flow also changes action preserves counters""" |
| 294 | |
| 295 | def runTest(self): |
| 296 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 297 | logging.info("Running Strict_Modify_Action test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 298 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 299 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 300 | of_ports.sort() |
| 301 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 302 | |
| 303 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 304 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 305 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 306 | logging.info("Inserting Flows and incrementing flow counters. Strict Modify the flow action ") |
| 307 | logging.info("Expecting the flow action to be modified , but the flow-counters should be preserved") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 308 | |
| 309 | #Create and add flow-1 Match on all, except one wildcarded (src adddress).Action A |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 310 | (pkt,match) = match_all_except_source_address(self,of_ports,priority=100) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 311 | |
| 312 | #Create and add flow-2 , Match on ingress_port only, Action A |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 313 | (pkt1,match1) = wildcard_all_except_ingress(self,of_ports,priority=10) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 314 | |
| 315 | # Verify both the flows are active |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 316 | verify_tablestats(self,expect_active=2) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 317 | |
| 318 | #Send a packet matching the flows, thus incrementing flow-counters (packet matches the flow F-1 with higher priority) |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 319 | send_packet(self,pkt,of_ports[0],of_ports[1]) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 320 | |
| 321 | # Verify flow counters of the flow-1 |
Rich Lane | ae3428c | 2013-03-07 14:37:42 -0800 | [diff] [blame] | 322 | verify_flow_stats(self, match, pkts=1, bytes=len(str(pkt))) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 323 | |
| 324 | # Strict-Modify flow- 1 |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 325 | strict_modify_flow_action(self,of_ports[2],match,priority=100) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 326 | |
| 327 | # Send Packet matching the flow-1 i.e ingress_port=port[0] and verify it is recieved on corret dataplane port i.e port[2] |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 328 | send_packet(self,pkt,of_ports[0],of_ports[2]) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 329 | |
| 330 | # Verify flow counters are preserved |
Rich Lane | ae3428c | 2013-03-07 14:37:42 -0800 | [diff] [blame] | 331 | verify_flow_stats(self, match, pkts=2, bytes=2*len(str(pkt))) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 332 | |
| 333 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 334 | class DeleteNonexistingFlow(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 335 | |
| 336 | """Request deletion of non-existing flow""" |
| 337 | |
| 338 | def runTest(self): |
| 339 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 340 | logging.info("Delete_NonExisting_Flow test begins") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 341 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 342 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 343 | of_ports.sort() |
| 344 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 345 | |
| 346 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 347 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 348 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 349 | logging.info("Deleting a non-existing flow") |
| 350 | logging.info("Expecting switch to ignore the command , without generating errors") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 351 | |
| 352 | # Issue a delete command |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 353 | msg = ofp.message.flow_delete() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 354 | msg.match.wildcards = ofp.OFPFW_ALL |
| 355 | msg.out_port = ofp.OFPP_NONE |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 356 | msg.buffer_id = 0xffffffff |
| 357 | |
| 358 | # Verify no message or error is generated by polling the the control plane |
| 359 | (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR, |
| 360 | timeout=2) |
| 361 | self.assertTrue(response is None, |
| 362 | 'Recieved Error for deleting non-exiting flow ') |
| 363 | |
| 364 | |
| 365 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 366 | class SendFlowRem(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 367 | |
| 368 | """Check deletion of flows happens and generates messages as configured. |
| 369 | If Send Flow removed message Flag is set in the flow entry, the flow deletion of that respective flow should generate the flow removed message, |
| 370 | vice versa also exists """ |
| 371 | |
| 372 | def runTest(self): |
| 373 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 374 | logging.info("Running Send_Flow_Rem test ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 375 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 376 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 377 | of_ports.sort() |
| 378 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 379 | |
| 380 | #Clear swicth state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 381 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 382 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 383 | logging.info("Inserting flows F1 and F2 without and with send_flow_removed_message flag set ") |
| 384 | logging.info("Deleting the flows") |
| 385 | logging.info("Expecting flow removed message only for F2") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 386 | |
| 387 | # Insert flow-1 with F without OFPFF_SEND_FLOW_REM flag set. |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 388 | (pkt,match) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 389 | |
| 390 | # Verify flow is inserted |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 391 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 392 | |
| 393 | #Delete the flow-1 |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 394 | nonstrict_delete(self,match,priority=0) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 395 | |
| 396 | # Verify no flow removed message is generated for the FLOW-1 |
| 397 | |
| 398 | (response1, pkt1) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED, |
| 399 | timeout=2) |
| 400 | self.assertTrue(response1 is None, |
| 401 | 'Received flow removed message for the flow with flow_rem flag not set') |
| 402 | |
| 403 | # Insert another flow F' with OFPFF_SEND_FLOW_REM flag set. |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 404 | msg9 = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 405 | msg9.match.wildcards = ofp.OFPFW_ALL |
| 406 | msg9.cookie = random.randint(0,9007199254740992) |
| 407 | msg9.buffer_id = 0xffffffff |
| 408 | msg9.idle_timeout = 1 |
| 409 | msg9.flags |= ofp.OFPFF_SEND_FLOW_REM |
| 410 | rv1 = self.controller.message_send(msg9) |
| 411 | self.assertTrue(rv1 != -1, "Error installing flow mod") |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 412 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 413 | |
| 414 | # Delete the flow-2 |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 415 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 416 | |
| 417 | # Verify flow removed message is generated for the FLOW-2 |
| 418 | |
| 419 | (response2, pkt2) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED, |
| 420 | timeout=2) |
| 421 | self.assertTrue(response2 is not None, |
| 422 | 'Did not receive flow removed message for this flow') |
| 423 | |
| 424 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 425 | class DeleteEmerFlow(base_tests.SimpleProtocol): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 426 | |
| 427 | """Delete emergency flow and verify no message is generated.An emergency flow deletion will not generate flow-removed messages even if |
| 428 | Send Flow removed message flag was set during the emergency flow entry""" |
| 429 | |
| 430 | def runTest(self): |
| 431 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 432 | logging.info("Running Delete_Emer_Flow") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 433 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 434 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 435 | of_ports.sort() |
| 436 | |
| 437 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 438 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 439 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 440 | logging.info("Inserting a emergency flow with send_flow_removed flag set") |
| 441 | logging.info("Expecting no flow_removed_message on the deletion of the emergency flow") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 442 | |
| 443 | # Insert a flow with emergency bit set. |
| 444 | pkt = simple_tcp_packet() |
| 445 | match = parse.packet_to_flow_match(pkt) |
| 446 | match.in_port = of_ports[0] |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 447 | request = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 448 | request.match = match |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 449 | request.flags = request.flags|ofp.OFPFF_EMERG|ofp.OFPFF_SEND_FLOW_REM |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 450 | act = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 451 | act.port = of_ports[1] |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 452 | request.actions.append(act) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 453 | |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 454 | self.controller.message_send(request) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 455 | |
| 456 | # Delete the emergency flow |
| 457 | |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 458 | nonstrict_delete(self,match) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 459 | (response, pkt) = self.controller.poll(exp_msg=ofp.OFPFF_SEND_FLOW_REM , |
| 460 | timeout=2) |
| 461 | self.assertTrue(response is None, |
| 462 | 'Test Failed ') |
| 463 | |
| 464 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 465 | class StrictVsNonstrict(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 466 | |
| 467 | """Delete and verify strict and non-strict behaviors |
| 468 | This test compares the behavior of delete strict and non-strict""" |
| 469 | |
| 470 | def runTest(self): |
| 471 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 472 | logging.info("Strict_Vs_Nonstrict test begins") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 473 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 474 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 475 | of_ports.sort() |
| 476 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 477 | |
| 478 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 479 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 480 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 481 | logging.info("Inserting a flow with exact match") |
| 482 | logging.info("Issue Strict Delete command , verify it gets deleted") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 483 | |
| 484 | #Insert F with an exact Match |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 485 | (pkt,match) = exact_match(self,of_ports) |
| 486 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 487 | |
| 488 | #Issue Strict Delete Command , verify F gets deleted. |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 489 | strict_delete(self,match) |
| 490 | verify_tablestats(self,expect_active=0) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 491 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 492 | logging.info("Inserting two overlapping flows") |
| 493 | logging.info("Issue Strict Delete command ") |
| 494 | logging.info("Expecting only one flow gets deleted , because Strict Delete matches on wildcards as well") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 495 | |
| 496 | #Insert Flow T with match on all , except one wildcarded ( say src adddress ). |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 497 | (pkt,match) = match_all_except_source_address(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 498 | |
| 499 | #Insert another flow T' with match on ingress_port , wildcarded rest. |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 500 | (pkt1,match1) = wildcard_all_except_ingress(self,of_ports) |
| 501 | verify_tablestats(self,expect_active=2) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 502 | |
| 503 | #Issue Strict Delete matching on ingress_port. Verify only T' gets deleted |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 504 | strict_delete(self,match1) |
| 505 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 506 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 507 | logging.info("Inserting two overlapping flows") |
| 508 | logging.info("Issue Non-Strict Delete command ") |
| 509 | logging.info("Expecting both the flow gets deleted , because wildcards are active") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 510 | |
| 511 | #Insert T and T' again . |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 512 | (pkt,match) = match_all_except_source_address(self,of_ports) |
| 513 | (pkt1,match1) = wildcard_all_except_ingress(self,of_ports) |
| 514 | verify_tablestats(self,expect_active=2) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 515 | |
| 516 | #Issue Non-strict Delete with match on ingress_port.Verify T+T' gets deleted . |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 517 | nonstrict_delete(self,match1) |
| 518 | verify_tablestats(self,expect_active=0) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 519 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 520 | logging.info("Inserting three overlapping flows with different priorities") |
| 521 | logging.info("Issue Non-Strict Delete command ") |
| 522 | logging.info("Expecting all the flows to get deleted") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 523 | |
| 524 | #Insert T , add Priority P (say 100 ) |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 525 | (pkt,match) = match_all_except_source_address(self,of_ports,priority=100) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 526 | |
| 527 | #Insert T' add priority (200). |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 528 | (pkt1,match1) = wildcard_all_except_ingress(self,of_ports,priority=200) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 529 | |
| 530 | #Insert T' again add priority 300 --> T" . |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 531 | (pkt2,match2) = wildcard_all_except_ingress(self,of_ports,priority=300) |
| 532 | verify_tablestats(self,expect_active=3) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 533 | |
| 534 | #Issue Non-Strict Delete and verify all getting deleted |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 535 | nonstrict_delete(self,match1,priority=200) |
| 536 | verify_tablestats(self,expect_active=0) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 537 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 538 | logging.info("Inserting three overlapping flows with different priorities") |
| 539 | logging.info("Issue Strict Delete command ") |
| 540 | logging.info("Expecting only one to get deleted because here priorities & wildcards are being matched") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 541 | |
| 542 | #Issue Strict-Delete and verify only T'' gets deleted. |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 543 | (pkt,match) = match_all_except_source_address(self,of_ports,priority=100) |
| 544 | (pkt1,match1) = wildcard_all_except_ingress(self,of_ports,priority=200) |
| 545 | (pkt2,match2) = wildcard_all_except_ingress(self,of_ports,priority=300) |
| 546 | strict_delete(self,match1,priority=200) |
| 547 | verify_tablestats(self,expect_active=2) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 548 | |
| 549 | |
| 550 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 551 | class Outport1(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 552 | |
| 553 | """Delete flows filtered by action outport.If the out_port field in the delete command contains a value other than OFPP_NONE, |
| 554 | it introduces a constraint when matching. This constraint is that the rule must contain an output action directed at that port.""" |
| 555 | |
| 556 | def runTest(self): |
| 557 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 558 | logging.info("Outport1 test begins") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 559 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 560 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 561 | of_ports.sort() |
| 562 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 563 | |
| 564 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 565 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 566 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 567 | logging.info("Inserting a flow with output action --> of_port[1]") |
| 568 | logging.info("Deleting the flow but with out_port set to of_port[2]") |
| 569 | logging.info("Expecting switch to filter the delete command") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 570 | |
| 571 | #Build and send Flow-1 with action output to of_port[1] |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 572 | (pkt,match) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 573 | |
| 574 | # Verify active_entries in table_stats_request = 1 |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 575 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 576 | |
| 577 | #Send delete command matching the flow-1 but with contraint out_port = of_port[2] |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 578 | msg7 = ofp.message.flow_delete() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 579 | msg7.out_port = of_ports[2] |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 580 | msg7.buffer_id = 0xffffffff |
| 581 | msg7.match = match |
| 582 | |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 583 | self.controller.message_send(msg7) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 584 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 585 | |
| 586 | # Verify flow will not get deleted, active_entries in table_stats_request = 1 |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 587 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 588 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 589 | logging.info("Deleting the flow with out_port set to of_port[1]") |
| 590 | logging.info("Expecting switch to delete the flow") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 591 | |
| 592 | #Send Delete command with contraint out_port = of_ports[1] |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 593 | msg7 = ofp.message.flow_delete() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 594 | msg7.out_port = of_ports[1] |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 595 | msg7.buffer_id = 0xffffffff |
| 596 | msg7.match = match |
| 597 | |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 598 | self.controller.message_send(msg7) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 599 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 600 | |
| 601 | #Verify flow gets deleted. |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 602 | verify_tablestats(self,expect_active=0) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 603 | |
| 604 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 605 | class IdleTimeout(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 606 | |
| 607 | """ Verify that idle timeout is implemented""" |
| 608 | |
| 609 | def runTest(self): |
| 610 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 611 | logging.info("Running Idle_Timeout test ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 612 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 613 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 614 | of_ports.sort() |
| 615 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 616 | |
| 617 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 618 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 619 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 620 | logging.info("Inserting flow entry with idle_timeout set. Also send_flow_removed_message flag set") |
| 621 | logging.info("Expecting the flow entry to delete with given idle_timeout") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 622 | |
| 623 | #Insert a flow entry with idle_timeout=1.Send_Flow_Rem flag set |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 624 | msg9 = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 625 | msg9.match.wildcards = ofp.OFPFW_ALL |
| 626 | msg9.cookie = random.randint(0,9007199254740992) |
| 627 | msg9.buffer_id = 0xffffffff |
| 628 | msg9.idle_timeout = 1 |
| 629 | msg9.flags |= ofp.OFPFF_SEND_FLOW_REM |
| 630 | rv1 = self.controller.message_send(msg9) |
| 631 | self.assertTrue(rv1 != -1, "Error installing flow mod") |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 632 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 633 | |
| 634 | #Verify flow gets inserted |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 635 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 636 | |
| 637 | # Verify flow removed message is recieved. |
| 638 | (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED, |
| 639 | timeout=5) |
| 640 | self.assertTrue(response is not None, |
| 641 | 'Did not receive flow removed message ') |
| 642 | self.assertEqual(ofp.OFPRR_IDLE_TIMEOUT, response.reason, |
| 643 | 'Flow table entry removal reason is not idle_timeout') |
| 644 | self.assertEqual(1, response.duration_sec, |
| 645 | 'Flow was not alive for 1 sec') |
| 646 | |
Rich Lane | 2617eb6 | 2015-05-05 14:19:59 -0700 | [diff] [blame] | 647 | sleep(1) |
| 648 | |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 649 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 650 | class Outport2(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 651 | |
| 652 | """Add, modify flows with outport set. This field is ignored by ADD, MODIFY, and MODIFY STRICT messages.""" |
| 653 | |
| 654 | def runTest(self): |
| 655 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 656 | logging.info("Running Outport2 test ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 657 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 658 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 659 | of_ports.sort() |
| 660 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 661 | |
| 662 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 663 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 664 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 665 | logging.info("Adding and modifying flow with out_port fields set") |
| 666 | logging.info("Expecting switch to ignore out_port") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 667 | |
| 668 | # Create and add flow-1,Action A ,output to port of_port[1], out_port set to of_ports[2] |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 669 | (pkt,match) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 670 | |
| 671 | # Verify flow is active |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 672 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 673 | |
| 674 | # Send Packet matching the flow |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 675 | send_packet(self,pkt,of_ports[0],of_ports[1]) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 676 | |
| 677 | # Insert Flow-Modify matching flow F-1 ,action A', output to port[2], out_port set to port[3] |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 678 | modify_flow_action(self,of_ports,match) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 679 | |
| 680 | # Again verify active_entries in table_stats_request =1 |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 681 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 682 | |
| 683 | #Verify action is modified |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 684 | send_packet(self,pkt,of_ports[0],of_ports[2]) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 685 | |
| 686 | |
| 687 | |
| 688 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 689 | class HardTimeout(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 690 | |
| 691 | """ Verify that hard timeout is implemented """ |
| 692 | |
| 693 | def runTest(self): |
| 694 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 695 | logging.info("Running Hard_Timeout test ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 696 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 697 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 698 | of_ports.sort() |
| 699 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 700 | |
| 701 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 702 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 703 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 704 | logging.info("Inserting flow entry with hard_timeout set. Also send_flow_removed_message flag set") |
| 705 | logging.info("Expecting the flow entry to delete with given hard_timeout") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 706 | |
| 707 | # Insert a flow entry with hardtimeout=1 and send_flow_removed flag set |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 708 | msg9 = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 709 | msg9.match.wildcards = ofp.OFPFW_ALL |
| 710 | msg9.cookie = random.randint(0,9007199254740992) |
| 711 | msg9.buffer_id = 0xffffffff |
| 712 | msg9.hard_timeout = 1 |
| 713 | msg9.flags |= ofp.OFPFF_SEND_FLOW_REM |
| 714 | rv1 = self.controller.message_send(msg9) |
| 715 | self.assertTrue(rv1 != -1, "Error installing flow mod") |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 716 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 717 | |
| 718 | #Verify flow gets inserted |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 719 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 720 | |
| 721 | # Verify flow removed message is recieved. |
| 722 | (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED, |
| 723 | timeout=5) |
| 724 | self.assertTrue(response is not None, |
| 725 | 'Did not receive flow removed message ') |
| 726 | self.assertEqual(ofp.OFPRR_HARD_TIMEOUT, response.reason, |
| 727 | 'Flow table entry removal reason is not hard_timeout') |
| 728 | self.assertEqual(1, response.duration_sec, |
| 729 | 'Flow was not alive for 1 sec') |
| 730 | |
Rich Lane | 2617eb6 | 2015-05-05 14:19:59 -0700 | [diff] [blame] | 731 | sleep(1) |
| 732 | |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 733 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 734 | class FlowTimeout(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 735 | |
| 736 | """Verify that Flow removed messages are generated as expected |
| 737 | Flow removed messages being generated when flag is set, is already tested in the above tests |
| 738 | So here, we test the vice-versa condition""" |
| 739 | |
| 740 | |
| 741 | def runTest(self): |
| 742 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 743 | logging.info("Running Flow_Timeout test ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 744 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 745 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 746 | of_ports.sort() |
| 747 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 748 | |
| 749 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 750 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 751 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 752 | logging.info("Inserting flow entry with hard_timeout set and send_flow_removed_message flag not set") |
| 753 | logging.info("Expecting the flow entry to delete, but no flow removed message") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 754 | |
| 755 | # Insert a flow with hard_timeout = 1 but no Send_Flow_Rem flag set |
| 756 | pkt = simple_tcp_packet() |
| 757 | match3 = parse.packet_to_flow_match(pkt) |
| 758 | self.assertTrue(match3 is not None, "Could not generate flow match from pkt") |
| 759 | match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT |
| 760 | match3.in_port = of_ports[0] |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 761 | msg3 = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 762 | msg3.out_port = of_ports[2] # ignored by flow add,flow modify |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 763 | msg3.cookie = random.randint(0,9007199254740992) |
| 764 | msg3.buffer_id = 0xffffffff |
| 765 | msg3.hard_timeout = 1 |
| 766 | msg3.buffer_id = 0xffffffff |
| 767 | msg3.match = match3 |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 768 | act3 = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 769 | act3.port = of_ports[1] |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 770 | msg3.actions.append(act3) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 771 | |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 772 | self.controller.message_send(msg3) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 773 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 774 | |
| 775 | #Verify no flow removed message is generated |
| 776 | (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED, |
| 777 | timeout=3) |
| 778 | self.assertTrue(response is None, |
| 779 | 'Recieved flow removed message ') |
| 780 | |
| 781 | # Verify no entries in the table |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 782 | verify_tablestats(self,expect_active=0) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 783 | |
Rich Lane | 2617eb6 | 2015-05-05 14:19:59 -0700 | [diff] [blame] | 784 | sleep(1) |
| 785 | |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 | |
| 797 | |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | |