From 98e320a9f3f894951a86cc5ae6b3a725eeea4afc Mon Sep 17 00:00:00 2001 From: hwchiu <sppsorrg@gmail.com> Date: Mon, 11 Aug 2014 16:52:53 +0800 Subject: [PATCH] Fix the bug for LLDP (send/receive) and add the null condition check for topologyInstance. --- .../internal/LinkDiscoveryManager.java | 8 +++---- .../topology/TopologyInstance.java | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java index e2b53a777..5ca1b5eb7 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java @@ -565,7 +565,7 @@ IFloodlightModule, IInfoProvider { FloodlightContext cntx) { Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD); - + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); if (eth.getPayload() instanceof BSN) { BSN bsn = (BSN) eth.getPayload(); if (bsn == null) return Command.STOP; @@ -574,9 +574,9 @@ IFloodlightModule, IInfoProvider { // continue with the regular processing. if (bsn.getPayload() instanceof LLDP == false) return Command.CONTINUE; - return handleLldp((LLDP) bsn.getPayload(), sw, pi.getInPort(), false, cntx); + return handleLldp((LLDP) bsn.getPayload(), sw, inPort, false, cntx); } else if (eth.getPayload() instanceof LLDP) { - return handleLldp((LLDP) eth.getPayload(), sw, pi.getInPort(), true, cntx); + return handleLldp((LLDP) eth.getPayload(), sw, inPort, true, cntx); } else if (eth.getEtherType() < 1500) { long destMac = eth.getDestinationMACAddress().getLong(); if ((destMac & LINK_LOCAL_MASK) == LINK_LOCAL_VALUE) { @@ -1134,7 +1134,7 @@ IFloodlightModule, IInfoProvider { // send // no more try-catch. switch will silently fail - iofSwitch.write(po); + iofSwitch.write(pob.build()); iofSwitch.flush(); } diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java b/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java index 57d27231d..580d82e83 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java @@ -583,17 +583,19 @@ public class TopologyInstance { //log.info("Broadcast Tree {}", tree); Set<NodePortTuple> nptSet = new HashSet<NodePortTuple>(); - Map<DatapathId, Link> links = tree.getLinks(); - if (links == null) continue; - for(DatapathId nodeId: links.keySet()) { - Link l = links.get(nodeId); - if (l == null) continue; - NodePortTuple npt1 = new NodePortTuple(l.getSrc(), l.getSrcPort()); - NodePortTuple npt2 = new NodePortTuple(l.getDst(), l.getDstPort()); - nptSet.add(npt1); - nptSet.add(npt2); + if( tree != null){ + Map<DatapathId, Link> links = tree.getLinks(); + if (links == null) continue; + for(DatapathId nodeId: links.keySet()) { + Link l = links.get(nodeId); + if (l == null) continue; + NodePortTuple npt1 = new NodePortTuple(l.getSrc(), l.getSrcPort()); + NodePortTuple npt2 = new NodePortTuple(l.getDst(), l.getDstPort()); + nptSet.add(npt1); + nptSet.add(npt2); + } + clusterBroadcastNodePorts.put(c.id, nptSet); } - clusterBroadcastNodePorts.put(c.id, nptSet); } } -- GitLab