[VOL-4185] Reset OF connection on Core restart

This fix resets the OF connection between the OFAgent and
the OF controller when the connection between the Voltha Core and
OFAgent is down (Voltah Core restarts).  This allows ONOS to
prevent any actions done on Voltha including stats update.

Change-Id: I146b316e70a3d086902250a7321bad13ddaf6eca
diff --git a/VERSION b/VERSION
index 266146b..e20c784 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.6.3
+1.6.4-dev
diff --git a/internal/pkg/ofagent/ofagent.go b/internal/pkg/ofagent/ofagent.go
index e2b66f3..fec0679 100644
--- a/internal/pkg/ofagent/ofagent.go
+++ b/internal/pkg/ofagent/ofagent.go
@@ -177,6 +177,9 @@
 				logger.Debug(ctx, "ofagent-voltha-disconnect-event")
 				if state == ofaStateConnected {
 					state = ofaStateDisconnected
+					// Clear all the OF connections to the OF controller.  These will be recreated when the
+					// connection to voltha is established
+					ofa.clearAllOFClient()
 					ofa.volthaClient.Clear()
 					volthaDone()
 					volthaDone = nil
diff --git a/internal/pkg/ofagent/refresh.go b/internal/pkg/ofagent/refresh.go
index 8025ba7..c77247d 100644
--- a/internal/pkg/ofagent/refresh.go
+++ b/internal/pkg/ofagent/refresh.go
@@ -110,9 +110,22 @@
 }
 
 func (ofa *OFAgent) getOFClient(ctx context.Context, deviceID string) *openflow.OFClient {
+	ofa.mapLock.Lock()
 	ofc := ofa.clientMap[deviceID]
+	ofa.mapLock.Unlock()
 	if ofc == nil {
 		ofc = ofa.addOFClient(ctx, deviceID)
 	}
 	return ofc
 }
+
+//clearAllOFClient clears all OF connections for all clients
+func (ofa *OFAgent) clearAllOFClient() {
+	logger.Debug(context.Background(), "stopping-all-of-connections...")
+	ofa.mapLock.Lock()
+	for deviceID := range ofa.clientMap {
+		ofa.clientMap[deviceID].Stop()
+		delete(ofa.clientMap, deviceID)
+	}
+	ofa.mapLock.Unlock()
+}