From 1bc28ca2234ec1bfbd3c6fcd4d5476d479a7f52d Mon Sep 17 00:00:00 2001
From: Srinivasan Ramasubramanian <srini@bigswitch.com>
Date: Thu, 7 Jun 2012 21:04:56 -0700
Subject: [PATCH] When sending LLDPs and BDDPs from all the switches, send
 LLDPs first and then BDDPs. This would enable direct links to be detected
 first and reduced instability.

---
 .../internal/LinkDiscoveryManager.java           | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
index 36aa4fce0..63919095b 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -346,24 +346,22 @@ public class LinkDiscoveryManager
 
     }
 
-    protected void sendLLDPs(SwitchPortTuple swt) {
+    protected void sendLLDPs(SwitchPortTuple swt, boolean isStandard) {
         IOFSwitch sw = swt.getSw();
 
         if (sw == null) return;
 
         OFPhysicalPort port = sw.getPort(swt.getPort());
         if (port != null) {
-            sendLLDPs(sw, port, true);
-            sendLLDPs(sw, port, false);
+            sendLLDPs(sw, port, isStandard);
         }
     }
 
-    protected void sendLLDPs(IOFSwitch sw) {
+    protected void sendLLDPs(IOFSwitch sw, boolean isStandard) {
     	
         if (sw.getEnabledPorts() != null) {
             for (OFPhysicalPort port : sw.getEnabledPorts()) {
-                sendLLDPs(sw, port, true);
-                sendLLDPs(sw, port, false);
+                sendLLDPs(sw, port, isStandard);
             }
         }
         sw.flush();
@@ -377,7 +375,11 @@ public class LinkDiscoveryManager
         Map<Long, IOFSwitch> switches = floodlightProvider.getSwitches();
         for (Entry<Long, IOFSwitch> entry : switches.entrySet()) {
             IOFSwitch sw = entry.getValue();
-            sendLLDPs(sw);
+            sendLLDPs(sw, true);
+        }
+        for (Entry<Long, IOFSwitch> entry : switches.entrySet()) {
+            IOFSwitch sw = entry.getValue();
+            sendLLDPs(sw, false);
         }
     }
 
-- 
GitLab