controller.py: clear pending packets on disconnect.
cxn.py: store switch addr to detect when switch has disconnected and
reconnected.
diff --git a/src/python/oftest/controller.py b/src/python/oftest/controller.py
index b4c3ac5..3b2dc43 100644
--- a/src/python/oftest/controller.py
+++ b/src/python/oftest/controller.py
@@ -444,6 +444,8 @@
self.switch_socket.close()
self.switch_socket = None
self.switch_addr = None
+ with self.packets_cv:
+ self.packets = []
with self.connect_cv:
self.connect_cv.notifyAll()
diff --git a/tests/cxn.py b/tests/cxn.py
index db377be..5718c66 100644
--- a/tests/cxn.py
+++ b/tests/cxn.py
@@ -147,6 +147,7 @@
for i in range(len(self.controller_list)):
self.controllers[i].cstate = 0
self.controllers[i].keep_alive = self.keep_alive
+ self.controllers[i].saved_switch_addr = None
tick = 0.1 # time period in seconds at which controllers are handled
disconnected_count = 0
@@ -157,7 +158,11 @@
condesc = con.host + ":" + str(con.port) + ": "
logging.debug("Checking " + condesc)
- if con.switch_socket:
+ if con.switch_socket:
+ if con.switch_addr != con.saved_switch_addr:
+ con.saved_switch_addr = con.switch_addr
+ con.cstate = 0
+
if con.cstate == 0:
logging.info(condesc + "Sending hello to " +
str(con.switch_addr))
@@ -196,6 +201,7 @@
con.cstate = 4
con.count = 0
cycle = cycle + 1
+ logging.info("Cycle " + str(cycle))
else:
con.count = con.count + 1
# fall back to previous state on timeout