alshabib

possible fix for link discovery

Change-Id: Id52dce21e93f0ca4665b15d3b169dc6a8dba76b4
......@@ -48,13 +48,10 @@ import org.slf4j.LoggerFactory;
public class Controller {
protected static final Logger log = LoggerFactory.getLogger(Controller.class);
static final String ERROR_DATABASE =
"The controller could not communicate with the system database.";
protected static final OFFactory FACTORY13 = OFFactories.getFactory(OFVersion.OF_13);
protected static final OFFactory FACTORY10 = OFFactories.getFactory(OFVersion.OF_10);
// The controllerNodeIPsCache maps Controller IDs to their IP address.
// It's only used by handleControllerNodeIPsChanged
protected HashMap<String, String> controllerNodeIPsCache;
private ChannelGroup cg;
......
......@@ -41,6 +41,7 @@ import org.projectfloodlight.openflow.protocol.OFHello;
import org.projectfloodlight.openflow.protocol.OFHelloElem;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPacketOut;
import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
import org.projectfloodlight.openflow.protocol.OFPortDescStatsRequest;
import org.projectfloodlight.openflow.protocol.OFPortStatus;
......@@ -418,7 +419,14 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
//h.setSwitchRole(RoleState.EQUAL);
h.sw.startDriverHandshake();
h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE);
if (h.sw.isDriverHandshakeComplete()) {
if (!h.sw.connectSwitch()) {
disconnectDuplicate(h);
}
h.setState(ACTIVE);
} else {
h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE);
}
}
......@@ -465,6 +473,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
if (h.sw.isDriverHandshakeComplete()) {
moveToActive(h);
h.state.processOFMessage(h, m);
return;
}
......@@ -479,7 +489,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
h.sw.processDriverHandshakeMessage(m);
if (h.sw.isDriverHandshakeComplete()) {
moveToActive(h);
h.setState(ACTIVE);
}
}
} else {
......@@ -507,7 +516,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
h.setState(ACTIVE);
if (!success) {
disconnectDuplicate(h);
return;
}
}
......@@ -581,6 +589,11 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
@Override
void processOFPacketIn(OFChannelHandler h, OFPacketIn m) {
// OFPacketOut out =
// h.sw.factory().buildPacketOut()
// .setXid(m.getXid())
// .setBufferId(m.getBufferId()).build();
// h.sw.sendMsg(out);
h.dispatchMessage(m);
}
......
......@@ -188,6 +188,7 @@ public class OpenFlowControllerImpl implements OpenFlowController {
@Override
public boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw) {
if (connectedSwitches.get(dpid) != null) {
log.error("Trying to add connectedSwitch but found a previous "
+ "value for dpid: {}", dpid);
......