Fix in hardware switch connection handling code - We now ensure we only add a switch to the active list if we actually already sent a MASTER request to switch (previously switch would be added even if only a SLAVE request had been sent)
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index 4057bc9..04e32e6 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -1114,16 +1114,19 @@
+"role reply earlier", sw);
}
state.firstRoleReplyReceived = true;
- sw.deliverRoleRequestNotSupported(error.getXid());
+ Role requestedRole =
+ sw.deliverRoleRequestNotSupported(error.getXid());
synchronized(roleChanger) {
if (sw.role == null && Controller.this.role==Role.SLAVE) {
+ //This will now never happen. The Controller's role
+ //is now never SLAVE, always MASTER.
// the switch doesn't understand role request
// messages and the current controller role is
// slave. We need to disconnect the switch.
// @see RoleChanger for rationale
sw.getChannel().close();
}
- else if (sw.role == null) {
+ else if (sw.role == null && requestedRole == Role.MASTER) {
// Controller's role is master: add to
// active
// TODO: check if clearing flow table is
diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java
index 5ffd9bc..7313619 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java
@@ -787,15 +787,17 @@
* Otherwise we ignore it.
* @param xid
*/
- protected void deliverRoleRequestNotSupported(int xid) {
+ protected Role deliverRoleRequestNotSupported(int xid) {
synchronized(pendingRoleRequests) {
PendingRoleRequestEntry head = pendingRoleRequests.poll();
this.role = null;
if (head!=null && head.xid == xid) {
setAttribute(SWITCH_SUPPORTS_NX_ROLE, false);
+ return head.role;
}
else {
this.channel.close();
+ return null;
}
}
}