fixing the Q-in-Q tests.
diff --git a/olt.py b/olt.py
index ca6928f..5a91ea5 100644
--- a/olt.py
+++ b/olt.py
@@ -11,9 +11,9 @@
from oftest.testutils import *
-onu_port = test_param_get("onu_port", 1)
-onu_port2 = test_param_get("onu_port2", 2)
-olt_port = test_param_get("olt_port", 129)
+onu_port = test_param_get("onu_port", 130)
+onu_port2 = test_param_get("onu_port2", 131)
+olt_port = test_param_get("olt_port", 258)
def double_vlan_udp_packet(pktlen=100,
eth_dst='00:01:02:03:04:05',
@@ -30,7 +30,8 @@
udp_sport=1234,
udp_dport=80,
ip_ihl=None,
- ip_options=False
+ ip_options=False,
+ eth_type=0x8100
):
"""
Return a double vlan tagged dataplane UDP packet
@@ -59,7 +60,7 @@
# Note Dot1Q.id is really CFI
if (dl_vlan_enable):
- pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
+ 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)/ \
@@ -543,9 +544,9 @@
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])
+ '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
self.controller.message_send(group_add)
self.controller.message_send(flow_pointing_to_group)
@@ -553,7 +554,7 @@
verify_no_errors(self.controller)
group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id)
- self.controller.message_send(group_delete)
+ self.controller.message_send(group_delete)'''
self.controller.message_send(flow_delete)
do_barrier(self.controller)
@@ -597,14 +598,15 @@
verify_no_errors(self.controller)
# It takes some time for flows to propagate down to the data plane
- time.sleep(2)
+ time.sleep(10)
inPkt = simple_udp_packet(pktlen=104,dl_vlan_enable=True,
- vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
+ 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))
verify_packet(self, outPkt, onu_port)
+
# Now put 2 ONU ports in the group and test that the input packet is
# duplicated out both ports
group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2])
@@ -613,12 +615,12 @@
verify_no_errors(self.controller)
# It takes some time for flows to propagate down to the data plane
- time.sleep(2)
+ time.sleep(10)
self.dataplane.send(olt_port, str(inPkt))
- verify_packet(self, outPkt, onu_port)
verify_packet(self, outPkt, onu_port2)
-
+ verify_packet(self, outPkt, onu_port)
+ #verify_packets(self, outPkt, [onu_port,onu_port2])
# clean up the test
request = ofp.message.flow_delete( table_id=test_param_get("table", 0))
@@ -629,6 +631,74 @@
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" )
+ delete_all_flows(self.controller)
+ delete_all_groups(self.controller)
+
+ vlan_id = 201
+
+ # Create a group
+ 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)
+
+ # Create a flow rule matching olt port and vlan id
+ 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))
+
+ request = ofp.message.flow_add(
+ table_id=test_param_get("table", 0),
+ cookie=43,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(
+ 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)
+ verify_no_errors(self.controller)
+
+ # 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,
+ 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))
+ verify_packet(self, outPkt, onu_port)
+ #verify_packet(self, outPkt, onu_port2)
+
+ # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1
+ group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
+ self.controller.message_send(group_mod)
+ do_barrier(self.controller)
+ verify_no_errors(self.controller)
+
+ time.sleep(10)
+ self.dataplane.send(olt_port, str(inPkt))
+ verify_no_packet(self, outPkt, onu_port)
+ verify_packet(self, outPkt, onu_port2)
+
+ # Now remove all ports in the group and test that the input packet is no longer forwarded to any port
+ group_mod = createAllGroupMod(test_group_id, ports=[])
+ self.controller.message_send(group_mod)
+ do_barrier(self.controller)
+ verify_no_errors(self.controller)
+ time.sleep(10)
+ self.dataplane.send(olt_port, str(inPkt))
+ verify_packets(self, outPkt, [])
+
+
class TransparentVlanTest(base_tests.SimpleDataPlane):
def runTest(self):
@@ -702,7 +772,7 @@
# upstream flow rule
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_vid(value=ofp.OFPVID_PRESENT))
match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
# push inner vlan (c-vlan) for upstream
@@ -735,7 +805,7 @@
instructions=[
ofp.instruction.apply_actions(
actions=[
- ofp.action.push_vlan(ethertype=0x8100),
+ ofp.action.push_vlan(ethertype=0x88A8),
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)]),
@@ -767,7 +837,7 @@
do_barrier(self.controller)
verify_no_errors(self.controller)
- # strip inner vlan (c-vlan) 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))
@@ -780,7 +850,7 @@
instructions=[
ofp.instruction.apply_actions(
actions=[
- ofp.action.pop_vlan(),
+ ofp.action.pop_vlan(),
ofp.action.output(port=onu_port) ] )
],
buffer_id=ofp.OFP_NO_BUFFER,
@@ -791,25 +861,48 @@
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)
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)
+
+ 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))
self.dataplane.send(onu_port, str(untaggedPkt))
- verify_packet(self, doubleTaggedPkt, olt_port)
- # test downstream doubletagged packet got untagged at ONU
+ verify_packet(self, upstreamDoubleTaggedPkt, olt_port)
+
+ # 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
- self.dataplane.send(onu_port, str(doubleTaggedPkt))
- verify_packets(self, untaggedPkt, [])
- # test downstream untagged packet got dropped at ONU
- self.dataplane.send(olt_port, str(untaggedPkt))
- verify_packet(self, doubleTaggedPkt, [])
+ # 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
+ 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)
# clean up the test
delete_all_flows(self.controller)