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