Added Flood test case; clear flows more often
Added flood test case. This assumes all ports are set to flood.
Also moved the "clear flow table" call to inside the loop across
ingress ports for various tests.
diff --git a/tests/pktact.py b/tests/pktact.py
index 0c31a07..26b920a 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -69,9 +69,6 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- rc = delete_all_flows(self.controller, pa_logger)
- self.assertEqual(rc, 0, "Failed to delete all flows")
-
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
match.wildcards &= ~ofp.OFPFW_IN_PORT
@@ -80,6 +77,9 @@
act = action.action_output()
for idx in range(len(of_ports)):
+ rc = delete_all_flows(self.controller, pa_logger)
+ self.assertEqual(rc, 0, "Failed to delete all flows")
+
ingress_port = of_ports[idx]
egress_port = of_ports[(idx + 1) % len(of_ports)]
pa_logger.info("Ingress " + str(ingress_port) +
@@ -127,9 +127,6 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 2, "Not enough ports for test")
- rc = delete_all_flows(self.controller, pa_logger)
- self.assertEqual(rc, 0, "Failed to delete all flows")
-
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
match.wildcards &= ~ofp.OFPFW_IN_PORT
@@ -138,6 +135,9 @@
act = action.action_output()
for idx in range(len(of_ports)):
+ rc = delete_all_flows(self.controller, pa_logger)
+ self.assertEqual(rc, 0, "Failed to delete all flows")
+
ingress_port = of_ports[idx]
egress_port1 = of_ports[(idx + 1) % len(of_ports)]
egress_port2 = of_ports[(idx + 2) % len(of_ports)]
@@ -185,8 +185,6 @@
'Response packet does not match send packet 1')
self.assertEqual(str(pkt), str(rcv_pkt2),
'Response packet does not match send packet 2')
-
-
class DirectMCNonIngress(basic.SimpleDataPlane):
"""
@@ -206,9 +204,6 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 2, "Not enough ports for test")
- rc = delete_all_flows(self.controller, pa_logger)
- self.assertEqual(rc, 0, "Failed to delete all flows")
-
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
match.wildcards &= ~ofp.OFPFW_IN_PORT
@@ -217,6 +212,9 @@
act = action.action_output()
for idx in range(len(of_ports)):
+ rc = delete_all_flows(self.controller, pa_logger)
+ self.assertEqual(rc, 0, "Failed to delete all flows")
+
ingress_port = of_ports[idx]
pa_logger.info("Ingress " + str(ingress_port) +
" all non-ingress ports")
@@ -257,8 +255,6 @@
self.assertEqual(str(pkt), str(rcv_pkt),
'Response packet does not match send packet ' +
"on port " + str(ofport))
-
-
class DirectMC(basic.SimpleDataPlane):
"""
@@ -278,9 +274,6 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 2, "Not enough ports for test")
- rc = delete_all_flows(self.controller, pa_logger)
- self.assertEqual(rc, 0, "Failed to delete all flows")
-
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
match.wildcards &= ~ofp.OFPFW_IN_PORT
@@ -289,6 +282,9 @@
act = action.action_output()
for idx in range(len(of_ports)):
+ rc = delete_all_flows(self.controller, pa_logger)
+ self.assertEqual(rc, 0, "Failed to delete all flows")
+
ingress_port = of_ports[idx]
pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
@@ -305,6 +301,66 @@
act.port = egress_port
self.assertTrue(request.actions.add(act),
"Could not add output to " + str(egress_port))
+ # pa_logger.info(request.show())
+
+ pa_logger.info("Inserting flow")
+ rv = self.controller.message_send(request)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ do_barrier(self.controller)
+
+ pa_logger.info("Sending packet to dp port " + str(ingress_port))
+ self.dataplane.send(ingress_port, str(pkt))
+ for egr_idx in range(len(of_ports)):
+ ofport = of_ports[egr_idx]
+ (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(
+ port_number=ofport, timeout=1)
+ self.assertTrue(rcv_pkt is not None,
+ "Did not receive packet port " + str(ofport))
+ pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on "
+ + str(rcv_port))
+
+ self.assertEqual(str(pkt), str(rcv_pkt),
+ 'Response packet does not match send packet ' +
+ "on port " + str(ofport))
+
+class Flood(basic.SimpleDataPlane):
+ """
+ Flood to all ports except ingress
+
+ Generate a packet
+ Generate and install a matching flow
+ Add action to flood the packet
+ Send the packet to ingress dataplane port
+ Verify the packet is received at all other ports
+ """
+ def runTest(self):
+ global pa_port_map
+ of_ports = pa_port_map.keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ pkt = simple_tcp_packet()
+ match = parse.packet_to_flow_match(pkt)
+ match.wildcards &= ~ofp.OFPFW_IN_PORT
+ self.assertTrue(match is not None,
+ "Could not generate flow match from pkt")
+ act = action.action_output()
+
+ for idx in range(len(of_ports)):
+ rc = delete_all_flows(self.controller, pa_logger)
+ self.assertEqual(rc, 0, "Failed to delete all flows")
+
+ ingress_port = of_ports[idx]
+ pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+
+ match.in_port = ingress_port
+
+ request = message.flow_mod()
+ request.match = match
+ request.buffer_id = 0xffffffff
+ act.port = ofp.OFPP_FLOOD
+ self.assertTrue(request.actions.add(act),
+ "Could not flood port action")
pa_logger.info(request.show())
pa_logger.info("Inserting flow")
@@ -315,6 +371,8 @@
pa_logger.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
for egr_idx in range(len(of_ports)):
+ if egr_idx == idx:
+ continue
ofport = of_ports[egr_idx]
(rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(
port_number=ofport, timeout=1)