diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java b/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java index 2c47dacf5f10883dcd0fb0e92bb005bb23c8ae6f..7f9af5d05fd89129e8a7a2c303cf084ffef93a71 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java +++ b/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java @@ -72,6 +72,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; + /** * Channel handler deals with the switch connection and dispatches * switch messages to the appropriate locations. @@ -96,6 +97,8 @@ class OFChannelHandler private RoleChanger roleChanger; private OFFeaturesReply featuresReply; + private ArrayList<OFPortStatus> pendingPortStatusMsg; + /** transaction Ids to use during handshake. Since only one thread * calls into the OFChannelHandler we don't need atomic. * We will count down @@ -541,6 +544,12 @@ class OFChannelHandler void processOFError(OFChannelHandler h, OFError m) { logErrorDisconnect(h, m); } + + @Override + void processOFPortStatus(OFChannelHandler h, OFPortStatus m) + throws IOException { + h.pendingPortStatusMsg.add(m); + } }, /** @@ -583,6 +592,9 @@ class OFChannelHandler h.sw.setFloodlightProvider(h.controller); h.sw.setThreadPoolService(h.controller.getThreadPoolService()); h.sw.setDebugCounterService(h.controller.getDebugCounter()); + for (OFPortStatus ps: h.pendingPortStatusMsg) + handlePortStatusMessage(h, ps, false); + h.pendingPortStatusMsg.clear(); h.readPropertyFromStorage(); log.info("Switch {} bound to class {}, writeThrottle={}," + " description {}", @@ -659,8 +671,7 @@ class OFChannelHandler @Override void processOFPortStatus(OFChannelHandler h, OFPortStatus m) throws IOException { - // TODO - handlePortStatusMessage(h, m); + handlePortStatusMessage(h, m, false); } }, @@ -742,8 +753,7 @@ class OFChannelHandler @Override void processOFPortStatus(OFChannelHandler h, OFPortStatus m) throws IOException { - handlePortStatusMessage(h, m); - // FIXME: ---> h.dispatchMessage(m); + handlePortStatusMessage(h, m, true); } @Override @@ -979,7 +989,8 @@ class OFChannelHandler * @param m The PortStatus message we received */ protected void handlePortStatusMessage(OFChannelHandler h, - OFPortStatus m) { + OFPortStatus m, + boolean doNotify) { short portNumber = m.getDesc().getPortNumber(); OFPhysicalPort port = m.getDesc(); OFPortReason reason = OFPortReason.fromReasonCode(m.getReason()); @@ -1016,7 +1027,8 @@ class OFChannelHandler log.debug("Port #{} deleted for {}", portNumber, h.sw); break; } - h.controller.notifyPortChanged(h.sw, port, changeType); + if (doNotify) + h.controller.notifyPortChanged(h.sw, port, changeType); } /** @@ -1199,6 +1211,7 @@ class OFChannelHandler this.counters = controller.getCounters(); this.roleChanger = new RoleChanger(DEFAULT_ROLE_TIMEOUT_MS); this.state = ChannelState.INIT; + this.pendingPortStatusMsg = new ArrayList<OFPortStatus>(); } /**