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