Skip to content
Snippets Groups Projects
Commit 98401dcd authored by abat's avatar abat
Browse files

Merge into master from pull request #150:

Minor adjustment to link discovery and add switch broadcast cache to ForwardingBase (https://github.com/floodlight/floodlight/pull/150)
parents 5977b208 35758a7f
No related branches found
No related tags found
No related merge requests found
......@@ -849,7 +849,7 @@ public class LinkDiscoveryManager
// It's probably overkill to send LLDP from all switches, but we don't
// know which switches might be connected to the new switch.
// Need to optimize when supporting a large number of switches.
sendLLDPTask.reschedule(1000, TimeUnit.MILLISECONDS);
sendLLDPTask.reschedule(2000, TimeUnit.MILLISECONDS);
// Update event history
evHistTopoSwitch(sw, EvAction.SWITCH_CONNECTED, "None");
}
......@@ -1379,29 +1379,27 @@ public class LinkDiscoveryManager
ScheduledExecutorService ses = threadPool.getScheduledExecutor();
// To be started by the first switch connection
sendLLDPTask = new SingletonTask(ses, new Runnable() {
@Override
public void run() {
try {
sendLLDPs();
if (!shuttingDown) {
sendLLDPTask.reschedule(lldpFrequency,
TimeUnit.MILLISECONDS);
}
} catch (StorageException e) {
log.error("Storage exception in LLDP send timer; " +
"terminating process", e);
floodlightProvider.terminate();
} catch (Exception e) {
log.error("Exception in LLDP send timer", e);
} finally {
if (!shuttingDown) {
sendLLDPTask.reschedule(lldpFrequency,
TimeUnit.MILLISECONDS);
}
}
}
});
// Setup sending out LLDPs
sendLLDPTask.reschedule(1000, TimeUnit.MILLISECONDS);
Runnable timeoutLinksTimer = new Runnable() {
@Override
public void run() {
......
......@@ -35,7 +35,10 @@ import net.floodlightcontroller.devicemanager.IDevice;
import net.floodlightcontroller.devicemanager.IDeviceListener;
import net.floodlightcontroller.devicemanager.IDeviceService;
import net.floodlightcontroller.devicemanager.SwitchPort;
import net.floodlightcontroller.packet.ARP;
import net.floodlightcontroller.packet.Ethernet;
import net.floodlightcontroller.packet.IPacket;
import net.floodlightcontroller.packet.IPv4;
import net.floodlightcontroller.routing.IRoutingService;
import net.floodlightcontroller.routing.IRoutingDecision;
import net.floodlightcontroller.routing.Link;
......@@ -50,6 +53,7 @@ import org.openflow.protocol.OFPacketIn;
import org.openflow.protocol.OFPacketOut;
import org.openflow.protocol.OFPort;
import org.openflow.protocol.OFType;
import org.openflow.protocol.OFPacketIn.OFPacketInReason;
import org.openflow.protocol.action.OFAction;
import org.openflow.protocol.action.OFActionOutput;
import org.openflow.util.HexString;
......@@ -72,6 +76,7 @@ public abstract class ForwardingBase implements
protected ICounterStoreService counterStore;
// for broadcast loop suppression
protected boolean broadcastCacheFeature = true;
public final int prime = 2633; // for hash calculation
public TimedCache<Long> broadcastCache =
new TimedCache<Long>(100, 5*1000); // 5 seconds interval;
......@@ -79,7 +84,8 @@ public abstract class ForwardingBase implements
// flow-mod - for use in the cookie
public static final int FORWARDING_APP_ID = 2; // TODO: This must be managed
// by a global APP_ID class
public long appCookie = AppCookie.makeCookie(FORWARDING_APP_ID, 0);
// Comparator for sorting by SwitchCluster
public Comparator<SwitchPort> clusterIdComparator =
new Comparator<SwitchPort>() {
......@@ -441,12 +447,16 @@ public abstract class ForwardingBase implements
// Get the hash of the Ethernet packet.
if (sw == null) return true;
// If the feature is disabled, always return false;
if (!broadcastCacheFeature) return false;
Ethernet eth =
IFloodlightProviderService.bcStore.get(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
Long broadcastHash;
broadcastHash = sw.getId() * prime + eth.hashCode();
broadcastHash = topology.getL2DomainId(sw.getId())
* prime + eth.hashCode();
if (broadcastCache.update(broadcastHash)) {
sw.updateBroadcastCache(broadcastHash, pi.getInPort());
return true;
......@@ -455,11 +465,27 @@ public abstract class ForwardingBase implements
}
}
protected boolean isInSwitchBroadcastCache(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
if (sw == null) return true;
// If the feature is disabled, always return false;
if (!broadcastCacheFeature) return false;
// Get the hash of the Ethernet packet.
Ethernet eth =
IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
// some FORWARD_OR_FLOOD packets are unicast with unknown destination mac
// if (eth.isBroadcast() || eth.isMulticast())
return sw.updateBroadcastCache(new Long(eth.hashCode()), pi.getInPort());
// return false;
}
public static boolean
blockHost(IFloodlightProviderService floodlightProvider,
SwitchPort sw_tup, long host_mac,
short hardTimeout) {
short hardTimeout, long cookie) {
if (sw_tup == null) {
return false;
......@@ -483,7 +509,7 @@ public abstract class ForwardingBase implements
.setInputPort((short)inputPort)
.setWildcards(OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_DL_SRC
& ~OFMatch.OFPFW_IN_PORT);
fm.setCookie(AppCookie.makeCookie(FORWARDING_APP_ID, 0))
fm.setCookie(cookie)
.setHardTimeout((short) hardTimeout)
.setIdleTimeout((short) 5)
.setBufferId(OFPacketOut.BUFFER_ID_NONE)
......
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