cycling double vlan test
diff --git a/olt.py b/olt.py
index 27858b0..83aca8b 100644
--- a/olt.py
+++ b/olt.py
@@ -2,6 +2,7 @@
OFTests for functionality needed from the OLT.
'''
import logging
+from __builtin__ import xrange
from oftest import config
import oftest.base_tests as base_tests
import oftest.packet as scapy
@@ -16,24 +17,25 @@
onu_port2 = test_param_get("onu_port2", 130)
olt_port = test_param_get("olt_port", 258)
+
def double_vlan_udp_packet(pktlen=100,
- eth_dst='00:01:02:03:04:05',
- eth_src='00:06:07:08:09:0a',
- dl_vlan_enable=False,
- c_vlan_vid=0,
- c_vlan_pcp=0,
- s_vlan_vid=0,
- s_vlan_pcp=0,
- ip_src='192.168.0.1',
- ip_dst='192.168.0.2',
- ip_tos=0,
- ip_ttl=64,
- udp_sport=1234,
- udp_dport=80,
- ip_ihl=None,
- ip_options=False,
- eth_type=0x8100
- ):
+ eth_dst='00:01:02:03:04:05',
+ eth_src='00:06:07:08:09:0a',
+ dl_vlan_enable=False,
+ c_vlan_vid=0,
+ c_vlan_pcp=0,
+ s_vlan_vid=0,
+ s_vlan_pcp=0,
+ ip_src='192.168.0.1',
+ ip_dst='192.168.0.2',
+ ip_tos=0,
+ ip_ttl=64,
+ udp_sport=1234,
+ udp_dport=80,
+ ip_ihl=None,
+ ip_options=False,
+ eth_type=0x8100
+ ):
"""
Return a double vlan tagged dataplane UDP packet
Supports a few parameters:
@@ -61,74 +63,74 @@
# Note Dot1Q.id is really CFI
if (dl_vlan_enable):
- pkt = scapy.Ether(dst=eth_dst, src=eth_src, type=eth_type)/ \
- scapy.Dot1Q(prio=s_vlan_pcp, vlan=s_vlan_vid)/ \
- scapy.Dot1Q(prio=c_vlan_pcp, vlan=c_vlan_vid)/ \
- scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
- scapy.UDP(sport=udp_sport, dport=udp_dport)
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src, type=eth_type) / \
+ scapy.Dot1Q(prio=s_vlan_pcp, vlan=s_vlan_vid) / \
+ scapy.Dot1Q(prio=c_vlan_pcp, vlan=c_vlan_vid) / \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl) / \
+ scapy.UDP(sport=udp_sport, dport=udp_dport)
else:
if not ip_options:
- pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
- scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
- scapy.UDP(sport=udp_sport, dport=udp_dport)
-
- else:
- pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
- scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl, options=ip_options)/ \
- scapy.UDP(sport=udp_sport, dport=udp_dport)
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src) / \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl) / \
+ scapy.UDP(sport=udp_sport, dport=udp_dport)
- pkt = pkt/("D" * (pktlen - len(pkt)))
+ else:
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src) / \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl, options=ip_options) / \
+ scapy.UDP(sport=udp_sport, dport=udp_dport)
+
+ pkt = pkt / ("D" * (pktlen - len(pkt)))
return pkt
def testPacketIn(self, match, parsed_pkt):
-
delete_all_flows(self.controller)
pkt = str(parsed_pkt)
for of_port in config["port_map"]:
- m = copy.deepcopy(match)
+ m = copy.deepcopy(match)
m.oxm_list.append(ofp.oxm.in_port(of_port))
request = ofp.message.flow_add(
- table_id=test_param_get("table", 0),
- cookie=42,
- match=m,
- instructions=[
- ofp.instruction.apply_actions(
- actions=[
- ofp.action.output(
- port=ofp.OFPP_CONTROLLER,
- max_len=ofp.OFPCML_NO_BUFFER)])],
- buffer_id=ofp.OFP_NO_BUFFER,
- priority=1000)
+ table_id=test_param_get("table", 0),
+ cookie=42,
+ match=m,
+ instructions=[
+ ofp.instruction.apply_actions(
+ actions=[
+ ofp.action.output(
+ port=ofp.OFPP_CONTROLLER,
+ max_len=ofp.OFPCML_NO_BUFFER)])],
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=1000)
logging.info("Inserting flow sending matching packets to controller")
self.controller.message_send(request)
do_barrier(self.controller)
-
+
for of_port in config["port_map"]:
logging.info("PacketInExact test, port %d", of_port)
self.dataplane.send(of_port, pkt)
verify_packet_in(self, pkt, of_port, ofp.OFPR_ACTION)
verify_packets(self, pkt, [])
+
def buildIgmp(payload):
- ether = scapy.Ether(src="00:01:02:03:04:05")
- ip = scapy.IP(src="1.2.3.4")
- payload.igmpize(ip, ether)
- pkt = ether / ip / payload
- if len(pkt) < 60:
- pad_len = 60 - len(pkt)
- pad = scapy.PAD()
- pad.load = '\x00' * pad_len
- pkt = pkt / pad
- return pkt
+ ether = scapy.Ether(src="00:01:02:03:04:05")
+ ip = scapy.IP(src="1.2.3.4")
+ payload.igmpize(ip, ether)
+ pkt = ether / ip / payload
+ if len(pkt) < 60:
+ pad_len = 60 - len(pkt)
+ pad = scapy.PAD()
+ pad.load = '\x00' * pad_len
+ pkt = pkt / pad
+ return pkt
+
class EapolPacketIn(base_tests.SimpleDataPlane):
-
"""Verify packet-ins are sent for EAPOL packets """
-
+
def runTest(self):
logging.info("Running EAPOL Packet In test")
@@ -136,35 +138,35 @@
match.oxm_list.append(ofp.oxm.eth_type(0x888e))
# Use ethertype 0x888e and multicast destination MAC address
pkt = simple_eth_packet(pktlen=60, eth_dst='01:00:5E:7F:FF:FF', eth_type=0x888e)
-
+
testPacketIn(self, match, pkt)
+
class IGMPPacketIn(base_tests.SimpleDataPlane):
-
"""Verify packet-ins are sent for IGMP packets """
-
+
def runTest(self):
logging.info("Running IGMP Packet In test")
match = ofp.match()
match.oxm_list.append(ofp.oxm.eth_type(0x800))
match.oxm_list.append(ofp.oxm.ip_proto(2))
-
- pkt = scapy.Ether(dst='01:00:5E:7F:FF:FF', src='00:00:00:00:00:01')/ \
- scapy.IP(src='10.0.0.1', dst='10.0.0.2', ttl=60, tos=0, id=0, proto=2)
- pkt = pkt/("0" * (100 - len(pkt)))
-
+ pkt = scapy.Ether(dst='01:00:5E:7F:FF:FF', src='00:00:00:00:00:01') / \
+ scapy.IP(src='10.0.0.1', dst='10.0.0.2', ttl=60, tos=0, id=0, proto=2)
+
+ pkt = pkt / ("0" * (100 - len(pkt)))
+
testPacketIn(self, match, pkt)
+
class IGMPQueryPacketOut(base_tests.SimpleDataPlane):
-
"""Verify sending multicast membership queries down to onu_ports"""
-
+
def runTest(self):
logging.info("Running IGMP query packet out")
- igmp = scapy.IGMP(type = 0x11, gaddr = "224.0.0.1")
+ igmp = scapy.IGMP(type=0x11, gaddr="224.0.0.1")
pkt = buildIgmp(igmp)
msg = ofp.message.packet_out()
@@ -172,24 +174,24 @@
msg.buffer_id = 0xffffffff
msg.data = str(pkt)
msg.actions = [ofp.action.output(
- port=onu_port,
- max_len=ofp.OFPCML_NO_BUFFER)]
+ port=onu_port,
+ max_len=ofp.OFPCML_NO_BUFFER)]
time.sleep(1)
- self.controller.message_send(msg)
+ self.controller.message_send(msg)
verify_no_errors(self.controller)
verify_packet(self, pkt, onu_port)
+
class TestMeter(base_tests.SimpleDataPlane):
-
def runTest(self):
logging.info("Running Meter tests")
- dropMeterBand = ofp.meter_band.drop(rate = 640)
- meter_mod = ofp.message.meter_mod(xid = 1, command = ofp.OFPMC_ADD, meter_id = 1, meters = [ dropMeterBand ])
+ dropMeterBand = ofp.meter_band.drop(rate=640)
+ meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
self.controller.message_send(meter_mod)
-
+
time.sleep(1)
verify_no_errors(self.controller)
@@ -197,7 +199,7 @@
vlan_id = 201
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(onu_port))
- match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id ))
+ match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
request = ofp.message.flow_add(
table_id=test_param_get("table", 0),
@@ -207,15 +209,15 @@
ofp.instruction.apply_actions(
actions=[ofp.action.output(port=olt_port)]
),
- ofp.instruction.meter(meter_id = 1)
- ],
+ ofp.instruction.meter(meter_id=1)
+ ],
buffer_id=ofp.OFP_NO_BUFFER,
priority=1000)
self.controller.message_send(request)
time.sleep(1)
verify_no_errors(self.controller)
-
+
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(olt_port))
match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
@@ -228,8 +230,8 @@
ofp.instruction.apply_actions(
actions=[ofp.action.output(port=onu_port)]
),
- ofp.instruction.meter(meter_id = 1)
- ],
+ ofp.instruction.meter(meter_id=1)
+ ],
buffer_id=ofp.OFP_NO_BUFFER,
priority=1000)
@@ -238,59 +240,57 @@
verify_no_errors(self.controller)
do_barrier(self.controller)
time.sleep(5)
-
+
inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
# downstream
- #self.dataplane.send(olt_port, str(inPkt))
- #verify_packet(self, inPkt, onu_port)
+ # self.dataplane.send(olt_port, str(inPkt))
+ # verify_packet(self, inPkt, onu_port)
# upstream
- #for i in range(1,400):
- # self.dataplane.send(onu_port, str(inPkt))
- #verify_packet(self, inPkt, olt_port)
+ # for i in range(1,400):
+ # self.dataplane.send(onu_port, str(inPkt))
+ # verify_packet(self, inPkt, olt_port)
# clean up the test
- meter_mod = ofp.message.meter_mod(xid = 2, command = ofp.OFPMC_DELETE, meter_id = 1)
+ meter_mod = ofp.message.meter_mod(xid=2, command=ofp.OFPMC_DELETE, meter_id=1)
self.controller.message_send(meter_mod)
time.sleep(1)
delete_all_flows(self.controller)
verify_no_errors(self.controller)
-
-class TestDuplicateMeter(base_tests.SimpleDataPlane):
+class TestDuplicateMeter(base_tests.SimpleDataPlane):
def runTest(self):
logging.info("Running Duplicate Meter Test")
- dropMeterBand = ofp.meter_band.drop(rate = 500)
- meter_mod = ofp.message.meter_mod(xid = 1, command = ofp.OFPMC_ADD, meter_id = 1, meters = [ dropMeterBand ])
+ dropMeterBand = ofp.meter_band.drop(rate=500)
+ meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
self.controller.message_send(meter_mod)
self.controller.message_send(meter_mod)
time.sleep(1)
-
+
try:
verify_no_errors(self.controller)
except AssertionError as e:
if (not e.message == "unexpected error type=12 code=1"):
raise AssertionError("Incorrect error type: %s" % e.message)
-
-
+
+
class VlanTest(base_tests.SimpleDataPlane):
-
"""Verify the switch can push/pop a VLAN tag and forward out a port """
-
+
def runTest(self):
logging.info("Running push VLAN test")
-
+
vlan_id = 200
-
+
delete_all_flows(self.controller)
-
- #PUSH
+
+ # PUSH
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(onu_port))
match.oxm_list.append(ofp.oxm.vlan_vid_masked(value=ofp.OFPVID_PRESENT, value_mask=ofp.OFPVID_PRESENT))
- match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
-
+ match.oxm_list.append(ofp.oxm.vlan_pcp(value=0))
+
request = ofp.message.flow_add(
table_id=test_param_get("table", 0),
cookie=42,
@@ -307,8 +307,8 @@
logging.info("Inserting flow tagging upstream")
self.controller.message_send(request)
-
- #POP
+
+ # POP
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(olt_port))
match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
@@ -321,7 +321,7 @@
ofp.instruction.apply_actions(
actions=[
ofp.action.pop_vlan(),
- ofp.action.output(port=onu_port)])],
+ ofp.action.output(port=onu_port)])],
buffer_id=ofp.OFP_NO_BUFFER,
priority=1000)
@@ -330,19 +330,18 @@
do_barrier(self.controller)
time.sleep(5)
-
inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
- outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
+ outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
-
+
# Send untagged packet in the ONU port and expect tagged packet out the OLT port
self.dataplane.send(onu_port, str(inPkt))
verify_packet(self, outPkt, olt_port)
-
+
# Send untagged packet in the OLT port and expect no packets to come out
self.dataplane.send(olt_port, str(inPkt))
verify_packets(self, outPkt, [])
-
+
inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
@@ -355,37 +354,39 @@
self.dataplane.send(onu_port, str(inPkt))
verify_packets(self, outPkt, [])
+
def createAllGroupAdd(group_id, ports=[]):
buckets = []
-
+
for portNum in ports:
buckets.append(ofp.common.bucket(watch_port=ofp.OFPP_ANY, watch_group=ofp.OFPG_ANY,
actions=[ofp.action.pop_vlan(), ofp.action.output(port=portNum)]))
-
- group_add = ofp.message.group_add(group_type = ofp.OFPGT_ALL, group_id=group_id, buckets=buckets)
-
+
+ group_add = ofp.message.group_add(group_type=ofp.OFPGT_ALL, group_id=group_id, buckets=buckets)
+
return group_add
+
def createAllGroupMod(group_id, ports=[]):
buckets = []
-
+
for portNum in ports:
buckets.append(ofp.common.bucket(watch_port=ofp.OFPP_ANY, watch_group=ofp.OFPG_ANY,
actions=[ofp.action.output(port=portNum)]))
-
- group_mod = ofp.message.group_mod(command=ofp.OFPGC_MODIFY, group_type = ofp.OFPGT_ALL, group_id=group_id, buckets=buckets)
-
+
+ group_mod = ofp.message.group_mod(command=ofp.OFPGC_MODIFY, group_type=ofp.OFPGT_ALL, group_id=group_id,
+ buckets=buckets)
+
return group_mod
-
+
class TestGroupAdd(base_tests.SimpleDataPlane):
-
def runTest(self):
logging.info("Running Group tests")
delete_all_flows(self.controller)
delete_all_groups(self.controller)
- test_group_id = 1
+ test_group_id = 1
# output to two ONU
group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2])
@@ -395,7 +396,7 @@
verify_no_errors(self.controller)
# Remove the group and then readd it.
- group_delete = ofp.message.group_delete(group_id = test_group_id)
+ group_delete = ofp.message.group_delete(group_id=test_group_id)
self.controller.message_send(group_delete)
do_barrier(self.controller)
verify_no_errors(self.controller)
@@ -407,30 +408,30 @@
# clean up the test
- group_delete = ofp.message.group_delete(group_id = test_group_id)
+ group_delete = ofp.message.group_delete(group_id=test_group_id)
self.controller.message_send(group_delete)
-
+
do_barrier(self.controller)
verify_no_errors(self.controller)
-
+
+
class TestGroupMod(base_tests.SimpleDataPlane):
-
def runTest(self):
logging.info("Running Group tests")
delete_all_flows(self.controller)
delete_all_groups(self.controller)
- test_group_id = 1
+ test_group_id = 1
group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
self.controller.message_send(group_add)
do_barrier(self.controller)
verify_no_errors(self.controller)
-
+
# Modifying the group
group_mod = createAllGroupMod(test_group_id, [onu_port2])
-
+
self.controller.message_send(group_mod)
do_barrier(self.controller)
verify_no_errors(self.controller)
@@ -453,61 +454,61 @@
errorExperienced = 1
if (not (e.message == "unexpected error type=6 code=8")):
raise AssertionError("Incorrect error type: %s" % e.message)
- if not errorExperienced:
+ if not errorExperienced:
raise AssertionError("An error message is expected, but not shown.")
-
-
+
+
# clean up the test
- group_delete = ofp.message.group_delete(xid = 2, group_id = test_group_id)
+ group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
self.controller.message_send(group_delete)
-
+
do_barrier(self.controller)
verify_no_errors(self.controller)
+
class TestDuplicateGroup(base_tests.SimpleDataPlane):
-
def runTest(self):
logging.info("Running Group tests")
delete_all_flows(self.controller)
delete_all_groups(self.controller)
- test_group_id = 1
+ test_group_id = 1
group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
self.controller.message_send(group_add)
do_barrier(self.controller)
verify_no_errors(self.controller)
-
+
# Add the same group id
- duplicate_group_fail = 0
-
+ duplicate_group_fail = 0
+
self.controller.message_send(group_add)
do_barrier(self.controller)
try:
verify_no_errors(self.controller)
except AssertionError as e:
- duplicate_group_fail = 1
+ duplicate_group_fail = 1
if (not e.message == "unexpected error type=6 code=0"):
raise AssertionError("Incorrect error type: %s" % e.message)
if not duplicate_group_fail:
raise AssertionError("Adding duplicate groups didn't raise an error.")
-
+
# clean up the test
- group_delete = ofp.message.group_delete(xid = 2, group_id = test_group_id)
+ group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
self.controller.message_send(group_delete)
-
+
do_barrier(self.controller)
verify_no_errors(self.controller)
+
class TestGroupAndFlow(base_tests.SimpleDataPlane):
-
def runTest(self):
logging.info("Running Group tests")
delete_all_flows(self.controller)
delete_all_groups(self.controller)
# Create a group
- test_group_id = 1
+ test_group_id = 1
group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
self.controller.message_send(group_add)
@@ -525,13 +526,13 @@
match=match,
instructions=[
ofp.instruction.apply_actions(
- actions=[ ofp.action.group( group_id = test_group_id ) ] ) ],
- buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
+ actions=[ofp.action.group(group_id=test_group_id)])],
+ buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
self.controller.message_send(flow_pointing_to_group)
do_barrier(self.controller)
verify_no_errors(self.controller)
-
+
# After letting a flow rule point to the group, test we can do group_mod
group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
self.controller.message_send(group_mod)
@@ -539,16 +540,16 @@
verify_no_errors(self.controller)
# Test we can remove flows and then remove group
- flow_delete = ofp.message.flow_delete( table_id=test_param_get("table", 0))
+ flow_delete = ofp.message.flow_delete(table_id=test_param_get("table", 0))
self.controller.message_send(flow_delete)
do_barrier(self.controller)
verify_no_errors(self.controller)
- group_delete = ofp.message.group_delete(xid = 3, group_id = test_group_id)
+ group_delete = ofp.message.group_delete(xid=3, group_id=test_group_id)
self.controller.message_send(group_delete)
do_barrier(self.controller)
verify_no_errors(self.controller)
-
+
# Add the group and flow back, test it we can first remove group and then remove the flow.
'''group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
self.controller.message_send(group_add)
@@ -566,7 +567,6 @@
class TestGroupForwarding(base_tests.SimpleDataPlane):
-
def runTest(self):
logging.info("Running Group datapath forwarding tests")
delete_all_flows(self.controller)
@@ -575,7 +575,7 @@
vlan_id = 201
# Create a group
- test_group_id = 1
+ test_group_id = 1
group_add = createAllGroupAdd(test_group_id, [onu_port])
self.controller.message_send(group_add)
@@ -593,9 +593,9 @@
match=match,
instructions=[
ofp.instruction.apply_actions(
- actions=[ ofp.action.group( group_id = test_group_id ) ] ),
- ],
- buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
+ actions=[ofp.action.group(group_id=test_group_id)]),
+ ],
+ buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
self.controller.message_send(request)
do_barrier(self.controller)
@@ -603,8 +603,8 @@
# It takes some time for flows to propagate down to the data plane
time.sleep(10)
-
- inPkt = simple_udp_packet(pktlen=104,dl_vlan_enable=True,
+
+ inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
outPkt = inPkt
self.dataplane.send(olt_port, str(inPkt))
@@ -617,36 +617,35 @@
self.controller.message_send(group_mod)
do_barrier(self.controller)
verify_no_errors(self.controller)
-
+
# It takes some time for flows to propagate down to the data plane
time.sleep(10)
self.dataplane.send(olt_port, str(inPkt))
verify_packet(self, outPkt, onu_port2)
verify_packet(self, outPkt, onu_port)
- #verify_packets(self, outPkt, [onu_port,onu_port2])
+ # verify_packets(self, outPkt, [onu_port,onu_port2])
# clean up the test
- request = ofp.message.flow_delete( table_id=test_param_get("table", 0))
+ request = ofp.message.flow_delete(table_id=test_param_get("table", 0))
self.controller.message_send(request)
- group_delete = ofp.message.group_delete(xid = 2, group_id = test_group_id)
+ group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
self.controller.message_send(group_delete)
-
+
do_barrier(self.controller)
verify_no_errors(self.controller)
class TestGroupModForwarding(base_tests.SimpleDataPlane):
-
def runTest(self):
- logging.info("Running datapath forwarding tests for group mod" )
+ logging.info("Running datapath forwarding tests for group mod")
delete_all_flows(self.controller)
delete_all_groups(self.controller)
vlan_id = 201
# Create a group
- test_group_id = 1
+ test_group_id = 1
group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
self.controller.message_send(group_add)
@@ -664,9 +663,9 @@
match=match,
instructions=[
ofp.instruction.apply_actions(
- actions=[ ofp.action.group( group_id = test_group_id ) ] ),
- ],
- buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
+ actions=[ofp.action.group(group_id=test_group_id)]),
+ ],
+ buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
self.controller.message_send(request)
do_barrier(self.controller)
@@ -674,8 +673,8 @@
# It takes some time for flows to propagate down to the data plane
time.sleep(10)
-
- inPkt = simple_udp_packet(pktlen=104,dl_vlan_enable=True,
+
+ inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
outPkt = inPkt
self.dataplane.send(olt_port, str(inPkt))
@@ -704,7 +703,6 @@
class TransparentVlanTest(base_tests.SimpleDataPlane):
-
def runTest(self):
logging.info("Running transparent vlan tests")
delete_all_flows(self.controller)
@@ -712,7 +710,7 @@
vlan_id = 201
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(onu_port))
- match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id ))
+ match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
request = ofp.message.flow_add(
table_id=test_param_get("table", 0),
@@ -722,12 +720,12 @@
ofp.instruction.apply_actions(
actions=[
ofp.action.output(port=olt_port)]),
- ],
+ ],
buffer_id=ofp.OFP_NO_BUFFER,
priority=1000)
self.controller.message_send(request)
-
+
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(olt_port))
match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
@@ -740,7 +738,7 @@
ofp.instruction.apply_actions(
actions=[
ofp.action.output(port=onu_port)]),
- ],
+ ],
buffer_id=ofp.OFP_NO_BUFFER,
priority=1000)
@@ -750,7 +748,7 @@
# It takes some time for flows to propagate down to the data plane
time.sleep(2)
-
+
inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
# upstream
self.dataplane.send(onu_port, str(inPkt))
@@ -764,21 +762,21 @@
do_barrier(self.controller)
verify_no_errors(self.controller)
+
class DoubleVlanTest(base_tests.SimpleDataPlane):
-
def runTest(self):
logging.info("Running double vlan tests")
delete_all_flows(self.controller)
c_vlan_id = 100
- s_vlan_id = 102
- # upstream flow rule
+ s_vlan_id = 102
+ # upstream flow rule
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(onu_port))
match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_PRESENT))
- match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
+ match.oxm_list.append(ofp.oxm.vlan_pcp(value=0))
- # push inner vlan (c-vlan) for upstream
+ # push inner vlan (c-vlan) for upstream
request = ofp.message.flow_add(
table_id=test_param_get("table", 0),
cookie=42,
@@ -786,20 +784,20 @@
instructions=[
ofp.instruction.apply_actions(
actions=[
- ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id)) ] ),
- ofp.instruction.goto_table(1) ],
+ ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))]),
+ ofp.instruction.goto_table(1)],
buffer_id=ofp.OFP_NO_BUFFER,
priority=1000)
self.controller.message_send(request)
do_barrier(self.controller)
verify_no_errors(self.controller)
-
- # push outer vlan (s-vlan) for upstream
+
+ # push outer vlan (s-vlan) for upstream
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(onu_port))
match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
- match.oxm_list.append(ofp.oxm.vlan_pcp( 0 ))
+ match.oxm_list.append(ofp.oxm.vlan_pcp(0))
request = ofp.message.flow_add(
table_id=test_param_get("table", 1),
@@ -812,7 +810,7 @@
ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id)),
ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
ofp.action.output(port=olt_port)]),
- ],
+ ],
buffer_id=ofp.OFP_NO_BUFFER,
priority=1000)
@@ -820,31 +818,31 @@
do_barrier(self.controller)
verify_no_errors(self.controller)
- # strip outer vlan (s-vlan) for downstream
+ # strip outer vlan (s-vlan) for downstream
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(olt_port))
match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id))
- match.oxm_list.append(ofp.oxm.vlan_pcp( 0 ))
+ match.oxm_list.append(ofp.oxm.vlan_pcp(0))
request = ofp.message.flow_add(
table_id=test_param_get("table", 0),
cookie=44,
match=match,
instructions=[
ofp.instruction.apply_actions(
- actions=[ ofp.action.pop_vlan() ] ),
- ofp.instruction.goto_table(1) ],
+ actions=[ofp.action.pop_vlan()]),
+ ofp.instruction.goto_table(1)],
buffer_id=ofp.OFP_NO_BUFFER,
priority=1000)
self.controller.message_send(request)
do_barrier(self.controller)
verify_no_errors(self.controller)
-
- # rewrite inner vlan (c-vlan) to default (0) for downstream
+
+ # rewrite inner vlan (c-vlan) to default (0) for downstream
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(olt_port))
match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
- match.oxm_list.append(ofp.oxm.vlan_pcp( 0 ))
+ match.oxm_list.append(ofp.oxm.vlan_pcp(0))
request = ofp.message.flow_add(
table_id=test_param_get("table", 1),
@@ -853,9 +851,9 @@
instructions=[
ofp.instruction.apply_actions(
actions=[
- ofp.action.pop_vlan(),
- ofp.action.output(port=onu_port) ] )
- ],
+ ofp.action.pop_vlan(),
+ ofp.action.output(port=onu_port)])
+ ],
buffer_id=ofp.OFP_NO_BUFFER,
priority=1000)
@@ -863,51 +861,191 @@
do_barrier(self.controller)
verify_no_errors(self.controller)
# It takes some time for flows to propagate down to the data plane
+
time.sleep(10)
- incorrectTagPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=100, vlan_pcp=0)
+ incorrectTagPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=100, vlan_pcp=0)
untaggedPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
-
- '''
+ '''
FIXME: hack because OLT does _not_ tag packets correctly
it ignores the eth_type in the push_vlan action
and always slaps on 0x8100 even though the
down stream flow must be 0x88a8.
- '''
- doubleTaggedPkt = double_vlan_udp_packet(pktlen=104, dl_vlan_enable=True,
- c_vlan_vid=c_vlan_id,
- s_vlan_vid=s_vlan_id,
- c_vlan_pcp=0, s_vlan_pcp=0, eth_type=0x88a8)
+ '''
+ doubleTaggedPkt = double_vlan_udp_packet(pktlen=104, dl_vlan_enable=True,
+ c_vlan_vid=c_vlan_id,
+ s_vlan_vid=s_vlan_id,
+ c_vlan_pcp=0, s_vlan_pcp=0, eth_type=0x88a8)
- upstreamDoubleTaggedPkt = double_vlan_udp_packet(pktlen=104, dl_vlan_enable=True,
- c_vlan_vid=c_vlan_id,
- s_vlan_vid=s_vlan_id,
- c_vlan_pcp=0, s_vlan_pcp=0)
+ upstreamDoubleTaggedPkt = double_vlan_udp_packet(pktlen=104, dl_vlan_enable=True,
+ c_vlan_vid=c_vlan_id,
+ s_vlan_vid=s_vlan_id,
+ c_vlan_pcp=0, s_vlan_pcp=0)
# test upstream untagged packet got double tag at OLT
- logging.info(str(doubleTaggedPkt))
+ logging.info(str(doubleTaggedPkt))
+
self.dataplane.send(onu_port, str(untaggedPkt))
verify_packet(self, upstreamDoubleTaggedPkt, olt_port)
-
- # test downstream doubletagged packet got untagged at ONU
+
+ # test downstream doubletagged packet got untagged at ONU
self.dataplane.send(olt_port, str(doubleTaggedPkt))
verify_packet(self, untaggedPkt, onu_port)
-
- # test upstream doubletagged packet got dropped
+
+ # test upstream doubletagged packet got dropped
self.dataplane.send(onu_port, str(doubleTaggedPkt))
verify_no_packet(self, upstreamDoubleTaggedPkt, olt_port)
-
- # test downstream untagged packet got dropped at ONU
+
+ # test downstream untagged packet got dropped at ONU
self.dataplane.send(olt_port, str(untaggedPkt))
verify_no_packet(self, untaggedPkt, onu_port)
-
- # test upstream icorrectly tagged packet; should get dropped
- self.dataplane.send(onu_port, str(incorrectTagPkt))
- verify_no_packet(self, upstreamDoubleTaggedPkt, olt_port)
-
- time.sleep(2)
+
+ # test upstream icorrectly tagged packet; should get dropped
+ self.dataplane.send(onu_port, str(incorrectTagPkt))
+
+ verify_no_packet(self, upstreamDoubleTaggedPkt, olt_port)
+
+ time.sleep(2)
# clean up the test
delete_all_flows(self.controller)
do_barrier(self.controller)
verify_no_errors(self.controller)
+
+
+class TestCyclingDoubleVlan(base_tests.SimpleDataPlane):
+ """Cycle through vlans and test traffic flow"""
+
+ def runTest(self):
+ logging.info("Running cycling vlan test")
+
+ self.vlan_pairs = []
+
+ for stag in xrange(1, 4000, 100):
+ for ctag in xrange(1, 4000, 100):
+ self.installDoubleTaggingRule(stag, ctag)
+ self.vlan_pairs.append((stag, ctag))
+ time.sleep(1)
+ self.testPacketFlow()
+
+ def testPacketFlow(self):
+ for (s_vlan_id, c_vlan_id) in self.vlan_pairs:
+ incorrectTagPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=100, vlan_pcp=0)
+ untaggedPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
+
+ upstreamDoubleTaggedPkt = double_vlan_udp_packet(pktlen=104, dl_vlan_enable=True,
+ c_vlan_vid=c_vlan_id,
+ s_vlan_vid=s_vlan_id,
+ c_vlan_pcp=0, s_vlan_pcp=0)
+
+ logging.info("Testing s-tag %d, c-tag %d" % (s_vlan_id, c_vlan_id))
+
+ self.dataplane.send(onu_port, str(untaggedPkt))
+ verify_packet(self, upstreamDoubleTaggedPkt, olt_port)
+
+ # test downstream doubletagged packet got untagged at ONU
+ self.dataplane.send(olt_port, str(upstreamDoubleTaggedPkt))
+ verify_packet(self, untaggedPkt, onu_port)
+
+ # test upstream doubletagged packet got dropped
+ self.dataplane.send(onu_port, str(upstreamDoubleTaggedPkt))
+ verify_no_packet(self, upstreamDoubleTaggedPkt, olt_port)
+
+ # test downstream untagged packet got dropped at ONU
+ self.dataplane.send(olt_port, str(untaggedPkt))
+ verify_no_packet(self, untaggedPkt, onu_port)
+
+ # test upstream icorrectly tagged packet; should get dropped
+ self.dataplane.send(onu_port, str(incorrectTagPkt))
+ verify_no_packet(self, upstreamDoubleTaggedPkt, olt_port)
+
+ def installDoubleTaggingRule(self, s_vlan_id, c_vlan_id):
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.in_port(onu_port))
+ match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_PRESENT))
+ match.oxm_list.append(ofp.oxm.vlan_pcp(value=0))
+
+ # push inner vlan (c-vlan) for upstream
+ request = ofp.message.flow_add(
+ table_id=test_param_get("table", 0),
+ cookie=42,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(
+ actions=[
+ ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))]),
+ ofp.instruction.goto_table(1)],
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=1000)
+
+ self.controller.message_send(request)
+ do_barrier(self.controller)
+ verify_no_errors(self.controller)
+
+ # push outer vlan (s-vlan) for upstream
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.in_port(onu_port))
+ match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
+ match.oxm_list.append(ofp.oxm.vlan_pcp(0))
+
+ request = ofp.message.flow_add(
+ table_id=test_param_get("table", 1),
+ cookie=43,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(
+ actions=[
+ ofp.action.push_vlan(ethertype=0x8100),
+ ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id)),
+ ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
+ ofp.action.output(port=olt_port)]),
+ ],
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=1000)
+
+ self.controller.message_send(request)
+ do_barrier(self.controller)
+ verify_no_errors(self.controller)
+
+ # strip outer vlan (s-vlan) for downstream
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.in_port(olt_port))
+ match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id))
+ match.oxm_list.append(ofp.oxm.vlan_pcp(0))
+ request = ofp.message.flow_add(
+ table_id=test_param_get("table", 0),
+ cookie=44,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(
+ actions=[ofp.action.pop_vlan()]),
+ ofp.instruction.goto_table(1)],
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=1000)
+
+ self.controller.message_send(request)
+ do_barrier(self.controller)
+ verify_no_errors(self.controller)
+
+ # rewrite inner vlan (c-vlan) to default (0) for downstream
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.in_port(olt_port))
+ match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
+ match.oxm_list.append(ofp.oxm.vlan_pcp(0))
+
+ request = ofp.message.flow_add(
+ table_id=test_param_get("table", 1),
+ cookie=45,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(
+ actions=[
+ ofp.action.pop_vlan(),
+ ofp.action.output(port=onu_port)])
+ ],
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=1000)
+
+ self.controller.message_send(request)
+ do_barrier(self.controller)
+ verify_no_errors(self.controller)