fix for switch connecting
Change-Id: If4e16a692f79f94289bd0df4a0ffbb3dd828e246
diff --git a/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java b/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
index 5ee4039..8b4d444 100644
--- a/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
+++ b/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
@@ -457,9 +457,17 @@
// will never be called. We override processOFMessage
}
+
+
@Override
void processOFMessage(OFChannelHandler h, OFMessage m)
throws IOException, SwitchStateException {
+
+ if (h.sw.isDriverHandshakeComplete()) {
+ moveToActive(h);
+
+ }
+
if (m.getType() == OFType.ECHO_REQUEST) {
processOFEchoRequest(h, (OFEchoRequest) m);
} else if (m.getType() == OFType.ECHO_REPLY) {
@@ -470,6 +478,7 @@
if (!h.sw.handleRoleError((OFErrorMsg)m)) {
h.sw.processDriverHandshakeMessage(m);
if (h.sw.isDriverHandshakeComplete()) {
+ moveToActive(h);
h.setState(ACTIVE);
}
}
@@ -481,13 +490,7 @@
} else {
h.sw.processDriverHandshakeMessage(m);
if (h.sw.isDriverHandshakeComplete()) {
- boolean success = h.sw.connectSwitch();
-
- if (!success) {
- disconnectDuplicate(h);
- return;
- }
- h.setState(ACTIVE);
+ moveToActive(h);
}
}
}
@@ -498,6 +501,16 @@
throws IOException, SwitchStateException {
h.pendingPortStatusMsg.add(m);
}
+
+ private void moveToActive(OFChannelHandler h) {
+ boolean success = h.sw.connectSwitch();
+ h.setState(ACTIVE);
+ if (!success) {
+ disconnectDuplicate(h);
+ return;
+ }
+ }
+
},