Skip to content
Snippets Groups Projects
Commit 54ebee4f authored by abat's avatar abat
Browse files

Merge into master from pull request #186:

Link discovery manager must send LDUpdates when port status change affects existing links. (https://github.com/floodlight/floodlight/pull/186)
parents e24b8ce5 25946ee6
No related branches found
No related tags found
No related merge requests found
...@@ -731,7 +731,7 @@ public class LinkDiscoveryManager ...@@ -731,7 +731,7 @@ public class LinkDiscoveryManager
ILinkDiscovery.LinkType.INVALID_LINK, ILinkDiscovery.LinkType.INVALID_LINK,
EvAction.LINK_DELETED, reason); EvAction.LINK_DELETED, reason);
// remove link from // remove link from storage.
removeLinkFromStorage(lt); removeLinkFromStorage(lt);
...@@ -764,12 +764,11 @@ public class LinkDiscoveryManager ...@@ -764,12 +764,11 @@ public class LinkDiscoveryManager
SwitchPortTuple tuple = SwitchPortTuple tuple =
new SwitchPortTuple(sw, ps.getDesc().getPortNumber()); new SwitchPortTuple(sw, ps.getDesc().getPortNumber());
boolean link_deleted = false; boolean linkDeleted = false;
boolean linkInfoChanged = false;
lock.writeLock().lock(); lock.writeLock().lock();
try { try {
boolean topologyChanged = false;
// if ps is a delete, or a modify where the port is down or // if ps is a delete, or a modify where the port is down or
// configured down // configured down
if ((byte)OFPortReason.OFPPR_DELETE.ordinal() == ps.getReason() || if ((byte)OFPortReason.OFPPR_DELETE.ordinal() == ps.getReason() ||
...@@ -788,26 +787,25 @@ public class LinkDiscoveryManager ...@@ -788,26 +787,25 @@ public class LinkDiscoveryManager
} }
eraseList.addAll(this.portLinks.get(tuple)); eraseList.addAll(this.portLinks.get(tuple));
deleteLinks(eraseList, "Port Status Changed"); deleteLinks(eraseList, "Port Status Changed");
topologyChanged = true; linkDeleted = true;
link_deleted = true;
} }
} else if (ps.getReason() == } else if (ps.getReason() ==
(byte)OFPortReason.OFPPR_MODIFY.ordinal()) { (byte)OFPortReason.OFPPR_MODIFY.ordinal()) {
// If ps is a port modification and the port state has changed // If ps is a port modification and the port state has changed
// that affects links in the topology // that affects links in the topology
if (this.portLinks.containsKey(tuple)) { if (this.portLinks.containsKey(tuple)) {
for (LinkTuple link: this.portLinks.get(tuple)) { for (LinkTuple lt: this.portLinks.get(tuple)) {
LinkInfo linkInfo = links.get(link); LinkInfo linkInfo = links.get(lt);
assert(linkInfo != null); assert(linkInfo != null);
Integer updatedSrcPortState = null; Integer updatedSrcPortState = null;
Integer updatedDstPortState = null; Integer updatedDstPortState = null;
if (link.getSrc().equals(tuple) && if (lt.getSrc().equals(tuple) &&
(linkInfo.getSrcPortState() != (linkInfo.getSrcPortState() !=
ps.getDesc().getState())) { ps.getDesc().getState())) {
updatedSrcPortState = ps.getDesc().getState(); updatedSrcPortState = ps.getDesc().getState();
linkInfo.setSrcPortState(updatedSrcPortState); linkInfo.setSrcPortState(updatedSrcPortState);
} }
if (link.getDst().equals(tuple) && if (lt.getDst().equals(tuple) &&
(linkInfo.getDstPortState() != (linkInfo.getDstPortState() !=
ps.getDesc().getState())) { ps.getDesc().getState())) {
updatedDstPortState = ps.getDesc().getState(); updatedDstPortState = ps.getDesc().getState();
...@@ -815,16 +813,21 @@ public class LinkDiscoveryManager ...@@ -815,16 +813,21 @@ public class LinkDiscoveryManager
} }
if ((updatedSrcPortState != null) || if ((updatedSrcPortState != null) ||
(updatedDstPortState != null)) { (updatedDstPortState != null)) {
writeLink(link, linkInfo); // The link is already known to link discovery
topologyChanged = true; // manager and the status has changed, therefore
// send an LDUpdate.
updates.add(new LDUpdate(lt, linkInfo.getSrcPortState(),
linkInfo.getDstPortState(),
getLinkType(lt, linkInfo),
UpdateOperation.ADD_OR_UPDATE));
writeLink(lt, linkInfo);
linkInfoChanged = true;
} }
} }
} }
} }
if (topologyChanged) { if (!linkDeleted && !linkInfoChanged){
//updateClusters();
} else {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("handlePortStatus: Switch {} port #{} reason {};"+ log.debug("handlePortStatus: Switch {} port #{} reason {};"+
" no links to update/remove", " no links to update/remove",
...@@ -837,12 +840,12 @@ public class LinkDiscoveryManager ...@@ -837,12 +840,12 @@ public class LinkDiscoveryManager
lock.writeLock().unlock(); lock.writeLock().unlock();
} }
if (!link_deleted) { if (!linkDeleted) {
// Send LLDP right away when port state is changed for faster // Send LLDP right away when port state is changed for faster
// cluster-merge. If it is a link delete then there is not need // cluster-merge. If it is a link delete then there is not need
// to send the LLDPs right away and instead we wait for the LLDPs // to send the LLDPs right away and instead we wait for the LLDPs
// to be sent on the timer as it is normally done // to be sent on the timer as it is normally done
// do it outside the write-lock // do it outside the write-lock
sendLLDPTask.reschedule(1000, TimeUnit.MILLISECONDS); sendLLDPTask.reschedule(1000, TimeUnit.MILLISECONDS);
} }
return Command.CONTINUE; return Command.CONTINUE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment