blob: 843f92fd481e90766634272db676ed6947bf9c63 [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)
16onu_port2 = test_param_get("onu_port2", 131)
17olt_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)
120 return ether / ip / payload
121
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700122class EapolPacketIn(base_tests.SimpleDataPlane):
123
124 """Verify packet-ins are sent for EAPOL packets """
125
126 def runTest(self):
127 logging.info("Running EAPOL Packet In test")
128
129 match = ofp.match()
130 match.oxm_list.append(ofp.oxm.eth_type(0x888e))
131 # Use ethertype 0x888e and multicast destination MAC address
132 pkt = simple_eth_packet(pktlen=60, eth_dst='01:00:5E:7F:FF:FF', eth_type=0x888e)
133
134 testPacketIn(self, match, pkt)
135
136class ARPPacketIn(base_tests.SimpleDataPlane):
137
138 """Verify packet-ins are sent for ARP packets """
139
140 def runTest(self):
141 logging.info("Running ARP Packet In test")
142
143 match = ofp.match()
144 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
145
146 # Use ethertype 0x0806
147 pkt = simple_eth_packet(eth_type=0x0806)
148
149 testPacketIn(self, match, pkt)
150
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700151class IGMPPacketIn(base_tests.SimpleDataPlane):
152
153 """Verify packet-ins are sent for IGMP packets """
154
155 def runTest(self):
156 logging.info("Running IGMP Packet In test")
157
158 match = ofp.match()
159 match.oxm_list.append(ofp.oxm.eth_type(0x800))
160 match.oxm_list.append(ofp.oxm.ip_proto(2))
161
162 pkt = scapy.Ether(dst='01:00:5E:7F:FF:FF', src='00:00:00:00:00:01')/ \
163 scapy.IP(src='10.0.0.1', dst='10.0.0.2', ttl=60, tos=0, id=0, proto=2)
164
165 pkt = pkt/("0" * (100 - len(pkt)))
166
167 testPacketIn(self, match, pkt)
Admin7e9c91d2015-08-25 15:53:49 -0700168
Admind5212782015-12-09 17:17:57 -0800169class IGMPQueryPacketOut(base_tests.SimpleDataPlane):
170
171 """Verify sending multicast membership queries down to onu_ports"""
172
173 def runTest(self):
174 logging.info("Running IGMP query packet out")
175
176 igmp = scapy.IGMP(type = 0x11, gaddr = "224.0.0.1")
177 pkt = buildIgmp(igmp)
178
179 msg = ofp.message.packet_out()
180 msg.in_port = ofp.OFPP_CONTROLLER
181 #msg.buffer_id = 0xffffffff
182 msg.data = str(pkt)
183 msg.actions = [ofp.action.output(
184 port=onu_port,
185 max_len=ofp.OFPCML_NO_BUFFER)]
186 time.sleep(1)
187
188 self.controller.message_send(msg)
189
190 verify_no_errors(self.controller)
191
192 verify_packet(self, pkt, onu_port)
193
Admin7e9c91d2015-08-25 15:53:49 -0700194class TestMeter(base_tests.SimpleDataPlane):
195
196 def runTest(self):
197 logging.info("Running Meter tests")
Adminef7a0552015-12-09 15:21:45 -0800198 dropMeterBand = ofp.meter_band.drop(rate = 64)
Admin7e9c91d2015-08-25 15:53:49 -0700199 meter_mod = ofp.message.meter_mod(xid = 1, command = ofp.OFPMC_ADD, meter_id = 1, meters = [ dropMeterBand ])
200 self.controller.message_send(meter_mod)
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700201
Admin7e9c91d2015-08-25 15:53:49 -0700202 time.sleep(1)
203
204 verify_no_errors(self.controller)
205
Jonathan Hartf65e1812015-10-05 15:15:37 -0700206 vlan_id = 201
Admin7e9c91d2015-08-25 15:53:49 -0700207 match = ofp.match()
208 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Admin02d052c2015-10-10 19:08:26 -0700209 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id ))
210
211 request = ofp.message.flow_add(
212 table_id=test_param_get("table", 0),
213 cookie=42,
214 match=match,
215 instructions=[
216 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700217 actions=[ofp.action.output(port=olt_port)]
218 ),
Admin02d052c2015-10-10 19:08:26 -0700219 ofp.instruction.meter(meter_id = 1)
220 ],
221 buffer_id=ofp.OFP_NO_BUFFER,
222 priority=1000)
223
224 self.controller.message_send(request)
225 time.sleep(1)
226 verify_no_errors(self.controller)
227
228 match = ofp.match()
229 match.oxm_list.append(ofp.oxm.in_port(olt_port))
230 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700231
232 request = ofp.message.flow_add(
233 table_id=test_param_get("table", 0),
234 cookie=43,
235 match=match,
236 instructions=[
237 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700238 actions=[ofp.action.output(port=onu_port)]
239 ),
240 ofp.instruction.meter(meter_id = 1)
Admin7e9c91d2015-08-25 15:53:49 -0700241 ],
242 buffer_id=ofp.OFP_NO_BUFFER,
243 priority=1000)
244
245 self.controller.message_send(request)
Admin7e9c91d2015-08-25 15:53:49 -0700246 time.sleep(1)
Admin7e9c91d2015-08-25 15:53:49 -0700247 verify_no_errors(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700248 do_barrier(self.controller)
249 time.sleep(5)
Admin7e9c91d2015-08-25 15:53:49 -0700250
Jonathan Hartf65e1812015-10-05 15:15:37 -0700251 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
252 # downstream
Adminef7a0552015-12-09 15:21:45 -0800253 #self.dataplane.send(olt_port, str(inPkt))
254 #verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700255 # upstream
Adminef7a0552015-12-09 15:21:45 -0800256 for i in range(1,400):
257 self.dataplane.send(onu_port, str(inPkt))
Admin09b5cc62015-10-11 13:53:59 -0700258 verify_packet(self, inPkt, olt_port)
Admin02d052c2015-10-10 19:08:26 -0700259
Jonathan Hartf65e1812015-10-05 15:15:37 -0700260 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700261 meter_mod = ofp.message.meter_mod(xid = 2, command = ofp.OFPMC_DELETE, meter_id = 1)
262 self.controller.message_send(meter_mod)
263 time.sleep(1)
264 delete_all_flows(self.controller)
265 verify_no_errors(self.controller)
266
267
Admin7e9c91d2015-08-25 15:53:49 -0700268class TestDuplicateMeter(base_tests.SimpleDataPlane):
269
270 def runTest(self):
271 logging.info("Running Duplicate Meter Test")
272 dropMeterBand = ofp.meter_band.drop(rate = 500)
273 meter_mod = ofp.message.meter_mod(xid = 1, command = ofp.OFPMC_ADD, meter_id = 1, meters = [ dropMeterBand ])
274 self.controller.message_send(meter_mod)
275 self.controller.message_send(meter_mod)
276
277 time.sleep(1)
278
279 try:
280 verify_no_errors(self.controller)
281 except AssertionError as e:
Admin09b5cc62015-10-11 13:53:59 -0700282 if (not e.message == "unexpected error type=12 code=1"):
Admin7e9c91d2015-08-25 15:53:49 -0700283 raise AssertionError("Incorrect error type: %s" % e.message)
284
285
286class VlanTest(base_tests.SimpleDataPlane):
287
288 """Verify the switch can push/pop a VLAN tag and forward out a port """
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700289
290 def runTest(self):
291 logging.info("Running push VLAN test")
292
293 vlan_id = 200
294
295 delete_all_flows(self.controller)
Admin7e9c91d2015-08-25 15:53:49 -0700296
297 #PUSH
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700298 match = ofp.match()
299 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Admin7e9c91d2015-08-25 15:53:49 -0700300 match.oxm_list.append(ofp.oxm.vlan_vid_masked(value=ofp.OFPVID_PRESENT, value_mask=ofp.OFPVID_PRESENT))
301 match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700302
303 request = ofp.message.flow_add(
304 table_id=test_param_get("table", 0),
305 cookie=42,
306 match=match,
307 instructions=[
308 ofp.instruction.apply_actions(
309 actions=[
310 ofp.action.push_vlan(ethertype=0x8100),
311 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
Admin7e9c91d2015-08-25 15:53:49 -0700312 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700313 ofp.action.output(port=olt_port)])],
314 buffer_id=ofp.OFP_NO_BUFFER,
315 priority=1000)
316
Admin7e9c91d2015-08-25 15:53:49 -0700317 logging.info("Inserting flow tagging upstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700318 self.controller.message_send(request)
Adminb17b1662015-10-19 15:50:53 -0700319
Admin02d052c2015-10-10 19:08:26 -0700320 #POP
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700321 match = ofp.match()
322 match.oxm_list.append(ofp.oxm.in_port(olt_port))
323 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700324
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700325 request = ofp.message.flow_add(
326 table_id=test_param_get("table", 0),
Admin7e9c91d2015-08-25 15:53:49 -0700327 cookie=43,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700328 match=match,
329 instructions=[
330 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700331 actions=[
332 ofp.action.pop_vlan(),
Admin09b5cc62015-10-11 13:53:59 -0700333 ofp.action.output(port=onu_port)])],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700334 buffer_id=ofp.OFP_NO_BUFFER,
335 priority=1000)
336
Admin7e9c91d2015-08-25 15:53:49 -0700337 logging.info("Inserting flow tagging downstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700338 self.controller.message_send(request)
339 do_barrier(self.controller)
Admin7e9c91d2015-08-25 15:53:49 -0700340 time.sleep(5)
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700341
Admin7e9c91d2015-08-25 15:53:49 -0700342 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
343 outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
344 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
345
346 # Send untagged packet in the ONU port and expect tagged packet out the OLT port
347 self.dataplane.send(onu_port, str(inPkt))
348 verify_packet(self, outPkt, olt_port)
349
350 # Send untagged packet in the OLT port and expect no packets to come out
351 self.dataplane.send(olt_port, str(inPkt))
352 verify_packets(self, outPkt, [])
Adminb17b1662015-10-19 15:50:53 -0700353
Admin7e9c91d2015-08-25 15:53:49 -0700354 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700355 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
Admin7e9c91d2015-08-25 15:53:49 -0700356 outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
357
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700358 # Send tagged packet in the OLT port and expect untagged packet out the OLT port
359 self.dataplane.send(olt_port, str(inPkt))
360 verify_packet(self, outPkt, onu_port)
Admin7e9c91d2015-08-25 15:53:49 -0700361
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700362 # Send tagged packet in the ONU port and expect no packets to come out
363 self.dataplane.send(onu_port, str(inPkt))
Admin7e9c91d2015-08-25 15:53:49 -0700364 verify_packets(self, outPkt, [])
Jonathan Hartf65e1812015-10-05 15:15:37 -0700365
366def createAllGroupAdd(group_id, ports=[]):
367 buckets = []
368
369 for portNum in ports:
370 buckets.append(ofp.common.bucket(watch_port=ofp.OFPP_ANY, watch_group=ofp.OFPG_ANY,
371 actions=[ofp.action.output(port=portNum)]))
372
373 group_add = ofp.message.group_add(group_type = ofp.OFPGT_ALL, group_id=group_id, buckets=buckets)
374
375 return group_add
376
377def createAllGroupMod(group_id, ports=[]):
378 buckets = []
379
380 for portNum in ports:
381 buckets.append(ofp.common.bucket(watch_port=ofp.OFPP_ANY, watch_group=ofp.OFPG_ANY,
382 actions=[ofp.action.output(port=portNum)]))
383
384 group_mod = ofp.message.group_mod(command=ofp.OFPGC_MODIFY, group_type = ofp.OFPGT_ALL, group_id=group_id, buckets=buckets)
385
386 return group_mod
387
388
Admin02d052c2015-10-10 19:08:26 -0700389class TestGroupAdd(base_tests.SimpleDataPlane):
390
391 def runTest(self):
392 logging.info("Running Group tests")
393 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700394 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700395
Jonathan Hartf65e1812015-10-05 15:15:37 -0700396 test_group_id = 1
397
398 # output to two ONU
399 group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700400
401 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700402 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700403 verify_no_errors(self.controller)
404
405 # Remove the group and then readd it.
Jonathan Hartf65e1812015-10-05 15:15:37 -0700406 group_delete = ofp.message.group_delete(group_id = test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700407 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700408 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700409 verify_no_errors(self.controller)
410
Jonathan Hartf65e1812015-10-05 15:15:37 -0700411 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700412 self.controller.message_send(group_add)
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
416
Jonathan Hartf65e1812015-10-05 15:15:37 -0700417 # clean up the test
418 group_delete = ofp.message.group_delete(group_id = test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700419 self.controller.message_send(group_delete)
420
Jonathan Hartf65e1812015-10-05 15:15:37 -0700421 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700422 verify_no_errors(self.controller)
423
424class TestGroupMod(base_tests.SimpleDataPlane):
425
426 def runTest(self):
427 logging.info("Running Group tests")
428 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700429 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700430
Jonathan Hartf65e1812015-10-05 15:15:37 -0700431 test_group_id = 1
432
433 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700434
435 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700436 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700437 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700438
439 # Modifying the group
440 group_mod = createAllGroupMod(test_group_id, [onu_port2])
441
442 self.controller.message_send(group_mod)
443 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700444 verify_no_errors(self.controller)
445
Jonathan Hartf65e1812015-10-05 15:15:37 -0700446 # Add a bucket into the group
447 group_mod = createAllGroupMod(test_group_id, [onu_port, onu_port2])
448 self.controller.message_send(group_mod)
449 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700450 verify_no_errors(self.controller)
451
452 # Modifying a non-existing group
Jonathan Hartf65e1812015-10-05 15:15:37 -0700453 group_mod = createAllGroupMod(777, [onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700454
Jonathan Hartf65e1812015-10-05 15:15:37 -0700455 self.controller.message_send(group_mod)
456 do_barrier(self.controller)
457 errorExperienced = 0
Admin02d052c2015-10-10 19:08:26 -0700458 try:
459 verify_no_errors(self.controller)
460 except AssertionError as e:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700461 errorExperienced = 1
Admin02d052c2015-10-10 19:08:26 -0700462 if (not (e.message == "unexpected error type=6 code=8")):
Jonathan Hartf65e1812015-10-05 15:15:37 -0700463 raise AssertionError("Incorrect error type: %s" % e.message)
464 if not errorExperienced:
465 raise AssertionError("An error message is expected, but not shown.")
466
Admin02d052c2015-10-10 19:08:26 -0700467
Jonathan Hartf65e1812015-10-05 15:15:37 -0700468 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700469 group_delete = ofp.message.group_delete(xid = 2, group_id = test_group_id)
470 self.controller.message_send(group_delete)
471
Jonathan Hartf65e1812015-10-05 15:15:37 -0700472 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700473 verify_no_errors(self.controller)
474
475class TestDuplicateGroup(base_tests.SimpleDataPlane):
476
477 def runTest(self):
478 logging.info("Running Group tests")
479 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700480 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700481
Jonathan Hartf65e1812015-10-05 15:15:37 -0700482 test_group_id = 1
483 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700484
485 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700486 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700487 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700488
489 # Add the same group id
Admin02d052c2015-10-10 19:08:26 -0700490 duplicate_group_fail = 0
Jonathan Hartf65e1812015-10-05 15:15:37 -0700491
Admin02d052c2015-10-10 19:08:26 -0700492 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700493 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700494 try:
495 verify_no_errors(self.controller)
496 except AssertionError as e:
497 duplicate_group_fail = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700498 if (not e.message == "unexpected error type=6 code=0"):
499 raise AssertionError("Incorrect error type: %s" % e.message)
500 if not duplicate_group_fail:
501 raise AssertionError("Adding duplicate groups didn't raise an error.")
502
503 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700504 group_delete = ofp.message.group_delete(xid = 2, group_id = test_group_id)
505 self.controller.message_send(group_delete)
506
Jonathan Hartf65e1812015-10-05 15:15:37 -0700507 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700508 verify_no_errors(self.controller)
509
510class TestGroupAndFlow(base_tests.SimpleDataPlane):
511
512 def runTest(self):
513 logging.info("Running Group tests")
514 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700515 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700516
Jonathan Hartf65e1812015-10-05 15:15:37 -0700517 # Create a group
518 test_group_id = 1
519 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700520
521 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700522 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700523 verify_no_errors(self.controller)
524
525 # Create a flow rule matching olt port and vlan id
526 match = ofp.match()
527 match.oxm_list.append(ofp.oxm.in_port(olt_port))
528 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201))
529
Jonathan Hartf65e1812015-10-05 15:15:37 -0700530 flow_pointing_to_group = ofp.message.flow_add(
Admin02d052c2015-10-10 19:08:26 -0700531 table_id=test_param_get("table", 0),
532 cookie=43,
533 match=match,
534 instructions=[
535 ofp.instruction.apply_actions(
536 actions=[ ofp.action.group( group_id = test_group_id ) ] ) ],
537 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
538
Jonathan Hartf65e1812015-10-05 15:15:37 -0700539 self.controller.message_send(flow_pointing_to_group)
540 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700541 verify_no_errors(self.controller)
542
Jonathan Hartf65e1812015-10-05 15:15:37 -0700543 # After letting a flow rule point to the group, test we can do group_mod
544 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
545 self.controller.message_send(group_mod)
546 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700547 verify_no_errors(self.controller)
548
549 # Test we can remove flows and then remove group
Jonathan Hartf65e1812015-10-05 15:15:37 -0700550 flow_delete = ofp.message.flow_delete( table_id=test_param_get("table", 0))
551 self.controller.message_send(flow_delete)
552 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700553 verify_no_errors(self.controller)
554
555 group_delete = ofp.message.group_delete(xid = 3, group_id = test_group_id)
556 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700557 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700558 verify_no_errors(self.controller)
Admindcb1bc72015-11-12 18:24:56 -0800559
Jonathan Hartf65e1812015-10-05 15:15:37 -0700560 # Add the group and flow back, test it we can first remove group and then remove the flow.
Admindcb1bc72015-11-12 18:24:56 -0800561 '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700562 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700563
564 self.controller.message_send(flow_pointing_to_group)
565 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700566 verify_no_errors(self.controller)
567
568 group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id)
Admindcb1bc72015-11-12 18:24:56 -0800569 self.controller.message_send(group_delete)'''
Jonathan Hartf65e1812015-10-05 15:15:37 -0700570
571 self.controller.message_send(flow_delete)
572 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700573 verify_no_errors(self.controller)
574
575
576class TestGroupForwarding(base_tests.SimpleDataPlane):
577
578 def runTest(self):
579 logging.info("Running Group datapath forwarding tests")
580 delete_all_flows(self.controller)
Admin09b5cc62015-10-11 13:53:59 -0700581 #delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700582
Admin09b5cc62015-10-11 13:53:59 -0700583 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700584
Jonathan Hartf65e1812015-10-05 15:15:37 -0700585 # Create a group
586 test_group_id = 1
587 group_add = createAllGroupAdd(test_group_id, [onu_port])
Admin02d052c2015-10-10 19:08:26 -0700588
589 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700590 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700591 verify_no_errors(self.controller)
592
593 # Create a flow rule matching olt port and vlan id
594 match = ofp.match()
595 match.oxm_list.append(ofp.oxm.in_port(olt_port))
596 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
597
598 request = ofp.message.flow_add(
599 table_id=test_param_get("table", 0),
600 cookie=43,
601 match=match,
602 instructions=[
603 ofp.instruction.apply_actions(
604 actions=[ ofp.action.group( group_id = test_group_id ) ] ),
Jonathan Hartf65e1812015-10-05 15:15:37 -0700605 ],
Admin02d052c2015-10-10 19:08:26 -0700606 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
607
608 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700609 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700610 verify_no_errors(self.controller)
Admin09b5cc62015-10-11 13:53:59 -0700611
612 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800613 time.sleep(10)
Admin02d052c2015-10-10 19:08:26 -0700614
615 inPkt = simple_udp_packet(pktlen=104,dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800616 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 -0700617 outPkt = inPkt
618 self.dataplane.send(olt_port, str(inPkt))
619 verify_packet(self, outPkt, onu_port)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700620
Admindcb1bc72015-11-12 18:24:56 -0800621
Jonathan Hartf65e1812015-10-05 15:15:37 -0700622 # Now put 2 ONU ports in the group and test that the input packet is
623 # duplicated out both ports
624 group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2])
625 self.controller.message_send(group_mod)
626 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700627 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700628
Admin09b5cc62015-10-11 13:53:59 -0700629 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800630 time.sleep(10)
Admin09b5cc62015-10-11 13:53:59 -0700631
Jonathan Hartf65e1812015-10-05 15:15:37 -0700632 self.dataplane.send(olt_port, str(inPkt))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700633 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800634 verify_packet(self, outPkt, onu_port)
635 #verify_packets(self, outPkt, [onu_port,onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700636
Jonathan Hartf65e1812015-10-05 15:15:37 -0700637 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700638 request = ofp.message.flow_delete( table_id=test_param_get("table", 0))
639 self.controller.message_send(request)
640 group_delete = ofp.message.group_delete(xid = 2, group_id = test_group_id)
641 self.controller.message_send(group_delete)
642
Jonathan Hartf65e1812015-10-05 15:15:37 -0700643 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700644 verify_no_errors(self.controller)
645
Admindcb1bc72015-11-12 18:24:56 -0800646
647class TestGroupModForwarding(base_tests.SimpleDataPlane):
648
649 def runTest(self):
650 logging.info("Running datapath forwarding tests for group mod" )
651 delete_all_flows(self.controller)
652 delete_all_groups(self.controller)
653
654 vlan_id = 201
655
656 # Create a group
657 test_group_id = 1
658 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
659
660 self.controller.message_send(group_add)
661 do_barrier(self.controller)
662 verify_no_errors(self.controller)
663
664 # Create a flow rule matching olt port and vlan id
665 match = ofp.match()
666 match.oxm_list.append(ofp.oxm.in_port(olt_port))
667 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
668
669 request = ofp.message.flow_add(
670 table_id=test_param_get("table", 0),
671 cookie=43,
672 match=match,
673 instructions=[
674 ofp.instruction.apply_actions(
675 actions=[ ofp.action.group( group_id = test_group_id ) ] ),
676 ],
677 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
678
679 self.controller.message_send(request)
680 do_barrier(self.controller)
681 verify_no_errors(self.controller)
682
683 # It takes some time for flows to propagate down to the data plane
684 time.sleep(10)
685
686 inPkt = simple_udp_packet(pktlen=104,dl_vlan_enable=True,
687 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
688 outPkt = inPkt
689 self.dataplane.send(olt_port, str(inPkt))
690 verify_packet(self, outPkt, onu_port)
691 #verify_packet(self, outPkt, onu_port2)
692
693 # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1
694 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
695 self.controller.message_send(group_mod)
696 do_barrier(self.controller)
697 verify_no_errors(self.controller)
698
699 time.sleep(10)
700 self.dataplane.send(olt_port, str(inPkt))
701 verify_no_packet(self, outPkt, onu_port)
702 verify_packet(self, outPkt, onu_port2)
703
704 # Now remove all ports in the group and test that the input packet is no longer forwarded to any port
705 group_mod = createAllGroupMod(test_group_id, ports=[])
706 self.controller.message_send(group_mod)
707 do_barrier(self.controller)
708 verify_no_errors(self.controller)
709 time.sleep(10)
710 self.dataplane.send(olt_port, str(inPkt))
711 verify_packets(self, outPkt, [])
712
713
Admin02d052c2015-10-10 19:08:26 -0700714class TransparentVlanTest(base_tests.SimpleDataPlane):
715
716 def runTest(self):
717 logging.info("Running transparent vlan tests")
Admin09b5cc62015-10-11 13:53:59 -0700718 delete_all_flows(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700719
Jonathan Hartf65e1812015-10-05 15:15:37 -0700720 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700721 match = ofp.match()
722 match.oxm_list.append(ofp.oxm.in_port(onu_port))
723 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id ))
724
725 request = ofp.message.flow_add(
726 table_id=test_param_get("table", 0),
727 cookie=42,
728 match=match,
729 instructions=[
730 ofp.instruction.apply_actions(
731 actions=[
732 ofp.action.output(port=olt_port)]),
733 ],
734 buffer_id=ofp.OFP_NO_BUFFER,
735 priority=1000)
736
737 self.controller.message_send(request)
Admin02d052c2015-10-10 19:08:26 -0700738
739 match = ofp.match()
740 match.oxm_list.append(ofp.oxm.in_port(olt_port))
741 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
742
743 request = ofp.message.flow_add(
744 table_id=test_param_get("table", 0),
745 cookie=43,
746 match=match,
747 instructions=[
748 ofp.instruction.apply_actions(
749 actions=[
750 ofp.action.output(port=onu_port)]),
751 ],
752 buffer_id=ofp.OFP_NO_BUFFER,
753 priority=1000)
754
755 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700756 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700757 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700758
Admin09b5cc62015-10-11 13:53:59 -0700759 # It takes some time for flows to propagate down to the data plane
760 time.sleep(2)
Admin02d052c2015-10-10 19:08:26 -0700761
Jonathan Hartf65e1812015-10-05 15:15:37 -0700762 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
763 # downstream
Admin02d052c2015-10-10 19:08:26 -0700764 self.dataplane.send(olt_port, str(inPkt))
765 verify_packet(self, inPkt, onu_port)
766 # upstream
767 self.dataplane.send(onu_port, str(inPkt))
768 verify_packet(self, inPkt, olt_port)
769
770
Jonathan Hartf65e1812015-10-05 15:15:37 -0700771 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700772 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700773 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700774 verify_no_errors(self.controller)
775
Adminb17b1662015-10-19 15:50:53 -0700776class DoubleVlanTest(base_tests.SimpleDataPlane):
777
778 def runTest(self):
779 logging.info("Running double vlan tests")
780 delete_all_flows(self.controller)
781
782 c_vlan_id = 100
783 s_vlan_id = 102
784 # upstream flow rule
785 match = ofp.match()
786 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Admindcb1bc72015-11-12 18:24:56 -0800787 match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_PRESENT))
Adminb17b1662015-10-19 15:50:53 -0700788 match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
789
790 # push inner vlan (c-vlan) for upstream
791 request = ofp.message.flow_add(
792 table_id=test_param_get("table", 0),
793 cookie=42,
794 match=match,
795 instructions=[
796 ofp.instruction.apply_actions(
797 actions=[
798 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id)) ] ),
799 ofp.instruction.goto_table(1) ],
800 buffer_id=ofp.OFP_NO_BUFFER,
801 priority=1000)
802
803 self.controller.message_send(request)
804 do_barrier(self.controller)
805 verify_no_errors(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700806
Adminb17b1662015-10-19 15:50:53 -0700807 # push outer vlan (s-vlan) for upstream
808 match = ofp.match()
809 match.oxm_list.append(ofp.oxm.in_port(onu_port))
810 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
811 match.oxm_list.append(ofp.oxm.vlan_pcp( 0 ))
812
813 request = ofp.message.flow_add(
814 table_id=test_param_get("table", 1),
815 cookie=43,
816 match=match,
817 instructions=[
818 ofp.instruction.apply_actions(
819 actions=[
Adminef7a0552015-12-09 15:21:45 -0800820 ofp.action.push_vlan(ethertype=0x8100),
Adminb17b1662015-10-19 15:50:53 -0700821 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id)),
822 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
823 ofp.action.output(port=olt_port)]),
824 ],
825 buffer_id=ofp.OFP_NO_BUFFER,
826 priority=1000)
827
828 self.controller.message_send(request)
829 do_barrier(self.controller)
830 verify_no_errors(self.controller)
831
832 # strip outer vlan (s-vlan) for downstream
833 match = ofp.match()
834 match.oxm_list.append(ofp.oxm.in_port(olt_port))
835 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id))
836 match.oxm_list.append(ofp.oxm.vlan_pcp( 0 ))
837 request = ofp.message.flow_add(
838 table_id=test_param_get("table", 0),
839 cookie=44,
840 match=match,
841 instructions=[
842 ofp.instruction.apply_actions(
843 actions=[ ofp.action.pop_vlan() ] ),
844 ofp.instruction.goto_table(1) ],
845 buffer_id=ofp.OFP_NO_BUFFER,
846 priority=1000)
847
848 self.controller.message_send(request)
849 do_barrier(self.controller)
850 verify_no_errors(self.controller)
851
Admindcb1bc72015-11-12 18:24:56 -0800852 # rewrite inner vlan (c-vlan) to default (0) for downstream
Adminb17b1662015-10-19 15:50:53 -0700853 match = ofp.match()
854 match.oxm_list.append(ofp.oxm.in_port(olt_port))
855 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
856 match.oxm_list.append(ofp.oxm.vlan_pcp( 0 ))
857
858 request = ofp.message.flow_add(
859 table_id=test_param_get("table", 1),
860 cookie=45,
861 match=match,
862 instructions=[
863 ofp.instruction.apply_actions(
864 actions=[
Admindcb1bc72015-11-12 18:24:56 -0800865 ofp.action.pop_vlan(),
Adminb17b1662015-10-19 15:50:53 -0700866 ofp.action.output(port=onu_port) ] )
867 ],
868 buffer_id=ofp.OFP_NO_BUFFER,
869 priority=1000)
870
871 self.controller.message_send(request)
872 do_barrier(self.controller)
873 verify_no_errors(self.controller)
874 # It takes some time for flows to propagate down to the data plane
875 time.sleep(10)
Admindcb1bc72015-11-12 18:24:56 -0800876 incorrectTagPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=100, vlan_pcp=0)
Adminb17b1662015-10-19 15:50:53 -0700877 untaggedPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
Admindcb1bc72015-11-12 18:24:56 -0800878
879
880 '''
881 FIXME: hack because OLT does _not_ tag packets correctly
882 it ignores the eth_type in the push_vlan action
883 and always slaps on 0x8100 even though the
884 down stream flow must be 0x88a8.
885 '''
Adminb17b1662015-10-19 15:50:53 -0700886 doubleTaggedPkt = double_vlan_udp_packet(pktlen=104, dl_vlan_enable=True,
887 c_vlan_vid=c_vlan_id,
888 s_vlan_vid=s_vlan_id,
Admindcb1bc72015-11-12 18:24:56 -0800889 c_vlan_pcp=0, s_vlan_pcp=0, eth_type=0x88a8)
890
891 upstreamDoubleTaggedPkt = double_vlan_udp_packet(pktlen=104, dl_vlan_enable=True,
892 c_vlan_vid=c_vlan_id,
893 s_vlan_vid=s_vlan_id,
Adminb17b1662015-10-19 15:50:53 -0700894 c_vlan_pcp=0, s_vlan_pcp=0)
Admindcb1bc72015-11-12 18:24:56 -0800895
Adminb17b1662015-10-19 15:50:53 -0700896 # test upstream untagged packet got double tag at OLT
897 logging.info(str(doubleTaggedPkt))
898 self.dataplane.send(onu_port, str(untaggedPkt))
Admindcb1bc72015-11-12 18:24:56 -0800899 verify_packet(self, upstreamDoubleTaggedPkt, olt_port)
900
901 # test downstream doubletagged packet got untagged at ONU
Adminb17b1662015-10-19 15:50:53 -0700902 self.dataplane.send(olt_port, str(doubleTaggedPkt))
903 verify_packet(self, untaggedPkt, onu_port)
Adminb17b1662015-10-19 15:50:53 -0700904
Admindcb1bc72015-11-12 18:24:56 -0800905 # test upstream doubletagged packet got dropped
906 self.dataplane.send(onu_port, str(doubleTaggedPkt))
907 verify_no_packet(self, upstreamDoubleTaggedPkt, olt_port)
908
909 # test downstream untagged packet got dropped at ONU
910 self.dataplane.send(olt_port, str(untaggedPkt))
911 verify_no_packet(self, untaggedPkt, onu_port)
912
913 # test upstream icorrectly tagged packet; should get dropped
914 self.dataplane.send(onu_port, str(incorrectTagPkt))
915 verify_no_packet(self, upstreamDoubleTaggedPkt, olt_port)
916
917 time.sleep(2)
Adminb17b1662015-10-19 15:50:53 -0700918
919 # clean up the test
920 delete_all_flows(self.controller)
921 do_barrier(self.controller)
922 verify_no_errors(self.controller)