Refactored code into different files
diff --git a/ofdpa/basic.py b/ofdpa/basic.py
deleted file mode 100644
index b2392a7..0000000
--- a/ofdpa/basic.py
+++ /dev/null
@@ -1,608 +0,0 @@
-# Distributed under the OpenFlow Software License (see LICENSE)
-# Copyright (c) 2010 The Board of Trustees of The Leland Stanford Junior University
-# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
-# Copyright (c) 2012, 2013 CPqD
-# Copyright (c) 2012, 2013 Ericsson
-"""
-Basic test cases
-
-Test cases in other modules depend on this functionality.
-"""
-
-import logging
-
-from oftest import config
-import oftest.base_tests as base_tests
-import ofp
-import ofdpa_utils
-
-from oftest.testutils import *
-
-@group('smoke')
-class Echo(base_tests.SimpleProtocol):
- """
- Test echo response with no data
- """
- def runTest(self):
- request = ofp.message.echo_request()
- response, pkt = self.controller.transact(request)
- self.assertTrue(response is not None,
- "Did not get echo reply")
- self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,
- 'response is not echo_reply')
- self.assertEqual(request.xid, response.xid,
- 'response xid != request xid')
- self.assertEqual(len(response.data), 0, 'response data non-empty')
-
-class EchoWithData(base_tests.SimpleProtocol):
- """
- Test echo response with short string data
- """
- def runTest(self):
- data = 'OpenFlow Will Rule The World'
- request = ofp.message.echo_request(data=data)
- response, _ = self.controller.transact(request)
- self.assertTrue(response is not None,
- "Did not get echo reply")
- self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,
- 'response is not echo_reply')
- self.assertEqual(request.xid, response.xid,
- 'response xid != request xid')
- self.assertEqual(request.data, response.data,
- 'response data != request data')
-
-class FeaturesRequest(base_tests.SimpleProtocol):
- """
- Test features_request to make sure we get a response
-
- Does NOT test the contents; just that we get a response
- """
- def runTest(self):
- request = ofp.message.features_request()
- response,_ = self.controller.transact(request)
- self.assertTrue(response is not None,
- 'Did not get features reply')
-
-class DefaultDrop(base_tests.SimpleDataPlane):
- """
- Check that an empty flowtable results in drops
- """
- def runTest(self):
- in_port, = openflow_ports(1)
- delete_all_flows(self.controller)
-
- pkt = str(simple_tcp_packet())
- self.dataplane.send(in_port, pkt)
- verify_no_packet_in(self, pkt, None)
- verify_packets(self, pkt, [])
-
-@disabled #FIXME ofdpa
-class OutputExact(base_tests.SimpleDataPlane):
- """
- Test output function for an exact-match flow
-
- For each port A, adds a flow directing matching packets to that port.
- Then, for all other ports B != A, verifies that sending a matching packet
- to B results in an output to A.
- """
- def runTest(self):
- ports = sorted(config["port_map"].keys())
-
- delete_all_flows(self.controller)
-
- parsed_pkt = simple_tcp_packet()
- pkt = str(parsed_pkt)
- match = packet_to_flow_match(self, parsed_pkt)
-
- for out_port in ports:
- request = ofp.message.flow_add(
- table_id=test_param_get("table", 0),
- cookie=42,
- match=match,
- instructions=[
- ofp.instruction.apply_actions(
- actions=[
- ofp.action.output(
- port=out_port,
- max_len=ofp.OFPCML_NO_BUFFER)])],
- buffer_id=ofp.OFP_NO_BUFFER,
- priority=1000)
-
- logging.info("Inserting flow sending matching packets to port %d", out_port)
- self.controller.message_send(request)
- do_barrier(self.controller)
-
- for in_port in ports:
- if in_port == out_port:
- continue
- logging.info("OutputExact test, ports %d to %d", in_port, out_port)
- self.dataplane.send(in_port, pkt)
- verify_packets(self, pkt, [out_port])
-
-@disabled #FIXME ofdpa
-class OutputWildcard(base_tests.SimpleDataPlane):
- """
- Test output function for a match-all (but not table-miss) flow
-
- For each port A, adds a flow directing all packets to that port.
- Then, for all other ports B != A, verifies that sending a packet
- to B results in an output to A.
- """
- def runTest(self):
- ports = sorted(config["port_map"].keys())
-
- delete_all_flows(self.controller)
-
- pkt = str(simple_tcp_packet())
-
- for out_port in ports:
- request = ofp.message.flow_add(
- table_id=test_param_get("table", 0),
- cookie=42,
- instructions=[
- ofp.instruction.apply_actions(
- actions=[
- ofp.action.output(
- port=out_port,
- max_len=ofp.OFPCML_NO_BUFFER)])],
- buffer_id=ofp.OFP_NO_BUFFER,
- priority=1000)
-
- logging.info("Inserting flow sending all packets to port %d", out_port)
- self.controller.message_send(request)
- do_barrier(self.controller)
-
- for in_port in ports:
- if in_port == out_port:
- continue
- logging.info("OutputWildcard test, ports %d to %d", in_port, out_port)
- self.dataplane.send(in_port, pkt)
- verify_packets(self, pkt, [out_port])
-
-@disabled #FIXME ofdpa
-class PacketInExact(base_tests.SimpleDataPlane):
- """
- Test packet in function for an exact-match flow
-
- Send a packet to each dataplane port and verify that a packet
- in message is received from the controller for each
- """
- def runTest(self):
- delete_all_flows(self.controller)
-
- # required for OF-DPA to not drop packets
- ofdpa_utils.installDefaultVlan(self.controller)
-
- parsed_pkt = simple_tcp_packet()
- pkt = str(parsed_pkt)
-
- # NOTE: interally the switch adds a VLAN so the match needs to be with an explicit VLAN
- parsed_vlan_pkt = simple_tcp_packet(dl_vlan_enable=True,
- vlan_vid=ofdpa_utils.DEFAULT_VLAN,
- vlan_pcp=0,
- pktlen=104) # 4 less than we started with, because the way simple_tcp calc's length
- match = packet_to_flow_match(self, parsed_vlan_pkt)
- vlan_pkt = str(parsed_vlan_pkt)
-
- request = ofp.message.flow_add(
- table_id=ofdpa_utils.ACL_TABLE.table_id,
- cookie=42,
- match=match,
- 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"].keys():
- logging.info("PacketInExact test, port %d", of_port)
- self.dataplane.send(of_port, pkt)
- verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
- verify_packets(self, pkt, [])
-
-@disabled #FIXME ofdpa
-class PacketInWildcard(base_tests.SimpleDataPlane):
- # NOTE: interally the switch adds a VLAN so the match needs to be with an explicit VLAN
- """
- Test packet in function for a match-all flow
-
- Send a packet to each dataplane port and verify that a packet
- in message is received from the controller for each
- """
- def runTest(self):
- delete_all_flows(self.controller)
-
- # required for OF-DPA to not drop packets
- ofdpa_utils.installDefaultVlan(self.controller)
-
- pkt = str(simple_tcp_packet())
-
- # NOTE: interally the switch adds a VLAN so the match needs to be with an explicit VLAN
- parsed_vlan_pkt = simple_tcp_packet(dl_vlan_enable=True,
- vlan_vid=ofdpa_utils.DEFAULT_VLAN,
- vlan_pcp=0,
- pktlen=104) # 4 less than we started with, because the way simple_tcp calc's length
- vlan_pkt = str(parsed_vlan_pkt)
-
-
- request = ofp.message.flow_add(
- table_id=ofdpa_utils.ACL_TABLE.table_id,
- cookie=42,
- 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 all packets to controller")
- self.controller.message_send(request)
- do_barrier(self.controller)
-
- for of_port in config["port_map"].keys():
- logging.info("PacketInWildcard test, port %d", of_port)
- self.dataplane.send(of_port, pkt)
- verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
- verify_packets(self, pkt, [])
-
-@disabled #FIXME ofdpa
-class PacketInMiss(base_tests.SimpleDataPlane):
- """
- Test packet in function for a table-miss flow
-
- Send a packet to each dataplane port and verify that a packet
- in message is received from the controller for each
- """
- def runTest(self):
- delete_all_flows(self.controller)
-
- # required for OF-DPA to not drop packets
- ofdpa_utils.installDefaultVlan(self.controller)
-
- parsed_pkt = simple_tcp_packet()
- pkt = str(parsed_pkt)
-
- # NOTE: interally the switch adds a VLAN so the match needs to be with an explicit VLAN
- parsed_vlan_pkt = simple_tcp_packet(dl_vlan_enable=True,
- vlan_vid=ofdpa_utils.DEFAULT_VLAN,
- vlan_pcp=0,
- pktlen=104) # 4 less than we started with, because the way simple_tcp calc's length
- vlan_pkt = str(parsed_vlan_pkt)
-
- request = ofp.message.flow_add(
- table_id=ofdpa_utils.ACL_TABLE.table_id,
- cookie=42,
- 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=0)
-
- logging.info("Inserting table-miss flow sending all packets to controller")
- self.controller.message_send(request)
- do_barrier(self.controller)
-
- for of_port in config["port_map"].keys():
- logging.info("PacketInMiss test, port %d", of_port)
- self.dataplane.send(of_port, pkt)
- verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH)
- verify_packets(self, pkt, [])
-
-class PacketOut(base_tests.SimpleDataPlane):
- """
- Test packet out function
-
- Send packet out message to controller for each dataplane port and
- verify the packet appears on the appropriate dataplane port
- """
- def runTest(self):
- pkt = str(simple_tcp_packet())
-
- for of_port in config["port_map"].keys():
- msg = ofp.message.packet_out(
- in_port=ofp.OFPP_CONTROLLER,
- actions=[ofp.action.output(port=of_port)],
- buffer_id=ofp.OFP_NO_BUFFER,
- data=pkt)
-
- logging.info("PacketOut test, port %d", of_port)
- self.controller.message_send(msg)
- verify_packets(self, pkt, [of_port])
-
-class FlowRemoveAll(base_tests.SimpleProtocol):
- """
- Remove all flows; required for almost all tests
-
- Add a bunch of flows, remove them, and then make sure there are no flows left
- This is an intentionally naive test to see if the baseline functionality works
- and should be a precondition to any more complicated deletion test (e.g.,
- delete_strict vs. delete)
- """
- def runTest(self):
- for i in range(1,5):
- logging.debug("Adding flow %d", i)
- request = ofp.message.flow_add(
- buffer_id=ofp.OFP_NO_BUFFER,
- priority=i*1000)
- self.controller.message_send(request)
- do_barrier(self.controller)
-
- delete_all_flows(self.controller)
-
- logging.info("Sending flow stats request")
- stats = get_flow_stats(self, ofp.match())
- self.assertEqual(len(stats), 0, "Expected empty flow stats reply")
-
-
-## Multipart messages
-
-class DescStats(base_tests.SimpleProtocol):
- """
- Switch description multipart transaction
-
- Only verifies we get a single reply.
- """
- def runTest(self):
- request = ofp.message.desc_stats_request()
- logging.info("Sending desc stats request")
- response, _ = self.controller.transact(request)
- self.assertTrue(response != None, "No response to desc stats request")
- logging.info(response.show())
- self.assertEquals(response.flags, 0, "Unexpected bit set in desc stats reply flags")
-
-class FlowStats(base_tests.SimpleProtocol):
- """
- Flow stats multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- logging.info("Sending flow stats request")
- stats = get_flow_stats(self, ofp.match())
- logging.info("Received %d flow stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-class AggregateStats(base_tests.SimpleProtocol):
- """
- Aggregate flow stats multipart transaction
-
- Only verifies we get a single reply.
- """
- def runTest(self):
- request = ofp.message.aggregate_stats_request(
- table_id=ofp.OFPTT_ALL,
- out_port=ofp.OFPP_ANY,
- out_group=ofp.OFPG_ANY,
- cookie=0,
- cookie_mask=0)
- logging.info("Sending aggregate flow stats request")
- response, _ = self.controller.transact(request)
- self.assertTrue(response != None, "No response to aggregate stats request")
- logging.info(response.show())
- self.assertEquals(response.flags, 0, "Unexpected bit set in aggregate stats reply flags")
-
-class TableStats(base_tests.SimpleProtocol):
- """
- Table stats multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- logging.info("Sending table stats request")
- stats = get_stats(self, ofp.message.table_stats_request())
- logging.info("Received %d table stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-class PortStats(base_tests.SimpleProtocol):
- """
- Port stats multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- request = ofp.message.port_stats_request(port_no=ofp.OFPP_ANY)
- logging.info("Sending port stats request")
- stats = get_stats(self, request)
- logging.info("Received %d port stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-class QueueStats(base_tests.SimpleProtocol):
- """
- Queue stats multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- request = ofp.message.queue_stats_request(port_no=ofp.OFPP_ANY,
- queue_id=ofp.OFPQ_ALL)
- logging.info("Sending queue stats request")
- stats = get_stats(self, request)
- logging.info("Received %d queue stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-class GroupStats(base_tests.SimpleProtocol):
- """
- Group stats multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- request = ofp.message.group_stats_request(group_id=ofp.OFPG_ALL)
- logging.info("Sending group stats request")
- stats = get_stats(self, request)
- logging.info("Received %d group stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-class GroupDescStats(base_tests.SimpleProtocol):
- """
- Group description multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- request = ofp.message.group_desc_stats_request()
- logging.info("Sending group desc stats request")
- stats = get_stats(self, request)
- logging.info("Received %d group desc stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-@disabled #FIXME ofdpa
-class GroupFeaturesStats(base_tests.SimpleProtocol):
- """
- Group features multipart transaction
-
- Only verifies we get a single reply.
- """
- def runTest(self):
- request = ofp.message.group_features_stats_request()
- logging.info("Sending group features stats request")
- response, _ = self.controller.transact(request)
- self.assertTrue(response != None, "No response to group features stats request")
- logging.info(response.show())
- self.assertEquals(response.flags, 0, "Unexpected bit set in group features stats reply flags")
-
-@disabled #FIXME ofdpa
-class MeterStats(base_tests.SimpleProtocol):
- """
- Meter stats multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- request = ofp.message.meter_stats_request(meter_id=ofp.OFPM_ALL)
- logging.info("Sending meter stats request")
- stats = get_stats(self, request)
- logging.info("Received %d meter stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-@disabled #FIXME ofdpa
-class MeterConfigStats(base_tests.SimpleProtocol):
- """
- Meter config multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- request = ofp.message.meter_config_stats_request(meter_id=ofp.OFPM_ALL)
- logging.info("Sending meter config stats request")
- stats = get_stats(self, request)
- logging.info("Received %d meter config stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-@disabled #FIXME ofdpa
-class MeterFeaturesStats(base_tests.SimpleProtocol):
- """
- Meter features multipart transaction
-
- Only verifies we get a single reply.
- """
- def runTest(self):
- request = ofp.message.meter_features_stats_request()
- logging.info("Sending meter features stats request")
- response, _ = self.controller.transact(request)
- self.assertTrue(response != None, "No response to meter features stats request")
- logging.info(response.show())
- self.assertEquals(response.flags, 0, "Unexpected bit set in meter features stats reply flags")
-
-@disabled # pyloxi does not yet support table features
-class TableFeaturesStats(base_tests.SimpleProtocol):
- """
- Table features multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- logging.info("Sending table features stats request")
- stats = get_stats(self, ofp.message.table_features_stats_request())
- logging.info("Received %d table features stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-class PortDescStats(base_tests.SimpleProtocol):
- """
- Port description multipart transaction
-
- Only verifies we get a reply.
- """
- def runTest(self):
- logging.info("Sending port desc stats request")
- stats = get_stats(self, ofp.message.port_desc_stats_request())
- logging.info("Received %d port desc stats entries", len(stats))
- for entry in stats:
- logging.info(entry.show())
-
-class PortConfigMod(base_tests.SimpleProtocol):
- """
- Modify a bit in port config and verify changed
-
- Get the switch configuration, modify the port configuration
- and write it back; get the config again and verify changed.
- Then set it back to the way it was.
- """
-
- def runTest(self):
- logging.info("Running " + str(self))
- for of_port, _ in config["port_map"].items(): # Grab first port
- break
-
- (_, config1, _) = \
- port_config_get(self.controller, of_port)
- self.assertTrue(config is not None, "Did not get port config")
-
- logging.debug("OFPPC_NO_PACKET_IN bit port " + str(of_port) + " is now " +
- str(config1 & ofp.OFPPC_NO_PACKET_IN))
-
- rv = port_config_set(self.controller, of_port,
- config1 ^ ofp.OFPPC_NO_PACKET_IN,
- ofp.OFPPC_NO_PACKET_IN)
- self.assertTrue(rv != -1, "Error sending port mod")
-
- # Verify change took place with same feature request
- (_, config2, _) = port_config_get(self.controller, of_port)
- self.assertTrue(config2 is not None, "Did not get port config2")
- logging.debug("OFPPC_NO_PACKET_IN bit port " + str(of_port) + " is now " +
- str(config2 & ofp.OFPPC_NO_PACKET_IN))
- self.assertTrue(config2 & ofp.OFPPC_NO_PACKET_IN !=
- config1 & ofp.OFPPC_NO_PACKET_IN,
- "Bit change did not take")
- # Set it back
- rv = port_config_set(self.controller, of_port, config1,
- ofp.OFPPC_NO_PACKET_IN)
- self.assertTrue(rv != -1, "Error sending port mod")
-
-@disabled #FIXME ofdpa
-class AsyncConfigGet(base_tests.SimpleProtocol):
- """
- Verify initial async config
-
- Other tests rely on connections starting with these values.
- """
-
- def runTest(self):
- logging.info("Sending get async config request")
- response, _ = self.controller.transact(ofp.message.async_get_request())
- self.assertTrue(response != None, "No response to get async config request")
- logging.info(response.show())
- self.assertEquals(response.packet_in_mask_equal_master & 0x07, 0x07)
- self.assertEquals(response.port_status_mask_equal_master & 0x07, 0x07)
- self.assertEquals(response.flow_removed_mask_equal_master & 0x0f, 0x0f)
diff --git a/ofdpa/bugs.py b/ofdpa/bugs.py
new file mode 100644
index 0000000..02dff65
--- /dev/null
+++ b/ofdpa/bugs.py
@@ -0,0 +1,139 @@
+"""
+The following tests are being done here
+1) PacketInSrcMacMiss
+2) VlanSupport
+3) L2FloodQinQ
+4) L2FloodTagged
+5) L2Flood Tagged Unknown Src
+6) L2 Unicast Tagged
+7) MTU 1500
+8) MTU 4100
+9) MTU 4500
+10) L3UnicastTagged
+11) L3VPNMPLS
+12) MPLS Termination
+"""
+
+from oftest import config
+import logging
+import oftest.base_tests as base_tests
+import ofp
+from oftest.testutils import *
+from accton_util import *
+
+class Mtu4500(base_tests.SimpleDataPlane):
+
+ def runTest(self):
+ ports = sorted(config["port_map"].keys())
+
+ delete_all_flows(self.controller)
+ delete_all_groups(self.controller)
+
+ for port in ports:
+ add_one_l2_interface_group(self.controller, port, 1, True, False)
+ add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
+ group_id = encode_l2_interface_group_id(1, port)
+ add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
+ do_barrier(self.controller)
+
+ for out_port in ports:
+ # change dest based on port number
+ mac_dst= '00:12:34:56:78:%02X' % out_port
+ for in_port in ports:
+ if in_port == out_port:
+ continue
+ # change source based on port number to avoid packet-ins from learning
+ mac_src= '00:12:34:56:78:%02X' % in_port
+ parsed_pkt = simple_tcp_packet(pktlen=4500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
+ pkt = str(parsed_pkt)
+ self.dataplane.send(in_port, pkt)
+
+ for ofport in ports:
+ if ofport in [out_port]:
+ verify_packet(self, pkt, ofport)
+ else:
+ verify_no_packet(self, pkt, ofport)
+
+ verify_no_other_packets(self)
+
+class L3McastToVPN(base_tests.SimpleDataPlane):
+ """
+ Mcast routing
+ """
+ def runTest(self):
+ """
+ port1 (vlan 1)-> port 2 (vlan 2)
+ """
+ #delete_all_flows(self.controller)
+ #delete_all_groups(self.controller)
+
+ if len(config["port_map"]) <3:
+ logging.info("Port count less than 2, can't run this case")
+ return
+
+ vlan_id =1
+ port2_out_vlan=2
+ port3_out_vlan=3
+ in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
+ intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
+ intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
+ dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
+ dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
+ port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
+ port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
+ src_ip=0xc0a80101
+ src_ip_str="192.168.1.1"
+ dst_ip=0xe0010101
+ dst_ip_str="224.1.1.1"
+
+ port1=config["port_map"].keys()[0]
+ port2=config["port_map"].keys()[1]
+ port3=config["port_map"].keys()[2]
+
+ #add l2 interface group
+ for port in config["port_map"].keys():
+ add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
+ #add vlan flow table
+ add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
+ vlan_id +=1
+
+ #add termination flow
+ add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
+
+ #add MPLS interface group
+ l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2)
+ mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2)
+ l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
+ mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
+ #add L3VPN groups
+ mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
+ index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True)
+ mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
+ index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True)
+
+
+
+ mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [0x92020022 , 0x92010023])
+ add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
+
+ parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
+ eth_dst=dst_mac_str,
+ eth_src=port1_mac_str,
+ ip_ttl=64,
+ ip_src=src_ip_str,
+ ip_dst=dst_ip_str)
+ pkt=str(parsed_pkt)
+ self.dataplane.send(port1, pkt)
+ label = (in_vlan, 0, 1, 63)
+ parsed_pkt = mpls_packet(pktlen=100,
+ eth_dst=dst_mac_str,
+ eth_src=intf_src_mac_str,
+ ip_ttl=63,
+ ip_src=src_ip_str, label= [label],
+ ip_dst=dst_ip_str)
+ pkt=str(parsed_pkt)
+ verify_packet(self, pkt, port2)
+ verify_packet(self, pkt, port3)
+ verify_no_other_packets(self)
+
+
diff --git a/ofdpa/cord.py b/ofdpa/cord.py
new file mode 100644
index 0000000..b86070b
--- /dev/null
+++ b/ofdpa/cord.py
@@ -0,0 +1,88 @@
+"""
+The following tests are being done here
+1) PacketInSrcMacMiss
+2) VlanSupport
+3) L2FloodQinQ
+4) L2FloodTagged
+5) L2Flood Tagged Unknown Src
+6) L2 Unicast Tagged
+7) MTU 1500
+8) MTU 4100
+9) MTU 4500
+10) L3UnicastTagged
+11) L3VPNMPLS
+12) MPLS Termination
+"""
+
+from oftest import config
+import logging
+import oftest.base_tests as base_tests
+import ofp
+from oftest.testutils import *
+from accton_util import *
+
+class VlanSupport(base_tests.SimpleDataPlane):
+ """
+ Test L2 forwarding of both, untagged and double-tagged packets
+ Sends a packet and expects the same packet on the other port
+ Repeats for double tagged
+ """
+ def runTest(self):
+ delete_all_flows(self.controller)
+ delete_all_groups(self.controller)
+ ports = sorted(config["port_map"].keys())
+ # group table
+ # set up untag groups for each port
+ add_l2_interface_group(self.controller, config["port_map"].keys(), 4093, False, 1)
+ for port in ports:
+ add_one_vlan_table_flow(self.controller, port, 4093, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
+ group_id = encode_l2_interface_group_id(4093, port)
+ add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 4093, group_id, True)
+ #add flow match for vlan 300
+ add_one_l2_interface_group(self.controller, port, 300, True, False)
+ add_one_vlan_table_flow(self.controller, port, 300, flag=VLAN_TABLE_FLAG_ONLY_TAG)
+ msg=add_l2_flood_group(self.controller, ports, 300, 1)
+ add_bridge_flow(self.controller, None, 300, msg.group_id, True)
+ msg=add_l2_flood_group(self.controller, ports, 4093, 1)
+ add_bridge_flow(self.controller, None, 4093, msg.group_id, True)
+ do_barrier(self.controller)
+
+ for out_port in ports:
+ # change dest based on port number
+ mac_dst= '00:12:34:56:78:%02X' % out_port
+
+ for in_port in ports:
+ if in_port == out_port:
+ continue
+ # change source based on port number to avoid packet-ins from learning
+ mac_src= '00:12:34:56:78:%02X' % in_port
+ #sends an untagged packet
+ parsed_pkt = simple_tcp_packet(dl_vlan_enable=False, vlan_vid=4093, eth_dst=mac_dst, eth_src=mac_src)
+ pkt = str(parsed_pkt)
+ logging.info("OutputExact test, ports %d to %d", in_port, out_port)
+ self.dataplane.send(in_port, pkt)
+
+ for ofport in ports:
+ if ofport in [out_port]:
+ verify_packet(self, pkt, ofport)
+ else:
+ verify_no_packet(self, pkt, ofport)
+
+ verify_no_other_packets(self)
+ # sends a double tagged packet
+ parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=300,
+ in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
+ pkt = str(parsed_pkt)
+ logging.info("OutputExact test, ports %d to %d", in_port, out_port)
+ self.dataplane.send(in_port, pkt)
+
+ for ofport in ports:
+ if ofport in [out_port]:
+ verify_packet(self, pkt, ofport)
+ else:
+ verify_no_packet(self, pkt, ofport)
+
+ verify_no_other_packets(self)
+
+
+
diff --git a/ofdpa/dev.py b/ofdpa/dev.py
deleted file mode 100644
index 46608c1..0000000
--- a/ofdpa/dev.py
+++ /dev/null
@@ -1,101 +0,0 @@
-"""
-Flow Test
-Test each flow table can set entry, and packet rx correctly.
-1) L3UcastRoute
-2) QinQ
-"""
-
-import logging
-
-from oftest import config
-import oftest.base_tests as base_tests
-import ofp
-from oftest.testutils import *
-from accton_util import *
-
-@disabled
-class Purge(base_tests.SimpleDataPlane):
- def runTest(self):
- delete_all_flows(self.controller)
- delete_all_groups(self.controller)
- do_barrier(self.controller)
- add_vlan_table_flow(self.controller, config["port_map"].keys(), 1)
- verify_no_other_packets(self)
-
-@disabled
-class FlowStats(base_tests.SimpleProtocol):
- """
- Flow stats multipart transaction
- Only verifies we get a reply.
- """
- def runTest(self):
-
- logging.info("Sending flow stats request")
- stats = get_flow_stats(self, ofp.match())
- logging.info("Received %d flow stats entries", len(stats))
- for entry in stats:
- print(entry.show())
-
-class TagFlow20to10(base_tests.SimpleDataPlane):
- def runTest(self):
- do_barrier(self.controller)
- for port in config["port_map"].keys():
- add_one_vlan_table_flow(self.controller, port, 10, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
- do_barrier(self.controller)
- logging.info("Sending flow stats request")
- stats = get_flow_stats(self, ofp.match())
- print "STATS"
- for entry in stats:
- print(entry.show())
- print "END"
- do_barrier(self.controller)
- verify_no_other_packets(self)
-
-@disabled
-class UnTagFlow0(base_tests.SimpleDataPlane):
- def runTest(self):
- do_barrier(self.controller)
- for port in config["port_map"].keys():
- add_untag_vlan_table_flow(self.controller, port, 0x0000, 0x1000)
- do_barrier(self.controller)
- logging.info("Sending flow stats request")
- stats = get_flow_stats(self, ofp.match())
- print "STATS"
- for entry in stats:
- print(entry.show())
- print "END"
- do_barrier(self.controller)
- verify_no_other_packets(self)
-
-@disabled
-class UnTagFlow10(base_tests.SimpleDataPlane):
- def runTest(self):
- do_barrier(self.controller)
- for port in config["port_map"].keys():
- add_untag_vlan_table_flow(self.controller, port, 0x0000, 0x1fff)
- do_barrier(self.controller)
- logging.info("Sending flow stats request")
- stats = get_flow_stats(self, ofp.match())
- print "STATS"
- for entry in stats:
- print(entry.show())
- print "END"
- do_barrier(self.controller)
- verify_no_other_packets(self)
-
-
-@disabled
-class UnTagFlow1(base_tests.SimpleDataPlane):
- def runTest(self):
- do_barrier(self.controller)
- for port in config["port_map"].keys():
- add_untag_vlan_table(self.controller, port)
- do_barrier(self.controller)
- logging.info("Sending flow stats request")
- stats = get_flow_stats(self, ofp.match())
- print "STATS"
- for entry in stats:
- print(entry.show())
- print "END"
- do_barrier(self.controller)
- verify_no_other_packets(self)
diff --git a/ofdpa/onos.py b/ofdpa/flows.py
similarity index 89%
rename from ofdpa/onos.py
rename to ofdpa/flows.py
index 86c7053..89cd88f 100644
--- a/ofdpa/onos.py
+++ b/ofdpa/flows.py
@@ -102,69 +102,6 @@
verify_no_other_packets(self)
-class VlanSupport(base_tests.SimpleDataPlane):
- """
- Test L2 forwarding of both, untagged and double-tagged packets
- Sends a packet and expects the same packet on the other port
- Repeats for double tagged
- """
- def runTest(self):
- delete_all_flows(self.controller)
- delete_all_groups(self.controller)
- ports = sorted(config["port_map"].keys())
- # group table
- # set up untag groups for each port
- add_l2_interface_group(self.controller, config["port_map"].keys(), 4093, False, 1)
- for port in ports:
- add_one_vlan_table_flow(self.controller, port, 4093, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
- group_id = encode_l2_interface_group_id(4093, port)
- add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 4093, group_id, True)
- #add flow match for vlan 300
- add_one_l2_interface_group(self.controller, port, 300, True, False)
- add_one_vlan_table_flow(self.controller, port, 300, flag=VLAN_TABLE_FLAG_ONLY_TAG)
- msg=add_l2_flood_group(self.controller, ports, 300, 1)
- add_bridge_flow(self.controller, None, 300, msg.group_id, True)
- msg=add_l2_flood_group(self.controller, ports, 4093, 1)
- add_bridge_flow(self.controller, None, 4093, msg.group_id, True)
- do_barrier(self.controller)
-
- for out_port in ports:
- # change dest based on port number
- mac_dst= '00:12:34:56:78:%02X' % out_port
-
- for in_port in ports:
- if in_port == out_port:
- continue
- # change source based on port number to avoid packet-ins from learning
- mac_src= '00:12:34:56:78:%02X' % in_port
- #sends an untagged packet
- parsed_pkt = simple_tcp_packet(dl_vlan_enable=False, vlan_vid=4093, eth_dst=mac_dst, eth_src=mac_src)
- pkt = str(parsed_pkt)
- logging.info("OutputExact test, ports %d to %d", in_port, out_port)
- self.dataplane.send(in_port, pkt)
-
- for ofport in ports:
- if ofport in [out_port]:
- verify_packet(self, pkt, ofport)
- else:
- verify_no_packet(self, pkt, ofport)
-
- verify_no_other_packets(self)
- # sends a double tagged packet
- parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=300,
- in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
- pkt = str(parsed_pkt)
- logging.info("OutputExact test, ports %d to %d", in_port, out_port)
- self.dataplane.send(in_port, pkt)
-
- for ofport in ports:
- if ofport in [out_port]:
- verify_packet(self, pkt, ofport)
- else:
- verify_no_packet(self, pkt, ofport)
-
- verify_no_other_packets(self)
-
class L2FloodQinQ(base_tests.SimpleDataPlane):
"""
Test L2 flood of double tagged vlan packets (802.1Q)
@@ -317,43 +254,6 @@
verify_no_other_packets(self)
-
-class Mtu4500(base_tests.SimpleDataPlane):
-
- def runTest(self):
- ports = sorted(config["port_map"].keys())
-
- delete_all_flows(self.controller)
- delete_all_groups(self.controller)
-
- for port in ports:
- add_one_l2_interface_group(self.controller, port, 1, True, False)
- add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
- group_id = encode_l2_interface_group_id(1, port)
- add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
- do_barrier(self.controller)
-
- for out_port in ports:
- # change dest based on port number
- mac_dst= '00:12:34:56:78:%02X' % out_port
- for in_port in ports:
- if in_port == out_port:
- continue
- # change source based on port number to avoid packet-ins from learning
- mac_src= '00:12:34:56:78:%02X' % in_port
- parsed_pkt = simple_tcp_packet(pktlen=4500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
- pkt = str(parsed_pkt)
- self.dataplane.send(in_port, pkt)
-
- for ofport in ports:
- if ofport in [out_port]:
- verify_packet(self, pkt, ofport)
- else:
- verify_no_packet(self, pkt, ofport)
-
- verify_no_other_packets(self)
-
-
class Mtu1500(base_tests.SimpleDataPlane):
def runTest(self):
diff --git a/ofdpa/sr.py b/ofdpa/manual.py
similarity index 100%
rename from ofdpa/sr.py
rename to ofdpa/manual.py