Search for dest port for duplicate search
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index 6f2d166..0cbcfcb 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -107,6 +107,7 @@
import org.openflow.protocol.OFPacketIn;
import org.openflow.protocol.OFPhysicalPort;
import org.openflow.protocol.OFPortStatus;
+import org.openflow.protocol.OFPhysicalPort.OFPortState;
import org.openflow.protocol.OFPortStatus.OFPortReason;
import org.openflow.protocol.OFSetConfig;
import org.openflow.protocol.OFStatisticsRequest;
@@ -1144,8 +1145,16 @@
short portNumber = m.getDesc().getPortNumber();
OFPhysicalPort port = m.getDesc();
if (m.getReason() == (byte)OFPortReason.OFPPR_MODIFY.ordinal()) {
+ int srcPortState = port.getState();
+ boolean portUp = ((srcPortState &
+ OFPortState.OFPPS_STP_MASK.getValue()) !=
+ OFPortState.OFPPS_STP_BLOCK.getValue());
sw.setPort(port);
- swStore.addPort(sw.getStringId(), port);
+ if (portUp) {
+ swStore.addPort(sw.getStringId(), port);
+ } else {
+ swStore.deletePort(sw.getStringId(), port.getPortNumber());
+ }
if (updateStorage)
updatePortInfo(sw, port);
log.debug("Port #{} modified for {}", portNumber, sw);
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
index 31814af..dd743ba 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
@@ -1,5 +1,6 @@
package net.floodlightcontroller.linkdiscovery.internal;
+import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -98,9 +99,16 @@
if (vportSrc != null && vportDst != null) {
//TODO: If Edge already exists should we remove and add again?
- if (vportSrc.query().direction(Direction.OUT).labels("link").vertices().iterator().hasNext() &&
- vportSrc.query().direction(Direction.OUT).labels("link").vertices().iterator().next().equals(vportDst)) {
+ List<Vertex> currLinks = new ArrayList<Vertex>();
+ for (Vertex V : vportSrc.query().direction(Direction.OUT).labels("link").vertices()) {
+ currLinks.add(V);
+ }
+
+ if (currLinks.contains(vportDst)) {
+ // if (vportSrc.query().direction(Direction.OUT).labels("link").vertices().iterator().hasNext() &&
+ // vportSrc.query().direction(Direction.OUT).labels("link").) {
//FIXME: Succeed silently for now
+ log.debug("addLink(): Failure: link exists {} src {} dst {}", new Object[]{lt, vportSrc, vportDst});
} else {
graph.addEdge(null, vportSrc, vportDst, "link");
graph.stopTransaction(Conclusion.SUCCESS);