Skip to content
Snippets Groups Projects
Commit cda2b77d authored by Srinivasan Ramasubramanian's avatar Srinivasan Ramasubramanian
Browse files

TopologyManager should drop all packets if isAllowed() is false. Some code cleanup.

parent 16a8c079
No related branches found
No related tags found
No related merge requests found
...@@ -116,7 +116,7 @@ public class LinkInfo { ...@@ -116,7 +116,7 @@ public class LinkInfo {
result = prime * result + ((firstSeenTime == null) ? 0 : firstSeenTime.hashCode()); result = prime * result + ((firstSeenTime == null) ? 0 : firstSeenTime.hashCode());
result = prime * result + ((lastLldpReceivedTime == null) ? 0 : lastLldpReceivedTime.hashCode()); result = prime * result + ((lastLldpReceivedTime == null) ? 0 : lastLldpReceivedTime.hashCode());
result = prime * result + ((lastBddpReceivedTime == null) ? 0 : lastBddpReceivedTime.hashCode()); result = prime * result + ((lastBddpReceivedTime == null) ? 0 : lastBddpReceivedTime.hashCode());
result = prime * result + ((srcPortState == null) ? 0 : lastLldpReceivedTime.hashCode()); result = prime * result + ((srcPortState == null) ? 0 : srcPortState.hashCode());
result = prime * result + ((dstPortState == null) ? 0 : dstPortState.hashCode()); result = prime * result + ((dstPortState == null) ? 0 : dstPortState.hashCode());
return result; return result;
} }
......
...@@ -616,7 +616,7 @@ public class TopologyManager implements ...@@ -616,7 +616,7 @@ public class TopologyManager implements
floodlightProvider.addHAListener(this); floodlightProvider.addHAListener(this);
addRestletRoutable(); addRestletRoutable();
} }
protected void addRestletRoutable() { protected void addRestletRoutable() {
restApi.addRestletRoutable(new TopologyWebRoutable()); restApi.addRestletRoutable(new TopologyWebRoutable());
} }
...@@ -624,31 +624,35 @@ public class TopologyManager implements ...@@ -624,31 +624,35 @@ public class TopologyManager implements
// **************** // ****************
// Internal methods // Internal methods
// **************** // ****************
protected Command dropFilter(IOFSwitch sw, OFPacketIn pi, /**
* If the packet-in switch port is disabled for all data traffic, then
* the packet will be dropped. Otherwise, the packet will follow the
* normal processing chain.
* @param sw
* @param pi
* @param cntx
* @return
*/
protected Command dropFilter(long sw, OFPacketIn pi,
FloodlightContext cntx) { FloodlightContext cntx) {
Command result = Command.CONTINUE; Command result = Command.CONTINUE;
Ethernet eth = short port = pi.getInPort();
IFloodlightProviderService.bcStore.
get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
if (isAllowed(sw.getId(), pi.getInPort()) == false) { // If the input port is not allowed for data traffic, drop everything.
if (eth.getEtherType() == Ethernet.TYPE_BDDP || // BDDP packets will not reach this stage.
(eth.isBroadcast() == false && eth.isMulticast() == false)) { if (isAllowed(sw, port) == false) {
result = Command.CONTINUE; if (log.isTraceEnabled()) {
} else { log.trace("Ignoring packet because of topology " +
if (log.isTraceEnabled()) { "restriction on switch={}, port={}", sw, port);
log.trace("Ignoring packet because of topology " +
"restriction on switch={}, port={}",
new Object[] {sw.getStringId(),
pi.getInPort()});
}
result = Command.STOP; result = Command.STOP;
} }
} }
// if sufficient information is available, then drop broadcast
// packets here as well.
return result; return result;
} }
/** /**
* TODO This method must be moved to a layer below forwarding * TODO This method must be moved to a layer below forwarding
* so that anyone can use it. * so that anyone can use it.
...@@ -723,9 +727,10 @@ public class TopologyManager implements ...@@ -723,9 +727,10 @@ public class TopologyManager implements
TopologyInstance ti = getCurrentInstance(false); TopologyInstance ti = getCurrentInstance(false);
Set<Long> switches = ti.getSwitchesInOpenflowDomain(pinSwitch); Set<Long> switches = ti.getSwitchesInOpenflowDomain(pinSwitch);
if (switches == null) // this implies that there are no links connected to the switches if (switches == null)
{ {
// indicates no links are connected to the switches
switches = new HashSet<Long>(); switches = new HashSet<Long>();
switches.add(pinSwitch); switches.add(pinSwitch);
} }
...@@ -774,9 +779,7 @@ public class TopologyManager implements ...@@ -774,9 +779,7 @@ public class TopologyManager implements
if (eth.getEtherType() == Ethernet.TYPE_BDDP) { if (eth.getEtherType() == Ethernet.TYPE_BDDP) {
doFloodBDDP(sw.getId(), pi, cntx); doFloodBDDP(sw.getId(), pi, cntx);
} else { } else {
// if the packet is BDDP, then send flood it on all the external return dropFilter(sw.getId(), pi, cntx);
// switch ports in the same openflow domain.
return dropFilter(sw, pi, cntx);
} }
return Command.STOP; return Command.STOP;
} }
...@@ -823,7 +826,7 @@ public class TopologyManager implements ...@@ -823,7 +826,7 @@ public class TopologyManager implements
update.getDst(), update.getDstPort()); update.getDst(), update.getDstPort());
updateApplied = true; updateApplied = true;
} }
if (updateApplied) { if (updateApplied) {
appliedUpdates.add(newUpdate); appliedUpdates.add(newUpdate);
} }
......
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