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