alshabib

possible fix for link discovery

Change-Id: Id52dce21e93f0ca4665b15d3b169dc6a8dba76b4
...@@ -48,13 +48,10 @@ import org.slf4j.LoggerFactory; ...@@ -48,13 +48,10 @@ import org.slf4j.LoggerFactory;
48 public class Controller { 48 public class Controller {
49 49
50 protected static final Logger log = LoggerFactory.getLogger(Controller.class); 50 protected static final Logger log = LoggerFactory.getLogger(Controller.class);
51 - static final String ERROR_DATABASE = 51 +
52 - "The controller could not communicate with the system database.";
53 protected static final OFFactory FACTORY13 = OFFactories.getFactory(OFVersion.OF_13); 52 protected static final OFFactory FACTORY13 = OFFactories.getFactory(OFVersion.OF_13);
54 protected static final OFFactory FACTORY10 = OFFactories.getFactory(OFVersion.OF_10); 53 protected static final OFFactory FACTORY10 = OFFactories.getFactory(OFVersion.OF_10);
55 54
56 - // The controllerNodeIPsCache maps Controller IDs to their IP address.
57 - // It's only used by handleControllerNodeIPsChanged
58 protected HashMap<String, String> controllerNodeIPsCache; 55 protected HashMap<String, String> controllerNodeIPsCache;
59 56
60 private ChannelGroup cg; 57 private ChannelGroup cg;
......
...@@ -41,6 +41,7 @@ import org.projectfloodlight.openflow.protocol.OFHello; ...@@ -41,6 +41,7 @@ import org.projectfloodlight.openflow.protocol.OFHello;
41 import org.projectfloodlight.openflow.protocol.OFHelloElem; 41 import org.projectfloodlight.openflow.protocol.OFHelloElem;
42 import org.projectfloodlight.openflow.protocol.OFMessage; 42 import org.projectfloodlight.openflow.protocol.OFMessage;
43 import org.projectfloodlight.openflow.protocol.OFPacketIn; 43 import org.projectfloodlight.openflow.protocol.OFPacketIn;
44 +import org.projectfloodlight.openflow.protocol.OFPacketOut;
44 import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; 45 import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
45 import org.projectfloodlight.openflow.protocol.OFPortDescStatsRequest; 46 import org.projectfloodlight.openflow.protocol.OFPortDescStatsRequest;
46 import org.projectfloodlight.openflow.protocol.OFPortStatus; 47 import org.projectfloodlight.openflow.protocol.OFPortStatus;
...@@ -418,7 +419,14 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -418,7 +419,14 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
418 //h.setSwitchRole(RoleState.EQUAL); 419 //h.setSwitchRole(RoleState.EQUAL);
419 420
420 h.sw.startDriverHandshake(); 421 h.sw.startDriverHandshake();
421 - h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE); 422 + if (h.sw.isDriverHandshakeComplete()) {
423 + if (!h.sw.connectSwitch()) {
424 + disconnectDuplicate(h);
425 + }
426 + h.setState(ACTIVE);
427 + } else {
428 + h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE);
429 + }
422 430
423 } 431 }
424 432
...@@ -465,6 +473,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -465,6 +473,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
465 473
466 if (h.sw.isDriverHandshakeComplete()) { 474 if (h.sw.isDriverHandshakeComplete()) {
467 moveToActive(h); 475 moveToActive(h);
476 + h.state.processOFMessage(h, m);
477 + return;
468 478
469 } 479 }
470 480
...@@ -479,7 +489,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -479,7 +489,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
479 h.sw.processDriverHandshakeMessage(m); 489 h.sw.processDriverHandshakeMessage(m);
480 if (h.sw.isDriverHandshakeComplete()) { 490 if (h.sw.isDriverHandshakeComplete()) {
481 moveToActive(h); 491 moveToActive(h);
482 - h.setState(ACTIVE);
483 } 492 }
484 } 493 }
485 } else { 494 } else {
...@@ -507,7 +516,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -507,7 +516,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
507 h.setState(ACTIVE); 516 h.setState(ACTIVE);
508 if (!success) { 517 if (!success) {
509 disconnectDuplicate(h); 518 disconnectDuplicate(h);
510 - return;
511 } 519 }
512 } 520 }
513 521
...@@ -581,6 +589,11 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -581,6 +589,11 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
581 589
582 @Override 590 @Override
583 void processOFPacketIn(OFChannelHandler h, OFPacketIn m) { 591 void processOFPacketIn(OFChannelHandler h, OFPacketIn m) {
592 +// OFPacketOut out =
593 +// h.sw.factory().buildPacketOut()
594 +// .setXid(m.getXid())
595 +// .setBufferId(m.getBufferId()).build();
596 +// h.sw.sendMsg(out);
584 h.dispatchMessage(m); 597 h.dispatchMessage(m);
585 } 598 }
586 599
......
...@@ -188,6 +188,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { ...@@ -188,6 +188,7 @@ public class OpenFlowControllerImpl implements OpenFlowController {
188 188
189 @Override 189 @Override
190 public boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw) { 190 public boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw) {
191 +
191 if (connectedSwitches.get(dpid) != null) { 192 if (connectedSwitches.get(dpid) != null) {
192 log.error("Trying to add connectedSwitch but found a previous " 193 log.error("Trying to add connectedSwitch but found a previous "
193 + "value for dpid: {}", dpid); 194 + "value for dpid: {}", dpid);
......