From a04b78eb4121c77f2fe3a6f4d1a4ef141bbafb27 Mon Sep 17 00:00:00 2001
From: Srinivasan Ramasubramanian <srini@bigswitch.com>
Date: Thu, 22 Mar 2012 16:57:31 -0700
Subject: [PATCH] If the attachment point of device moves too fast from a
 non-broadcast domain switch port to a broadcast domain switch port, ignore
 learning and stop processing the packets.

---
 .../internal/DeviceManagerImpl.java           | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
index 50fe56492..96d54893b 100755
--- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
@@ -855,6 +855,31 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
             updateDevice = device.shouldWriteLastSeenToStorage();
             attachmentPoint = device.getAttachmentPoint(switchPort);
 
+            // If the attachment point moves from a non-broadcast domain
+            // port to a broadcast domain port too quickly, ignore learning
+            // the broadcast domain attachment point.
+            if (attachmentPoint != null) {
+                // if the two switches are in the same cluster
+                // and if currSw,CurrPort is not in broadcast domain
+                long currSw = attachmentPoint.getSwitchPort().getSw().getId();
+                short currPort = attachmentPoint.getSwitchPort().getPort();
+                long newSw = switchPort.getSw().getId();
+                short newPort = switchPort.getPort();
+                if (topology.getSwitchClusterId(currSw) == topology.getSwitchClusterId(newSw)) {
+                    if (topology.isBroadcastDomainPort(currSw, currPort) == false) {
+                        if (topology.isBroadcastDomainPort(newSw, newPort) == true) {
+                            // only if the last seen
+                            if (currentDate.getTime() -
+                                    attachmentPoint.getLastSeen().getTime() < 5000) {
+                                // if the packet was seen within the last 5 seconds, we should ignore.
+                                // it should also ignore processing the packet.
+                                return Command.STOP;
+                            }
+                        }
+                    }
+                }
+            }
+
             if (isGratArp(eth)) {
                 clearAttachmentPoints = true;
             }
-- 
GitLab