Fix for inactive hardware switch issue. Previously we didn't send a role request to a switch when we know it doesn't support role requests. This meant nothing happened when we were granted control of a hardware switch. We now always send MASTER role requests to hardware switches and do the right thing in the error handling code
diff --git a/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java b/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java
index 2d1e3e8..b2de649 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java
@@ -277,11 +277,21 @@
// Handle cases #1 and #2
log.debug("Sending NxRoleRequest to {}", sw);
sw.sendNxRoleRequest(role, cookie);
- } else {
- log.debug("Switch {} doesn't support NxRoleRequests so we can't send " +
- "a {} request - doing nothing", sw, role);
- // Handle case #3
- if (role == Role.SLAVE) {
+ } else {
+ if (role == Role.MASTER) {
+ log.debug("Switch {} doesn't support NxRoleRequests, but sending " +
+ "{} request anyway", sw, role);
+ //Send the role request anyway, even though we know the switch
+ //doesn't support it. The switch will give an error and in our
+ //error handling code we will add the switch.
+ //NOTE we *could* just add the switch right away rather than
+ //going through the overhead of sending a role request - however
+ //we then have to deal with concurrency issues resulting from
+ //calling addSwitch outside of a netty handler.
+ sw.sendNxRoleRequest(role, cookie);
+ }
+ // Handle case #3
+ else if (role == Role.SLAVE) {
log.debug("Disconnecting switch {} that doesn't support " +
"role request messages from a controller that went to SLAVE mode");
// Closing the channel should result in a call to