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 | |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 17 | # Distributed under the OpenFlow Software License (see LICENSE) |
| 18 | # Copyright (c) 2010 The Board of Trustees of The Leland Stanford Junior University |
| 19 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 20 | """ |
| 21 | Action test cases |
| 22 | |
| 23 | These tests check the behavior of each type of action. The matches used are |
| 24 | exact-match, to satisfy the OXM prerequisites of the set-field actions. |
| 25 | These tests use a single apply-actions instruction. |
| 26 | """ |
| 27 | |
| 28 | import logging |
| 29 | |
| 30 | from oftest import config |
| 31 | import oftest.base_tests as base_tests |
| 32 | import ofp |
| 33 | from loxi.pp import pp |
| 34 | |
| 35 | from oftest.testutils import * |
| 36 | from oftest.parse import parse_ipv6 |
| 37 | |
| 38 | class Output(base_tests.SimpleDataPlane): |
| 39 | """ |
| 40 | Output to a single port |
| 41 | """ |
| 42 | def runTest(self): |
Rich Lane | 045db07 | 2013-08-06 13:16:30 -0700 | [diff] [blame] | 43 | in_port, out_port = openflow_ports(2) |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 44 | |
| 45 | actions = [ofp.action.output(out_port)] |
| 46 | |
| 47 | pkt = simple_tcp_packet() |
| 48 | |
| 49 | logging.info("Running actions test for %s", pp(actions)) |
| 50 | |
| 51 | delete_all_flows(self.controller) |
| 52 | |
| 53 | logging.info("Inserting flow") |
| 54 | request = ofp.message.flow_add( |
Wilson Ng | 6f53964 | 2013-10-28 18:17:44 -0700 | [diff] [blame] | 55 | table_id=test_param_get("table", 0), |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 56 | match=packet_to_flow_match(self, pkt), |
| 57 | instructions=[ |
| 58 | ofp.instruction.apply_actions(actions)], |
| 59 | buffer_id=ofp.OFP_NO_BUFFER, |
| 60 | priority=1000) |
| 61 | self.controller.message_send(request) |
| 62 | |
| 63 | do_barrier(self.controller) |
| 64 | |
| 65 | pktstr = str(pkt) |
| 66 | |
| 67 | logging.info("Sending packet, expecting output to port %d", out_port) |
| 68 | self.dataplane.send(in_port, pktstr) |
Rich Lane | e4b384d | 2013-09-13 14:33:40 -0700 | [diff] [blame] | 69 | verify_packets(self, pktstr, [out_port]) |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 70 | |
| 71 | class OutputMultiple(base_tests.SimpleDataPlane): |
| 72 | """ |
| 73 | Output to three ports |
| 74 | """ |
| 75 | def runTest(self): |
Rich Lane | 045db07 | 2013-08-06 13:16:30 -0700 | [diff] [blame] | 76 | ports = openflow_ports(4) |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 77 | in_port = ports[0] |
| 78 | out_ports = ports[1:4] |
| 79 | |
| 80 | actions = [ofp.action.output(x) for x in out_ports] |
| 81 | |
| 82 | pkt = simple_tcp_packet() |
| 83 | |
| 84 | logging.info("Running actions test for %s", pp(actions)) |
| 85 | |
| 86 | delete_all_flows(self.controller) |
| 87 | |
| 88 | logging.info("Inserting flow") |
| 89 | request = ofp.message.flow_add( |
Wilson Ng | 6f53964 | 2013-10-28 18:17:44 -0700 | [diff] [blame] | 90 | table_id=test_param_get("table", 0), |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 91 | match=packet_to_flow_match(self, pkt), |
| 92 | instructions=[ |
| 93 | ofp.instruction.apply_actions(actions)], |
| 94 | buffer_id=ofp.OFP_NO_BUFFER, |
| 95 | priority=1000) |
| 96 | self.controller.message_send(request) |
| 97 | |
| 98 | do_barrier(self.controller) |
| 99 | |
| 100 | pktstr = str(pkt) |
| 101 | |
| 102 | logging.info("Sending packet, expecting output to ports %r", out_ports) |
| 103 | self.dataplane.send(in_port, pktstr) |
Rich Lane | e4b384d | 2013-09-13 14:33:40 -0700 | [diff] [blame] | 104 | verify_packets(self, pktstr, out_ports) |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 105 | |
| 106 | class BaseModifyPacketTest(base_tests.SimpleDataPlane): |
| 107 | """ |
| 108 | Base class for action tests that modify a packet |
| 109 | """ |
| 110 | |
| 111 | def verify_modify(self, actions, pkt, exp_pkt): |
Rich Lane | 045db07 | 2013-08-06 13:16:30 -0700 | [diff] [blame] | 112 | in_port, out_port = openflow_ports(2) |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 113 | |
| 114 | actions = actions + [ofp.action.output(out_port)] |
| 115 | |
| 116 | logging.info("Running actions test for %s", pp(actions)) |
| 117 | |
| 118 | delete_all_flows(self.controller) |
| 119 | |
| 120 | logging.info("Inserting flow") |
| 121 | request = ofp.message.flow_add( |
Wilson Ng | 6f53964 | 2013-10-28 18:17:44 -0700 | [diff] [blame] | 122 | table_id=test_param_get("table", 0), |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 123 | match=packet_to_flow_match(self, pkt), |
| 124 | instructions=[ |
| 125 | ofp.instruction.apply_actions(actions)], |
| 126 | buffer_id=ofp.OFP_NO_BUFFER, |
| 127 | priority=1000) |
| 128 | self.controller.message_send(request) |
| 129 | |
| 130 | do_barrier(self.controller) |
| 131 | |
| 132 | logging.info("Sending packet, expecting output to port %d", out_port) |
| 133 | self.dataplane.send(in_port, str(pkt)) |
Rich Lane | e4b384d | 2013-09-13 14:33:40 -0700 | [diff] [blame] | 134 | verify_packets(self, str(exp_pkt), [out_port]) |
| 135 | |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 136 | |
| 137 | class PushVlan(BaseModifyPacketTest): |
| 138 | """ |
| 139 | Push a vlan tag (vid=0, pcp=0) |
| 140 | """ |
| 141 | def runTest(self): |
| 142 | actions = [ofp.action.push_vlan(ethertype=0x8100)] |
| 143 | pkt = simple_tcp_packet() |
| 144 | exp_pkt = simple_tcp_packet(dl_vlan_enable=True, pktlen=104) |
| 145 | self.verify_modify(actions, pkt, exp_pkt) |
| 146 | |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 147 | class PushVlanVid(BaseModifyPacketTest): |
| 148 | """ |
| 149 | Push a vlan tag (vid=2, pcp=0) |
| 150 | """ |
| 151 | def runTest(self): |
| 152 | actions = [ofp.action.push_vlan(ethertype=0x8100), |
| 153 | ofp.action.set_field(ofp.oxm.vlan_vid(2))] |
| 154 | pkt = simple_tcp_packet() |
| 155 | exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=2, pktlen=104) |
| 156 | self.verify_modify(actions, pkt, exp_pkt) |
| 157 | |
| 158 | class PushVlanVidPcp(BaseModifyPacketTest): |
| 159 | """ |
| 160 | Push a vlan tag (vid=2, pcp=3) |
| 161 | """ |
| 162 | def runTest(self): |
| 163 | actions = [ofp.action.push_vlan(ethertype=0x8100), |
| 164 | ofp.action.set_field(ofp.oxm.vlan_vid(2)), |
| 165 | ofp.action.set_field(ofp.oxm.vlan_pcp(3))] |
| 166 | pkt = simple_tcp_packet() |
| 167 | exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=2, vlan_pcp=3, pktlen=104) |
| 168 | self.verify_modify(actions, pkt, exp_pkt) |
| 169 | |
| 170 | class PushVlanPcp(BaseModifyPacketTest): |
| 171 | """ |
| 172 | Push a vlan tag (vid=0, pcp=3) |
| 173 | """ |
| 174 | def runTest(self): |
| 175 | actions = [ofp.action.push_vlan(ethertype=0x8100), |
| 176 | ofp.action.set_field(ofp.oxm.vlan_pcp(3))] |
| 177 | pkt = simple_tcp_packet() |
| 178 | exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=3, pktlen=104) |
| 179 | self.verify_modify(actions, pkt, exp_pkt) |
| 180 | |
Rich Lane | b626a9c | 2013-08-05 16:45:50 -0700 | [diff] [blame] | 181 | class PopVlan(BaseModifyPacketTest): |
| 182 | """ |
| 183 | Pop a vlan tag |
| 184 | """ |
| 185 | def runTest(self): |
| 186 | actions = [ofp.action.pop_vlan()] |
| 187 | pkt = simple_tcp_packet(dl_vlan_enable=True, pktlen=104) |
| 188 | exp_pkt = simple_tcp_packet() |
| 189 | self.verify_modify(actions, pkt, exp_pkt) |
| 190 | |
| 191 | class SetVlanVid(BaseModifyPacketTest): |
| 192 | """ |
| 193 | Set the vlan vid |
| 194 | """ |
| 195 | def runTest(self): |
| 196 | actions = [ofp.action.set_field(ofp.oxm.vlan_vid(2))] |
| 197 | pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1) |
| 198 | exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=2) |
| 199 | self.verify_modify(actions, pkt, exp_pkt) |
| 200 | |
| 201 | class SetVlanPcp(BaseModifyPacketTest): |
| 202 | """ |
| 203 | Set the vlan priority |
| 204 | """ |
| 205 | def runTest(self): |
| 206 | actions = [ofp.action.set_field(ofp.oxm.vlan_pcp(2))] |
| 207 | pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_pcp=1) |
| 208 | exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_pcp=2) |
| 209 | self.verify_modify(actions, pkt, exp_pkt) |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 210 | |
| 211 | class SetEthDst(BaseModifyPacketTest): |
| 212 | """ |
| 213 | Set Eth Dst address |
| 214 | """ |
| 215 | def runTest(self): |
| 216 | actions = [ofp.action.set_field(ofp.oxm.eth_dst([0x00,0xA1,0xCD,0x53,0xC6,0x55]))] |
| 217 | pkt = simple_tcp_packet() |
| 218 | exp_pkt = simple_tcp_packet(eth_dst="00:A1:CD:53:C6:55") |
| 219 | self.verify_modify(actions, pkt, exp_pkt) |
| 220 | |
| 221 | class SetEthSrc(BaseModifyPacketTest): |
| 222 | """ |
| 223 | Set Eth Src address |
| 224 | """ |
| 225 | def runTest(self): |
| 226 | actions = [ofp.action.set_field(ofp.oxm.eth_src([0x00,0xA1,0xCD,0x53,0xC6,0x55]))] |
| 227 | pkt = simple_tcp_packet() |
| 228 | exp_pkt = simple_tcp_packet(eth_src="00:A1:CD:53:C6:55") |
| 229 | self.verify_modify(actions, pkt, exp_pkt) |
| 230 | |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 231 | class SetIpv4Dscp(BaseModifyPacketTest): |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 232 | """ |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 233 | Set IPv4 DSCP |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 234 | """ |
| 235 | def runTest(self): |
| 236 | actions = [ofp.action.set_field(ofp.oxm.ip_dscp(0x01))] |
| 237 | pkt = simple_tcp_packet() |
| 238 | exp_pkt = simple_tcp_packet(ip_tos=0x04) |
| 239 | self.verify_modify(actions, pkt, exp_pkt) |
| 240 | |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 241 | class SetIpv4ECN(BaseModifyPacketTest): |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 242 | """ |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 243 | Set IPv4 ECN |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 244 | """ |
| 245 | def runTest(self): |
| 246 | actions = [ofp.action.set_field(ofp.oxm.ip_ecn(0x01))] |
| 247 | pkt = simple_tcp_packet() |
| 248 | exp_pkt = simple_tcp_packet(ip_tos=0x01) |
| 249 | self.verify_modify(actions, pkt, exp_pkt) |
| 250 | |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 251 | class SetIpv4DSCP_NonZeroECN(BaseModifyPacketTest): |
Kiran Poola | fb523e5 | 2013-08-07 22:57:51 -0700 | [diff] [blame] | 252 | """ |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 253 | Set IPv4 DSCP and make sure ECN is not modified |
Kiran Poola | fb523e5 | 2013-08-07 22:57:51 -0700 | [diff] [blame] | 254 | """ |
| 255 | def runTest(self): |
| 256 | actions = [ofp.action.set_field(ofp.oxm.ip_dscp(0x01))] |
| 257 | pkt = simple_tcp_packet(ip_tos=0x11) |
| 258 | exp_pkt = simple_tcp_packet(ip_tos=0x05) |
| 259 | self.verify_modify(actions, pkt, exp_pkt) |
| 260 | |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 261 | class SetIpv4ECN_NonZeroDSCP(BaseModifyPacketTest): |
Kiran Poola | fb523e5 | 2013-08-07 22:57:51 -0700 | [diff] [blame] | 262 | """ |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 263 | Set IPv4 ECN and make sure DSCP is not modified |
Kiran Poola | fb523e5 | 2013-08-07 22:57:51 -0700 | [diff] [blame] | 264 | """ |
| 265 | def runTest(self): |
| 266 | actions = [ofp.action.set_field(ofp.oxm.ip_ecn(0x02))] |
| 267 | pkt = simple_tcp_packet(ip_tos=0x11) |
| 268 | exp_pkt = simple_tcp_packet(ip_tos=0x12) |
| 269 | self.verify_modify(actions, pkt, exp_pkt) |
| 270 | |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 271 | class SetIPv4Src(BaseModifyPacketTest): |
| 272 | """ |
| 273 | Set IPv4 srouce address |
| 274 | """ |
| 275 | def runTest(self): |
| 276 | actions = [ofp.action.set_field(ofp.oxm.ipv4_src(167772161))] |
| 277 | pkt = simple_tcp_packet() |
| 278 | exp_pkt = simple_tcp_packet(ip_src="10.0.0.1") |
| 279 | self.verify_modify(actions, pkt, exp_pkt) |
| 280 | |
| 281 | class SetIPv4Dst(BaseModifyPacketTest): |
| 282 | """ |
| 283 | Set IPv4 destination address |
| 284 | """ |
| 285 | def runTest(self): |
| 286 | actions = [ofp.action.set_field(ofp.oxm.ipv4_dst(167772161))] |
| 287 | pkt = simple_tcp_packet() |
| 288 | exp_pkt = simple_tcp_packet(ip_dst="10.0.0.1") |
| 289 | self.verify_modify(actions, pkt, exp_pkt) |
| 290 | |
| 291 | class SetTCPSrc(BaseModifyPacketTest): |
| 292 | """ |
| 293 | Set TCP source port |
| 294 | """ |
| 295 | def runTest(self): |
| 296 | actions = [ofp.action.set_field(ofp.oxm.tcp_src(800))] |
| 297 | pkt = simple_tcp_packet() |
| 298 | exp_pkt = simple_tcp_packet(tcp_sport=800) |
| 299 | self.verify_modify(actions, pkt, exp_pkt) |
| 300 | |
| 301 | class SetTCPDst(BaseModifyPacketTest): |
| 302 | """ |
| 303 | Set TCP destination port |
| 304 | """ |
| 305 | def runTest(self): |
| 306 | actions = [ofp.action.set_field(ofp.oxm.tcp_dst(800))] |
| 307 | pkt = simple_tcp_packet() |
| 308 | exp_pkt = simple_tcp_packet(tcp_dport=800) |
| 309 | self.verify_modify(actions, pkt, exp_pkt) |
| 310 | |
| 311 | class SetUDPSrc(BaseModifyPacketTest): |
| 312 | """ |
| 313 | Set UDP source port |
| 314 | """ |
| 315 | def runTest(self): |
| 316 | actions = [ofp.action.set_field(ofp.oxm.udp_src(800))] |
| 317 | pkt = simple_udp_packet() |
| 318 | exp_pkt = simple_udp_packet(udp_sport=800) |
| 319 | self.verify_modify(actions, pkt, exp_pkt) |
| 320 | |
| 321 | class SetUDPDst(BaseModifyPacketTest): |
| 322 | """ |
| 323 | Set UDP destination port |
| 324 | """ |
| 325 | def runTest(self): |
| 326 | actions = [ofp.action.set_field(ofp.oxm.udp_dst(800))] |
| 327 | pkt = simple_udp_packet() |
| 328 | exp_pkt = simple_udp_packet(udp_dport=800) |
| 329 | self.verify_modify(actions, pkt, exp_pkt) |
| 330 | |
| 331 | class SetIPv6Src(BaseModifyPacketTest): |
| 332 | """ |
| 333 | Set IPv6 source address |
| 334 | """ |
| 335 | def runTest(self): |
| 336 | actions = [ofp.action.set_field(ofp.oxm.ipv6_src("\x20\x01\xab\xb1\x34\x56\xbc\xcb\x00\x00\x00\x00\x03\x70\x73\x36"))] |
| 337 | pkt = simple_tcpv6_packet() |
| 338 | exp_pkt = simple_tcpv6_packet(ipv6_src="2001:abb1:3456:bccb:0000:0000:0370:7336") |
| 339 | self.verify_modify(actions, pkt, exp_pkt) |
| 340 | |
| 341 | class SetIPv6Dst(BaseModifyPacketTest): |
| 342 | """ |
| 343 | Set IPv6 destination address |
| 344 | """ |
| 345 | def runTest(self): |
| 346 | actions = [ofp.action.set_field(ofp.oxm.ipv6_dst("\x20\x01\xab\xb1\x34\x56\xbc\xcb\x00\x00\x00\x00\x03\x70\x73\x36"))] |
| 347 | pkt = simple_tcpv6_packet() |
| 348 | exp_pkt = simple_tcpv6_packet(ipv6_dst="2001:abb1:3456:bccb:0000:0000:0370:7336") |
| 349 | self.verify_modify(actions, pkt, exp_pkt) |
| 350 | |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 351 | class SetIpv6Dscp(BaseModifyPacketTest): |
| 352 | """ |
| 353 | Set IPv6 DSCP |
| 354 | """ |
| 355 | def runTest(self): |
| 356 | actions = [ofp.action.set_field(ofp.oxm.ip_dscp(0x01))] |
| 357 | pkt = simple_tcpv6_packet() |
| 358 | exp_pkt = simple_tcpv6_packet(ipv6_tc=0x04) |
| 359 | self.verify_modify(actions, pkt, exp_pkt) |
| 360 | |
| 361 | class SetIpv6ECN(BaseModifyPacketTest): |
| 362 | """ |
| 363 | Set IPv6 ECN |
| 364 | """ |
| 365 | def runTest(self): |
| 366 | actions = [ofp.action.set_field(ofp.oxm.ip_ecn(0x01))] |
| 367 | pkt = simple_tcpv6_packet() |
| 368 | exp_pkt = simple_tcpv6_packet(ipv6_tc=0x01) |
| 369 | self.verify_modify(actions, pkt, exp_pkt) |
| 370 | |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 371 | class SetIPv6Flabel(BaseModifyPacketTest): |
| 372 | """ |
| 373 | Set IPv6 Flabel |
| 374 | """ |
| 375 | def runTest(self): |
Kiran Poola | fb523e5 | 2013-08-07 22:57:51 -0700 | [diff] [blame] | 376 | actions = [ofp.action.set_field(ofp.oxm.ipv6_flabel(10))] |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 377 | pkt = simple_tcpv6_packet() |
Kiran Poola | fb523e5 | 2013-08-07 22:57:51 -0700 | [diff] [blame] | 378 | exp_pkt = simple_tcpv6_packet(ipv6_fl=10) |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 379 | self.verify_modify(actions, pkt, exp_pkt) |
| 380 | |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 381 | class SetIpv6DSCP_NonZeroECNandFlabel(BaseModifyPacketTest): |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 382 | """ |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 383 | Set IPv6 DSCP and make sure ECN is not modified |
| 384 | """ |
| 385 | def runTest(self): |
| 386 | actions = [ofp.action.set_field(ofp.oxm.ip_dscp(0x01))] |
| 387 | pkt = simple_tcpv6_packet(ipv6_tc=0x11, ipv6_fl=10) |
| 388 | exp_pkt = simple_tcpv6_packet(ipv6_tc=0x05, ipv6_fl=10) |
| 389 | self.verify_modify(actions, pkt, exp_pkt) |
| 390 | |
| 391 | class SetIpv6ECN_NonZeroDSCPandFlabel(BaseModifyPacketTest): |
| 392 | """ |
| 393 | Set IPv6 ECN and make sure DSCP is not modified |
| 394 | """ |
| 395 | def runTest(self): |
| 396 | actions = [ofp.action.set_field(ofp.oxm.ip_ecn(0x02))] |
| 397 | pkt = simple_tcpv6_packet(ipv6_tc=0x11, ipv6_fl=10) |
| 398 | exp_pkt = simple_tcpv6_packet(ipv6_tc=0x12, ipv6_fl=10) |
| 399 | self.verify_modify(actions, pkt, exp_pkt) |
| 400 | |
| 401 | class SetIPv6Flabel_NonZeroDSCPandECN(BaseModifyPacketTest): |
| 402 | """ |
| 403 | Set IPv6 Flabel |
| 404 | """ |
| 405 | def runTest(self): |
| 406 | actions = [ofp.action.set_field(ofp.oxm.ipv6_flabel(10))] |
| 407 | pkt = simple_tcpv6_packet(ipv6_tc=0x11, ipv6_fl=9) |
| 408 | exp_pkt = simple_tcpv6_packet(ipv6_tc=0x11, ipv6_fl=10) |
| 409 | self.verify_modify(actions, pkt, exp_pkt) |
| 410 | |
| 411 | class SetIpv4TTL(BaseModifyPacketTest): |
| 412 | """ |
| 413 | Set IPv4 TTL |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 414 | """ |
| 415 | def runTest(self): |
| 416 | actions = [ofp.action.set_nw_ttl(10)] |
| 417 | pkt = simple_tcp_packet() |
| 418 | exp_pkt = simple_tcp_packet(ip_ttl=10) |
| 419 | self.verify_modify(actions, pkt, exp_pkt) |
| 420 | |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 421 | class SetIpv6HopLimit(BaseModifyPacketTest): |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 422 | """ |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 423 | Set Ipv6 Hop Limit |
| 424 | """ |
| 425 | def runTest(self): |
| 426 | actions = [ofp.action.set_nw_ttl(10)] |
| 427 | pkt = simple_tcpv6_packet() |
| 428 | exp_pkt = simple_tcpv6_packet(ipv6_hlim=10) |
| 429 | self.verify_modify(actions, pkt, exp_pkt) |
| 430 | |
| 431 | class DecIpv4TTL(BaseModifyPacketTest): |
| 432 | """ |
| 433 | Decrement Ipv4 TTL |
Kiran Poola | d06998a | 2013-08-07 14:51:50 -0700 | [diff] [blame] | 434 | """ |
| 435 | def runTest(self): |
| 436 | actions = [ofp.action.dec_nw_ttl()] |
| 437 | pkt = simple_tcp_packet(ip_ttl=10) |
| 438 | exp_pkt = simple_tcp_packet(ip_ttl=9) |
| 439 | self.verify_modify(actions, pkt, exp_pkt) |
Kiran Poola | 4ed39ce | 2013-08-08 21:46:17 -0700 | [diff] [blame] | 440 | |
| 441 | class DecIpv6HopLimit(BaseModifyPacketTest): |
| 442 | """ |
| 443 | Decrement Ipv6 Hop Limit |
| 444 | """ |
| 445 | def runTest(self): |
| 446 | actions = [ofp.action.dec_nw_ttl()] |
| 447 | pkt = simple_tcpv6_packet(ipv6_hlim=10) |
| 448 | exp_pkt = simple_tcpv6_packet(ipv6_hlim=9) |
| 449 | self.verify_modify(actions, pkt, exp_pkt) |