Bug 5327 - LLDP spoof warning in 3-node cluster 03/34503/1
authorAnil Vishnoi <vishnoianil@gmail.com>
Thu, 11 Feb 2016 19:32:57 +0000 (11:32 -0800)
committerAnil Vishnoi <vishnoianil@gmail.com>
Thu, 11 Feb 2016 19:40:52 +0000 (19:40 +0000)
Change-Id: I0bb970d9de99a162dd5f09ae8376151755da617d
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
applications/topology-lldp-discovery/src/main/config/default-config.xml
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtils.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/lldp/discovery/impl/rev150530/TopologyLldpDiscoveryImplModule.java
applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-impl.yang

index f91c773a7764d751812f2b77615c267dada1e22b..cf7005a47b79787b961807533ca6e952b253f724 100644 (file)
@@ -26,6 +26,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
             <name>binding-osgi-broker</name>
           </broker>
+          <lldp-secure-key>aa9251f8-c7c0-4322-b8d6-c3a84593bda3</lldp-secure-key>
         </module>
       </modules>
     </data>
index f73eb0b35be74adf11ee4d0ef99fabc05797c32f..79f100fa0730915b80b8aa0238055afe28efc8fe 100644 (file)
@@ -17,6 +17,11 @@ import org.slf4j.LoggerFactory;
 public class LLDPActivator implements BindingAwareProvider, AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(LLDPActivator.class);
     private static LLDPDiscoveryProvider provider = new LLDPDiscoveryProvider();
+    private static String lldpSecureKey;
+
+    public LLDPActivator(String secureKey) {
+        lldpSecureKey = secureKey;
+    }
 
     public void onSessionInitiated(final ProviderContext session) {
         DataProviderService dataService = session.<DataProviderService>getSALService(DataProviderService.class);
@@ -36,4 +41,8 @@ public class LLDPActivator implements BindingAwareProvider, AutoCloseable {
             }
         }
     }
+
+    public static String getLldpSecureKey() {
+        return lldpSecureKey;
+    }
 }
index da14b4e71d0afde604e69a7ec31daf5e0685f2c7..8112bcc2df886f11d3f062f0b7f18d2ba60e2052 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.controller.liblldp.NetUtils;
 import com.google.common.hash.Hasher;
 import com.google.common.hash.Hashing;
 import com.google.common.hash.HashFunction;
+import org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -127,7 +128,14 @@ public class LLDPDiscoveryUtils {
      * @throws NoSuchAlgorithmException
      */
     public static byte[] getValueForLLDPPacketIntegrityEnsuring(final NodeConnectorId nodeConnectorId) throws NoSuchAlgorithmException {
-        final String pureValue = nodeConnectorId+ManagementFactory.getRuntimeMXBean().getName();
+        String finalKey;
+        if(LLDPActivator.getLldpSecureKey() !=null && !LLDPActivator.getLldpSecureKey().isEmpty()) {
+            finalKey = LLDPActivator.getLldpSecureKey();
+        } else {
+            finalKey = ManagementFactory.getRuntimeMXBean().getName();
+        }
+        final String pureValue = nodeConnectorId + finalKey;
+
         final byte[] pureBytes = pureValue.getBytes();
         HashFunction hashFunction = Hashing.md5();
         Hasher hasher = hashFunction.newHasher();
index 0db029e5b2570c509dd9e3231db9a94c768e1c89..eed30f9e4134febf29c2172e6e2efa8a5cf0eb37 100644 (file)
@@ -18,7 +18,7 @@ public class TopologyLldpDiscoveryImplModule extends org.opendaylight.yang.gen.v
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        LLDPActivator provider = new LLDPActivator();
+        LLDPActivator provider = new LLDPActivator(getLldpSecureKey());
         getBrokerDependency().registerProvider(provider);
         return provider;
     }
index 547392bfa314d96cb539b40970ed839a9472aa0f..709da19ae0d180c4706eb907ef6f736fb6181834 100644 (file)
@@ -30,6 +30,10 @@ module topology-lldp-discovery-impl {
                     }
                 }
             }
+            leaf lldp-secure-key {
+                description "Provided key will be used to generate LLDP custom security hash";
+                type string;
+            }
         }
     }
 }