blob: 27858b01d5079318bcc245e17bed13f684c8630f [file] [log] [blame]
Jonathan Hartf2511ca2015-07-07 14:18:19 -07001'''
2OFTests for functionality needed from the OLT.
3'''
4import logging
5from oftest import config
6import oftest.base_tests as base_tests
7import oftest.packet as scapy
8
9import ofp
Admin7e9c91d2015-08-25 15:53:49 -070010import time
Adminef7a0552015-12-09 15:21:45 -080011import copy
Jonathan Hartf2511ca2015-07-07 14:18:19 -070012
13from oftest.testutils import *
14
Admindcb1bc72015-11-12 18:24:56 -080015onu_port = test_param_get("onu_port", 130)
Admin99c2a272016-03-01 12:56:39 -080016onu_port2 = test_param_get("onu_port2", 130)
Admindcb1bc72015-11-12 18:24:56 -080017olt_port = test_param_get("olt_port", 258)
Jonathan Hartf2511ca2015-07-07 14:18:19 -070018
Adminb17b1662015-10-19 15:50:53 -070019def double_vlan_udp_packet(pktlen=100,
20 eth_dst='00:01:02:03:04:05',
21 eth_src='00:06:07:08:09:0a',
22 dl_vlan_enable=False,
23 c_vlan_vid=0,
24 c_vlan_pcp=0,
25 s_vlan_vid=0,
26 s_vlan_pcp=0,
27 ip_src='192.168.0.1',
28 ip_dst='192.168.0.2',
29 ip_tos=0,
30 ip_ttl=64,
31 udp_sport=1234,
32 udp_dport=80,
33 ip_ihl=None,
Admindcb1bc72015-11-12 18:24:56 -080034 ip_options=False,
35 eth_type=0x8100
Adminb17b1662015-10-19 15:50:53 -070036 ):
37 """
38 Return a double vlan tagged dataplane UDP packet
39 Supports a few parameters:
40 @param len Length of packet in bytes w/o CRC
41 @param eth_dst Destination MAC
42 @param eth_src Source MAC
43 @param dl_vlan_enable True if the packet is with vlan, False otherwise
44 @param c_vlan_vid CVLAN ID
45 @param c_vlan_pcp CVLAN priority
46 @param s_vlan_vid SVLAN ID
47 @param s_vlan_pcp SVLAN priority
48 @param ip_src IP source
49 @param ip_dst IP destination
50 @param ip_tos IP ToS
51 @param ip_ttl IP TTL
52 @param udp_dport UDP destination port
53 @param udp_sport UDP source port
54
55 Generates a simple UDP packet. Users shouldn't assume anything about
56 this packet other than that it is a valid ethernet/IP/UDP frame.
57 """
58
59 if MINSIZE > pktlen:
60 pktlen = MINSIZE
61
62 # Note Dot1Q.id is really CFI
63 if (dl_vlan_enable):
Admindcb1bc72015-11-12 18:24:56 -080064 pkt = scapy.Ether(dst=eth_dst, src=eth_src, type=eth_type)/ \
Adminb17b1662015-10-19 15:50:53 -070065 scapy.Dot1Q(prio=s_vlan_pcp, vlan=s_vlan_vid)/ \
66 scapy.Dot1Q(prio=c_vlan_pcp, vlan=c_vlan_vid)/ \
67 scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
68 scapy.UDP(sport=udp_sport, dport=udp_dport)
69 else:
70 if not ip_options:
71 pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
72 scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
73 scapy.UDP(sport=udp_sport, dport=udp_dport)
74
75 else:
76 pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
77 scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl, options=ip_options)/ \
78 scapy.UDP(sport=udp_sport, dport=udp_dport)
79
80 pkt = pkt/("D" * (pktlen - len(pkt)))
81
82 return pkt
83
84
Jonathan Hartf2511ca2015-07-07 14:18:19 -070085def testPacketIn(self, match, parsed_pkt):
Admin7e9c91d2015-08-25 15:53:49 -070086
Jonathan Hartf2511ca2015-07-07 14:18:19 -070087 delete_all_flows(self.controller)
88
89 pkt = str(parsed_pkt)
90
Adminef7a0552015-12-09 15:21:45 -080091 for of_port in config["port_map"]:
92 m = copy.deepcopy(match)
93 m.oxm_list.append(ofp.oxm.in_port(of_port))
94 request = ofp.message.flow_add(
Jonathan Hartf2511ca2015-07-07 14:18:19 -070095 table_id=test_param_get("table", 0),
96 cookie=42,
Adminef7a0552015-12-09 15:21:45 -080097 match=m,
Jonathan Hartf2511ca2015-07-07 14:18:19 -070098 instructions=[
99 ofp.instruction.apply_actions(
100 actions=[
101 ofp.action.output(
102 port=ofp.OFPP_CONTROLLER,
103 max_len=ofp.OFPCML_NO_BUFFER)])],
104 buffer_id=ofp.OFP_NO_BUFFER,
105 priority=1000)
Adminef7a0552015-12-09 15:21:45 -0800106 logging.info("Inserting flow sending matching packets to controller")
107 self.controller.message_send(request)
108 do_barrier(self.controller)
109
Admin7e9c91d2015-08-25 15:53:49 -0700110 for of_port in config["port_map"]:
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700111 logging.info("PacketInExact test, port %d", of_port)
112 self.dataplane.send(of_port, pkt)
113 verify_packet_in(self, pkt, of_port, ofp.OFPR_ACTION)
114 verify_packets(self, pkt, [])
115
Admind5212782015-12-09 17:17:57 -0800116def buildIgmp(payload):
117 ether = scapy.Ether(src="00:01:02:03:04:05")
118 ip = scapy.IP(src="1.2.3.4")
119 payload.igmpize(ip, ether)
Admin99c2a272016-03-01 12:56:39 -0800120 pkt = ether / ip / payload
121 if len(pkt) < 60:
122 pad_len = 60 - len(pkt)
123 pad = scapy.PAD()
124 pad.load = '\x00' * pad_len
125 pkt = pkt / pad
126 return pkt
Admind5212782015-12-09 17:17:57 -0800127
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700128class EapolPacketIn(base_tests.SimpleDataPlane):
129
130 """Verify packet-ins are sent for EAPOL packets """
131
132 def runTest(self):
133 logging.info("Running EAPOL Packet In test")
134
135 match = ofp.match()
136 match.oxm_list.append(ofp.oxm.eth_type(0x888e))
137 # Use ethertype 0x888e and multicast destination MAC address
138 pkt = simple_eth_packet(pktlen=60, eth_dst='01:00:5E:7F:FF:FF', eth_type=0x888e)
139
140 testPacketIn(self, match, pkt)
141
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700142class IGMPPacketIn(base_tests.SimpleDataPlane):
143
144 """Verify packet-ins are sent for IGMP packets """
145
146 def runTest(self):
147 logging.info("Running IGMP Packet In test")
148
149 match = ofp.match()
150 match.oxm_list.append(ofp.oxm.eth_type(0x800))
151 match.oxm_list.append(ofp.oxm.ip_proto(2))
152
153 pkt = scapy.Ether(dst='01:00:5E:7F:FF:FF', src='00:00:00:00:00:01')/ \
154 scapy.IP(src='10.0.0.1', dst='10.0.0.2', ttl=60, tos=0, id=0, proto=2)
155
156 pkt = pkt/("0" * (100 - len(pkt)))
157
158 testPacketIn(self, match, pkt)
Admin7e9c91d2015-08-25 15:53:49 -0700159
Admind5212782015-12-09 17:17:57 -0800160class IGMPQueryPacketOut(base_tests.SimpleDataPlane):
161
162 """Verify sending multicast membership queries down to onu_ports"""
163
164 def runTest(self):
165 logging.info("Running IGMP query packet out")
166
167 igmp = scapy.IGMP(type = 0x11, gaddr = "224.0.0.1")
168 pkt = buildIgmp(igmp)
169
170 msg = ofp.message.packet_out()
171 msg.in_port = ofp.OFPP_CONTROLLER
Admin99c2a272016-03-01 12:56:39 -0800172 msg.buffer_id = 0xffffffff
Admind5212782015-12-09 17:17:57 -0800173 msg.data = str(pkt)
174 msg.actions = [ofp.action.output(
175 port=onu_port,
176 max_len=ofp.OFPCML_NO_BUFFER)]
177 time.sleep(1)
178
179 self.controller.message_send(msg)
180
181 verify_no_errors(self.controller)
182
183 verify_packet(self, pkt, onu_port)
184
Admin7e9c91d2015-08-25 15:53:49 -0700185class TestMeter(base_tests.SimpleDataPlane):
186
187 def runTest(self):
188 logging.info("Running Meter tests")
Admin99c2a272016-03-01 12:56:39 -0800189 dropMeterBand = ofp.meter_band.drop(rate = 640)
Admin7e9c91d2015-08-25 15:53:49 -0700190 meter_mod = ofp.message.meter_mod(xid = 1, command = ofp.OFPMC_ADD, meter_id = 1, meters = [ dropMeterBand ])
191 self.controller.message_send(meter_mod)
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700192
Admin7e9c91d2015-08-25 15:53:49 -0700193 time.sleep(1)
194
195 verify_no_errors(self.controller)
196
Jonathan Hartf65e1812015-10-05 15:15:37 -0700197 vlan_id = 201
Admin7e9c91d2015-08-25 15:53:49 -0700198 match = ofp.match()
199 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Admin02d052c2015-10-10 19:08:26 -0700200 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id ))
201
202 request = ofp.message.flow_add(
203 table_id=test_param_get("table", 0),
204 cookie=42,
205 match=match,
206 instructions=[
207 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700208 actions=[ofp.action.output(port=olt_port)]
209 ),
Admin02d052c2015-10-10 19:08:26 -0700210 ofp.instruction.meter(meter_id = 1)
211 ],
212 buffer_id=ofp.OFP_NO_BUFFER,
213 priority=1000)
214
215 self.controller.message_send(request)
216 time.sleep(1)
217 verify_no_errors(self.controller)
218
219 match = ofp.match()
220 match.oxm_list.append(ofp.oxm.in_port(olt_port))
221 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700222
223 request = ofp.message.flow_add(
224 table_id=test_param_get("table", 0),
225 cookie=43,
226 match=match,
227 instructions=[
228 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700229 actions=[ofp.action.output(port=onu_port)]
230 ),
231 ofp.instruction.meter(meter_id = 1)
Admin7e9c91d2015-08-25 15:53:49 -0700232 ],
233 buffer_id=ofp.OFP_NO_BUFFER,
234 priority=1000)
235
236 self.controller.message_send(request)
Admin7e9c91d2015-08-25 15:53:49 -0700237 time.sleep(1)
Admin7e9c91d2015-08-25 15:53:49 -0700238 verify_no_errors(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700239 do_barrier(self.controller)
240 time.sleep(5)
Admin7e9c91d2015-08-25 15:53:49 -0700241
Jonathan Hartf65e1812015-10-05 15:15:37 -0700242 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
243 # downstream
Adminef7a0552015-12-09 15:21:45 -0800244 #self.dataplane.send(olt_port, str(inPkt))
245 #verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700246 # upstream
Admin99c2a272016-03-01 12:56:39 -0800247 #for i in range(1,400):
248 # self.dataplane.send(onu_port, str(inPkt))
249 #verify_packet(self, inPkt, olt_port)
Admin02d052c2015-10-10 19:08:26 -0700250
Jonathan Hartf65e1812015-10-05 15:15:37 -0700251 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700252 meter_mod = ofp.message.meter_mod(xid = 2, command = ofp.OFPMC_DELETE, meter_id = 1)
253 self.controller.message_send(meter_mod)
254 time.sleep(1)
255 delete_all_flows(self.controller)
256 verify_no_errors(self.controller)
257
258
Admin7e9c91d2015-08-25 15:53:49 -0700259class TestDuplicateMeter(base_tests.SimpleDataPlane):
260
261 def runTest(self):
262 logging.info("Running Duplicate Meter Test")
263 dropMeterBand = ofp.meter_band.drop(rate = 500)
264 meter_mod = ofp.message.meter_mod(xid = 1, command = ofp.OFPMC_ADD, meter_id = 1, meters = [ dropMeterBand ])
265 self.controller.message_send(meter_mod)
266 self.controller.message_send(meter_mod)
267
268 time.sleep(1)
269
270 try:
271 verify_no_errors(self.controller)
272 except AssertionError as e:
Admin09b5cc62015-10-11 13:53:59 -0700273 if (not e.message == "unexpected error type=12 code=1"):
Admin7e9c91d2015-08-25 15:53:49 -0700274 raise AssertionError("Incorrect error type: %s" % e.message)
275
276
277class VlanTest(base_tests.SimpleDataPlane):
278
279 """Verify the switch can push/pop a VLAN tag and forward out a port """
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700280
281 def runTest(self):
282 logging.info("Running push VLAN test")
283
284 vlan_id = 200
285
286 delete_all_flows(self.controller)
Admin7e9c91d2015-08-25 15:53:49 -0700287
288 #PUSH
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700289 match = ofp.match()
290 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Admin7e9c91d2015-08-25 15:53:49 -0700291 match.oxm_list.append(ofp.oxm.vlan_vid_masked(value=ofp.OFPVID_PRESENT, value_mask=ofp.OFPVID_PRESENT))
292 match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700293
294 request = ofp.message.flow_add(
295 table_id=test_param_get("table", 0),
296 cookie=42,
297 match=match,
298 instructions=[
299 ofp.instruction.apply_actions(
300 actions=[
301 ofp.action.push_vlan(ethertype=0x8100),
302 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
Admin7e9c91d2015-08-25 15:53:49 -0700303 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700304 ofp.action.output(port=olt_port)])],
305 buffer_id=ofp.OFP_NO_BUFFER,
306 priority=1000)
307
Admin7e9c91d2015-08-25 15:53:49 -0700308 logging.info("Inserting flow tagging upstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700309 self.controller.message_send(request)
Adminb17b1662015-10-19 15:50:53 -0700310
Admin02d052c2015-10-10 19:08:26 -0700311 #POP
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700312 match = ofp.match()
313 match.oxm_list.append(ofp.oxm.in_port(olt_port))
314 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700315
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700316 request = ofp.message.flow_add(
317 table_id=test_param_get("table", 0),
Admin7e9c91d2015-08-25 15:53:49 -0700318 cookie=43,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700319 match=match,
320 instructions=[
321 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700322 actions=[
323 ofp.action.pop_vlan(),
Admin09b5cc62015-10-11 13:53:59 -0700324 ofp.action.output(port=onu_port)])],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700325 buffer_id=ofp.OFP_NO_BUFFER,
326 priority=1000)
327
Admin7e9c91d2015-08-25 15:53:49 -0700328 logging.info("Inserting flow tagging downstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700329 self.controller.message_send(request)
330 do_barrier(self.controller)
Admin7e9c91d2015-08-25 15:53:49 -0700331 time.sleep(5)
Admin99c2a272016-03-01 12:56:39 -0800332
333
Admin7e9c91d2015-08-25 15:53:49 -0700334 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
335 outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
336 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
337
338 # Send untagged packet in the ONU port and expect tagged packet out the OLT port
339 self.dataplane.send(onu_port, str(inPkt))
340 verify_packet(self, outPkt, olt_port)
341
342 # Send untagged packet in the OLT port and expect no packets to come out
343 self.dataplane.send(olt_port, str(inPkt))
344 verify_packets(self, outPkt, [])
Adminb17b1662015-10-19 15:50:53 -0700345
Admin7e9c91d2015-08-25 15:53:49 -0700346 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700347 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
Admin7e9c91d2015-08-25 15:53:49 -0700348 outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
349
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700350 # Send tagged packet in the OLT port and expect untagged packet out the OLT port
351 self.dataplane.send(olt_port, str(inPkt))
352 verify_packet(self, outPkt, onu_port)
Admin7e9c91d2015-08-25 15:53:49 -0700353
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700354 # Send tagged packet in the ONU port and expect no packets to come out
355 self.dataplane.send(onu_port, str(inPkt))
Admin7e9c91d2015-08-25 15:53:49 -0700356 verify_packets(self, outPkt, [])
Jonathan Hartf65e1812015-10-05 15:15:37 -0700357
358def createAllGroupAdd(group_id, ports=[]):
359 buckets = []
360
361 for portNum in ports:
362 buckets.append(ofp.common.bucket(watch_port=ofp.OFPP_ANY, watch_group=ofp.OFPG_ANY,
Admin99c2a272016-03-01 12:56:39 -0800363 actions=[ofp.action.pop_vlan(), ofp.action.output(port=portNum)]))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700364
365 group_add = ofp.message.group_add(group_type = ofp.OFPGT_ALL, group_id=group_id, buckets=buckets)
366
367 return group_add
368
369def createAllGroupMod(group_id, ports=[]):
370 buckets = []
371
372 for portNum in ports:
373 buckets.append(ofp.common.bucket(watch_port=ofp.OFPP_ANY, watch_group=ofp.OFPG_ANY,
374 actions=[ofp.action.output(port=portNum)]))
375
376 group_mod = ofp.message.group_mod(command=ofp.OFPGC_MODIFY, group_type = ofp.OFPGT_ALL, group_id=group_id, buckets=buckets)
377
378 return group_mod
379
380
Admin02d052c2015-10-10 19:08:26 -0700381class TestGroupAdd(base_tests.SimpleDataPlane):
382
383 def runTest(self):
384 logging.info("Running Group tests")
385 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700386 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700387
Jonathan Hartf65e1812015-10-05 15:15:37 -0700388 test_group_id = 1
389
390 # output to two ONU
391 group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700392
393 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700394 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700395 verify_no_errors(self.controller)
396
397 # Remove the group and then readd it.
Jonathan Hartf65e1812015-10-05 15:15:37 -0700398 group_delete = ofp.message.group_delete(group_id = test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700399 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700400 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700401 verify_no_errors(self.controller)
402
Jonathan Hartf65e1812015-10-05 15:15:37 -0700403 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700404 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700405 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700406 verify_no_errors(self.controller)
407
408
Jonathan Hartf65e1812015-10-05 15:15:37 -0700409 # clean up the test
410 group_delete = ofp.message.group_delete(group_id = test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700411 self.controller.message_send(group_delete)
412
Jonathan Hartf65e1812015-10-05 15:15:37 -0700413 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700414 verify_no_errors(self.controller)
415
416class TestGroupMod(base_tests.SimpleDataPlane):
417
418 def runTest(self):
419 logging.info("Running Group tests")
420 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700421 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700422
Jonathan Hartf65e1812015-10-05 15:15:37 -0700423 test_group_id = 1
424
425 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700426
427 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700428 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700429 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700430
431 # Modifying the group
432 group_mod = createAllGroupMod(test_group_id, [onu_port2])
433
434 self.controller.message_send(group_mod)
435 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700436 verify_no_errors(self.controller)
437
Jonathan Hartf65e1812015-10-05 15:15:37 -0700438 # Add a bucket into the group
439 group_mod = createAllGroupMod(test_group_id, [onu_port, onu_port2])
440 self.controller.message_send(group_mod)
441 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700442 verify_no_errors(self.controller)
443
444 # Modifying a non-existing group
Jonathan Hartf65e1812015-10-05 15:15:37 -0700445 group_mod = createAllGroupMod(777, [onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700446
Jonathan Hartf65e1812015-10-05 15:15:37 -0700447 self.controller.message_send(group_mod)
448 do_barrier(self.controller)
449 errorExperienced = 0
Admin02d052c2015-10-10 19:08:26 -0700450 try:
451 verify_no_errors(self.controller)
452 except AssertionError as e:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700453 errorExperienced = 1
Admin02d052c2015-10-10 19:08:26 -0700454 if (not (e.message == "unexpected error type=6 code=8")):
Jonathan Hartf65e1812015-10-05 15:15:37 -0700455 raise AssertionError("Incorrect error type: %s" % e.message)
456 if not errorExperienced:
457 raise AssertionError("An error message is expected, but not shown.")
458
Admin02d052c2015-10-10 19:08:26 -0700459
Jonathan Hartf65e1812015-10-05 15:15:37 -0700460 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700461 group_delete = ofp.message.group_delete(xid = 2, group_id = test_group_id)
462 self.controller.message_send(group_delete)
463
Jonathan Hartf65e1812015-10-05 15:15:37 -0700464 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700465 verify_no_errors(self.controller)
466
467class TestDuplicateGroup(base_tests.SimpleDataPlane):
468
469 def runTest(self):
470 logging.info("Running Group tests")
471 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700472 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700473
Jonathan Hartf65e1812015-10-05 15:15:37 -0700474 test_group_id = 1
475 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700476
477 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700478 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700479 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700480
481 # Add the same group id
Admin02d052c2015-10-10 19:08:26 -0700482 duplicate_group_fail = 0
Jonathan Hartf65e1812015-10-05 15:15:37 -0700483
Admin02d052c2015-10-10 19:08:26 -0700484 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700485 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700486 try:
487 verify_no_errors(self.controller)
488 except AssertionError as e:
489 duplicate_group_fail = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700490 if (not e.message == "unexpected error type=6 code=0"):
491 raise AssertionError("Incorrect error type: %s" % e.message)
492 if not duplicate_group_fail:
493 raise AssertionError("Adding duplicate groups didn't raise an error.")
494
495 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700496 group_delete = ofp.message.group_delete(xid = 2, group_id = test_group_id)
497 self.controller.message_send(group_delete)
498
Jonathan Hartf65e1812015-10-05 15:15:37 -0700499 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700500 verify_no_errors(self.controller)
501
502class TestGroupAndFlow(base_tests.SimpleDataPlane):
503
504 def runTest(self):
505 logging.info("Running Group tests")
506 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700507 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700508
Jonathan Hartf65e1812015-10-05 15:15:37 -0700509 # Create a group
510 test_group_id = 1
511 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700512
513 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700514 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700515 verify_no_errors(self.controller)
516
517 # Create a flow rule matching olt port and vlan id
518 match = ofp.match()
519 match.oxm_list.append(ofp.oxm.in_port(olt_port))
520 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201))
521
Jonathan Hartf65e1812015-10-05 15:15:37 -0700522 flow_pointing_to_group = ofp.message.flow_add(
Admin02d052c2015-10-10 19:08:26 -0700523 table_id=test_param_get("table", 0),
524 cookie=43,
525 match=match,
526 instructions=[
527 ofp.instruction.apply_actions(
528 actions=[ ofp.action.group( group_id = test_group_id ) ] ) ],
529 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
530
Jonathan Hartf65e1812015-10-05 15:15:37 -0700531 self.controller.message_send(flow_pointing_to_group)
532 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700533 verify_no_errors(self.controller)
534
Jonathan Hartf65e1812015-10-05 15:15:37 -0700535 # After letting a flow rule point to the group, test we can do group_mod
536 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
537 self.controller.message_send(group_mod)
538 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700539 verify_no_errors(self.controller)
540
541 # Test we can remove flows and then remove group
Jonathan Hartf65e1812015-10-05 15:15:37 -0700542 flow_delete = ofp.message.flow_delete( table_id=test_param_get("table", 0))
543 self.controller.message_send(flow_delete)
544 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700545 verify_no_errors(self.controller)
546
547 group_delete = ofp.message.group_delete(xid = 3, group_id = test_group_id)
548 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700549 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700550 verify_no_errors(self.controller)
Admindcb1bc72015-11-12 18:24:56 -0800551
Jonathan Hartf65e1812015-10-05 15:15:37 -0700552 # Add the group and flow back, test it we can first remove group and then remove the flow.
Admindcb1bc72015-11-12 18:24:56 -0800553 '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700554 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700555
556 self.controller.message_send(flow_pointing_to_group)
557 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700558 verify_no_errors(self.controller)
559
560 group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id)
Admindcb1bc72015-11-12 18:24:56 -0800561 self.controller.message_send(group_delete)'''
Jonathan Hartf65e1812015-10-05 15:15:37 -0700562
563 self.controller.message_send(flow_delete)
564 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700565 verify_no_errors(self.controller)
566
567
568class TestGroupForwarding(base_tests.SimpleDataPlane):
569
570 def runTest(self):
571 logging.info("Running Group datapath forwarding tests")
572 delete_all_flows(self.controller)
Admin99c2a272016-03-01 12:56:39 -0800573 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700574
Admin09b5cc62015-10-11 13:53:59 -0700575 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700576
Jonathan Hartf65e1812015-10-05 15:15:37 -0700577 # Create a group
578 test_group_id = 1
579 group_add = createAllGroupAdd(test_group_id, [onu_port])
Admin02d052c2015-10-10 19:08:26 -0700580
581 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700582 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700583 verify_no_errors(self.controller)
584
585 # Create a flow rule matching olt port and vlan id
586 match = ofp.match()
587 match.oxm_list.append(ofp.oxm.in_port(olt_port))
588 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
589
590 request = ofp.message.flow_add(
591 table_id=test_param_get("table", 0),
592 cookie=43,
593 match=match,
594 instructions=[
595 ofp.instruction.apply_actions(
596 actions=[ ofp.action.group( group_id = test_group_id ) ] ),
Jonathan Hartf65e1812015-10-05 15:15:37 -0700597 ],
Admin02d052c2015-10-10 19:08:26 -0700598 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
599
600 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700601 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700602 verify_no_errors(self.controller)
Admin09b5cc62015-10-11 13:53:59 -0700603
604 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800605 time.sleep(10)
Admin02d052c2015-10-10 19:08:26 -0700606
607 inPkt = simple_udp_packet(pktlen=104,dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800608 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
Admin02d052c2015-10-10 19:08:26 -0700609 outPkt = inPkt
610 self.dataplane.send(olt_port, str(inPkt))
611 verify_packet(self, outPkt, onu_port)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700612
Admindcb1bc72015-11-12 18:24:56 -0800613
Jonathan Hartf65e1812015-10-05 15:15:37 -0700614 # Now put 2 ONU ports in the group and test that the input packet is
615 # duplicated out both ports
616 group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2])
617 self.controller.message_send(group_mod)
618 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700619 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700620
Admin09b5cc62015-10-11 13:53:59 -0700621 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800622 time.sleep(10)
Admin09b5cc62015-10-11 13:53:59 -0700623
Jonathan Hartf65e1812015-10-05 15:15:37 -0700624 self.dataplane.send(olt_port, str(inPkt))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700625 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800626 verify_packet(self, outPkt, onu_port)
627 #verify_packets(self, outPkt, [onu_port,onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700628
Jonathan Hartf65e1812015-10-05 15:15:37 -0700629 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700630 request = ofp.message.flow_delete( table_id=test_param_get("table", 0))
631 self.controller.message_send(request)
632 group_delete = ofp.message.group_delete(xid = 2, group_id = test_group_id)
633 self.controller.message_send(group_delete)
634
Jonathan Hartf65e1812015-10-05 15:15:37 -0700635 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700636 verify_no_errors(self.controller)
637
Admindcb1bc72015-11-12 18:24:56 -0800638
639class TestGroupModForwarding(base_tests.SimpleDataPlane):
640
641 def runTest(self):
642 logging.info("Running datapath forwarding tests for group mod" )
643 delete_all_flows(self.controller)
644 delete_all_groups(self.controller)
645
646 vlan_id = 201
647
648 # Create a group
649 test_group_id = 1
650 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
651
652 self.controller.message_send(group_add)
653 do_barrier(self.controller)
654 verify_no_errors(self.controller)
655
656 # Create a flow rule matching olt port and vlan id
657 match = ofp.match()
658 match.oxm_list.append(ofp.oxm.in_port(olt_port))
659 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
660
661 request = ofp.message.flow_add(
662 table_id=test_param_get("table", 0),
663 cookie=43,
664 match=match,
665 instructions=[
666 ofp.instruction.apply_actions(
667 actions=[ ofp.action.group( group_id = test_group_id ) ] ),
668 ],
669 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
670
671 self.controller.message_send(request)
672 do_barrier(self.controller)
673 verify_no_errors(self.controller)
674
675 # It takes some time for flows to propagate down to the data plane
676 time.sleep(10)
677
678 inPkt = simple_udp_packet(pktlen=104,dl_vlan_enable=True,
679 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
680 outPkt = inPkt
681 self.dataplane.send(olt_port, str(inPkt))
682 verify_packet(self, outPkt, onu_port)
Admin99c2a272016-03-01 12:56:39 -0800683 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800684
685 # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1
686 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
687 self.controller.message_send(group_mod)
688 do_barrier(self.controller)
689 verify_no_errors(self.controller)
690
691 time.sleep(10)
692 self.dataplane.send(olt_port, str(inPkt))
693 verify_no_packet(self, outPkt, onu_port)
694 verify_packet(self, outPkt, onu_port2)
695
696 # Now remove all ports in the group and test that the input packet is no longer forwarded to any port
697 group_mod = createAllGroupMod(test_group_id, ports=[])
698 self.controller.message_send(group_mod)
699 do_barrier(self.controller)
700 verify_no_errors(self.controller)
701 time.sleep(10)
702 self.dataplane.send(olt_port, str(inPkt))
703 verify_packets(self, outPkt, [])
704
705
Admin02d052c2015-10-10 19:08:26 -0700706class TransparentVlanTest(base_tests.SimpleDataPlane):
707
708 def runTest(self):
709 logging.info("Running transparent vlan tests")
Admin09b5cc62015-10-11 13:53:59 -0700710 delete_all_flows(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700711
Jonathan Hartf65e1812015-10-05 15:15:37 -0700712 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700713 match = ofp.match()
714 match.oxm_list.append(ofp.oxm.in_port(onu_port))
715 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id ))
716
717 request = ofp.message.flow_add(
718 table_id=test_param_get("table", 0),
719 cookie=42,
720 match=match,
721 instructions=[
722 ofp.instruction.apply_actions(
723 actions=[
724 ofp.action.output(port=olt_port)]),
725 ],
726 buffer_id=ofp.OFP_NO_BUFFER,
727 priority=1000)
728
729 self.controller.message_send(request)
Admin02d052c2015-10-10 19:08:26 -0700730
731 match = ofp.match()
732 match.oxm_list.append(ofp.oxm.in_port(olt_port))
733 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
734
735 request = ofp.message.flow_add(
736 table_id=test_param_get("table", 0),
737 cookie=43,
738 match=match,
739 instructions=[
740 ofp.instruction.apply_actions(
741 actions=[
742 ofp.action.output(port=onu_port)]),
743 ],
744 buffer_id=ofp.OFP_NO_BUFFER,
745 priority=1000)
746
747 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700748 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700749 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700750
Admin09b5cc62015-10-11 13:53:59 -0700751 # It takes some time for flows to propagate down to the data plane
752 time.sleep(2)
Admin02d052c2015-10-10 19:08:26 -0700753
Jonathan Hartf65e1812015-10-05 15:15:37 -0700754 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
Admin02d052c2015-10-10 19:08:26 -0700755 # upstream
756 self.dataplane.send(onu_port, str(inPkt))
757 verify_packet(self, inPkt, olt_port)
Admin99c2a272016-03-01 12:56:39 -0800758 # downstream
759 self.dataplane.send(olt_port, str(inPkt))
760 verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700761
Jonathan Hartf65e1812015-10-05 15:15:37 -0700762 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700763 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700764 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700765 verify_no_errors(self.controller)
766
Adminb17b1662015-10-19 15:50:53 -0700767class DoubleVlanTest(base_tests.SimpleDataPlane):
768
769 def runTest(self):
770 logging.info("Running double vlan tests")
771 delete_all_flows(self.controller)
772
773 c_vlan_id = 100
774 s_vlan_id = 102
775 # upstream flow rule
776 match = ofp.match()
777 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Admindcb1bc72015-11-12 18:24:56 -0800778 match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_PRESENT))
Adminb17b1662015-10-19 15:50:53 -0700779 match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
780
781 # push inner vlan (c-vlan) for upstream
782 request = ofp.message.flow_add(
783 table_id=test_param_get("table", 0),
784 cookie=42,
785 match=match,
786 instructions=[
787 ofp.instruction.apply_actions(
788 actions=[
789 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id)) ] ),
790 ofp.instruction.goto_table(1) ],
791 buffer_id=ofp.OFP_NO_BUFFER,
792 priority=1000)
793
794 self.controller.message_send(request)
795 do_barrier(self.controller)
796 verify_no_errors(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700797
Adminb17b1662015-10-19 15:50:53 -0700798 # push outer vlan (s-vlan) for upstream
799 match = ofp.match()
800 match.oxm_list.append(ofp.oxm.in_port(onu_port))
801 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
802 match.oxm_list.append(ofp.oxm.vlan_pcp( 0 ))
803
804 request = ofp.message.flow_add(
805 table_id=test_param_get("table", 1),
806 cookie=43,
807 match=match,
808 instructions=[
809 ofp.instruction.apply_actions(
810 actions=[
Adminef7a0552015-12-09 15:21:45 -0800811 ofp.action.push_vlan(ethertype=0x8100),
Adminb17b1662015-10-19 15:50:53 -0700812 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id)),
813 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
814 ofp.action.output(port=olt_port)]),
815 ],
816 buffer_id=ofp.OFP_NO_BUFFER,
817 priority=1000)
818
819 self.controller.message_send(request)
820 do_barrier(self.controller)
821 verify_no_errors(self.controller)
822
823 # strip outer vlan (s-vlan) for downstream
824 match = ofp.match()
825 match.oxm_list.append(ofp.oxm.in_port(olt_port))
826 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id))
827 match.oxm_list.append(ofp.oxm.vlan_pcp( 0 ))
828 request = ofp.message.flow_add(
829 table_id=test_param_get("table", 0),
830 cookie=44,
831 match=match,
832 instructions=[
833 ofp.instruction.apply_actions(
834 actions=[ ofp.action.pop_vlan() ] ),
835 ofp.instruction.goto_table(1) ],
836 buffer_id=ofp.OFP_NO_BUFFER,
837 priority=1000)
838
839 self.controller.message_send(request)
840 do_barrier(self.controller)
841 verify_no_errors(self.controller)
842
Admindcb1bc72015-11-12 18:24:56 -0800843 # rewrite inner vlan (c-vlan) to default (0) for downstream
Adminb17b1662015-10-19 15:50:53 -0700844 match = ofp.match()
845 match.oxm_list.append(ofp.oxm.in_port(olt_port))
846 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
847 match.oxm_list.append(ofp.oxm.vlan_pcp( 0 ))
848
849 request = ofp.message.flow_add(
850 table_id=test_param_get("table", 1),
851 cookie=45,
852 match=match,
853 instructions=[
854 ofp.instruction.apply_actions(
855 actions=[
Admindcb1bc72015-11-12 18:24:56 -0800856 ofp.action.pop_vlan(),
Adminb17b1662015-10-19 15:50:53 -0700857 ofp.action.output(port=onu_port) ] )
858 ],
859 buffer_id=ofp.OFP_NO_BUFFER,
860 priority=1000)
861
862 self.controller.message_send(request)
863 do_barrier(self.controller)
864 verify_no_errors(self.controller)
865 # It takes some time for flows to propagate down to the data plane
866 time.sleep(10)
Admindcb1bc72015-11-12 18:24:56 -0800867 incorrectTagPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=100, vlan_pcp=0)
Adminb17b1662015-10-19 15:50:53 -0700868 untaggedPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
Admindcb1bc72015-11-12 18:24:56 -0800869
870
871 '''
872 FIXME: hack because OLT does _not_ tag packets correctly
873 it ignores the eth_type in the push_vlan action
874 and always slaps on 0x8100 even though the
875 down stream flow must be 0x88a8.
876 '''
Adminb17b1662015-10-19 15:50:53 -0700877 doubleTaggedPkt = double_vlan_udp_packet(pktlen=104, dl_vlan_enable=True,
878 c_vlan_vid=c_vlan_id,
879 s_vlan_vid=s_vlan_id,
Admindcb1bc72015-11-12 18:24:56 -0800880 c_vlan_pcp=0, s_vlan_pcp=0, eth_type=0x88a8)
881
882 upstreamDoubleTaggedPkt = double_vlan_udp_packet(pktlen=104, dl_vlan_enable=True,
883 c_vlan_vid=c_vlan_id,
884 s_vlan_vid=s_vlan_id,
Adminb17b1662015-10-19 15:50:53 -0700885 c_vlan_pcp=0, s_vlan_pcp=0)
Admindcb1bc72015-11-12 18:24:56 -0800886
Adminb17b1662015-10-19 15:50:53 -0700887 # test upstream untagged packet got double tag at OLT
888 logging.info(str(doubleTaggedPkt))
889 self.dataplane.send(onu_port, str(untaggedPkt))
Admindcb1bc72015-11-12 18:24:56 -0800890 verify_packet(self, upstreamDoubleTaggedPkt, olt_port)
891
892 # test downstream doubletagged packet got untagged at ONU
Adminb17b1662015-10-19 15:50:53 -0700893 self.dataplane.send(olt_port, str(doubleTaggedPkt))
894 verify_packet(self, untaggedPkt, onu_port)
Adminb17b1662015-10-19 15:50:53 -0700895
Admindcb1bc72015-11-12 18:24:56 -0800896 # test upstream doubletagged packet got dropped
897 self.dataplane.send(onu_port, str(doubleTaggedPkt))
898 verify_no_packet(self, upstreamDoubleTaggedPkt, olt_port)
899
900 # test downstream untagged packet got dropped at ONU
901 self.dataplane.send(olt_port, str(untaggedPkt))
902 verify_no_packet(self, untaggedPkt, onu_port)
903
904 # test upstream icorrectly tagged packet; should get dropped
905 self.dataplane.send(onu_port, str(incorrectTagPkt))
906 verify_no_packet(self, upstreamDoubleTaggedPkt, olt_port)
907
908 time.sleep(2)
Adminb17b1662015-10-19 15:50:53 -0700909
910 # clean up the test
911 delete_all_flows(self.controller)
912 do_barrier(self.controller)
913 verify_no_errors(self.controller)