Skip to content
Snippets Groups Projects
Commit dea38f15 authored by Ananth Suryanarayana's avatar Ananth Suryanarayana
Browse files

Merge pull request #260 from rombie/master

Add input port as additional field for packet hash computation
Auto-merging due to circular dependency with other repo
parents 1c08bea7 503ec6ef
No related branches found
No related tags found
No related merge requests found
......@@ -8,3 +8,5 @@
target
thrift
logback.xml
*.swp
*.pyc
......@@ -329,6 +329,8 @@ public class Ethernet extends BasePacket {
int result = super.hashCode();
result = prime * result + destinationMACAddress.hashCode();
result = prime * result + etherType;
result = prime * result + vlanID;
result = prime * result + priorityCode;
result = prime * result + (pad ? 1231 : 1237);
result = prime * result + sourceMACAddress.hashCode();
return result;
......
......@@ -70,7 +70,8 @@ public abstract class ForwardingBase implements
// for broadcast loop suppression
protected boolean broadcastCacheFeature = true;
public final int prime = 2633; // for hash calculation
public final int prime1 = 2633; // for hash calculation
public final static int prime2 = 4357; // for hash calculation
public TimedCache<Long> broadcastCache =
new TimedCache<Long>(100, 5*1000); // 5 seconds interval;
......@@ -506,8 +507,8 @@ public abstract class ForwardingBase implements
IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
Long broadcastHash;
broadcastHash = topology.getL2DomainId(sw.getId())
* prime + eth.hashCode();
broadcastHash = topology.getL2DomainId(sw.getId()) * prime1 +
pi.getInPort() * prime2 + eth.hashCode();
if (broadcastCache.update(broadcastHash)) {
sw.updateBroadcastCache(broadcastHash, pi.getInPort());
return true;
......@@ -521,16 +522,15 @@ public abstract class ForwardingBase implements
// 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());
long hash = pi.getInPort() * prime2 + eth.hashCode();
// return false;
// some FORWARD_OR_FLOOD packets are unicast with unknown destination mac
return sw.updateBroadcastCache(hash, pi.getInPort());
}
public static boolean
......
File added
File added
File added
File added
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