Merge "Bug 6051: Temporarly disable Neutron in build"
authorVina Ermagan <vermagan@cisco.com>
Tue, 14 Jun 2016 06:42:11 +0000 (06:42 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 14 Jun 2016 06:42:11 +0000 (06:42 +0000)
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundHandler.java

index af92027a9c57d75611b0c41055267055382cb9d4..97406d3dafb848af1fe7628dc40779b5ec43c329 100644 (file)
@@ -283,21 +283,30 @@ public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramP
     }
 
     private void sendMapNotifyMsg(final ByteBuffer inBuffer, final InetAddress inetAddress, int portNumber,
-                                  List<EidLispAddress> cacheValue) {
+                                  List<EidLispAddress> eids) {
 
-        final String authKey = provideAuthenticateKey(cacheValue);
+        if (eids == null) {
+            LOG.warn("Map-Register Cache: missing EID list when trying to send Map-Notify!");
+            return;
+        }
+
+        final MappingAuthkey authKey = provideAuthenticateKey(eids);
         if (authKey != null) {
             ByteBuffer outBuffer = transformMapRegisterToMapNotify(inBuffer);
-            outBuffer = calculateAndSetNewMAC(outBuffer, authKey);
+            if (authKey.getKeyType() != 0) {
+                outBuffer = calculateAndSetNewMAC(outBuffer, authKey.getKeyString());
+            }
             outBuffer.position(0);
             lispSbPlugin.handleSerializedLispBuffer(inetAddress, outBuffer, MessageType.MapNotify, portNumber);
+        } else {
+            LOG.error("Map-Register Cache: authentication succeeded, but can't find auth key for sending Map-Notify");
         }
     }
 
     /**
      * Returns null if not all of eids have the same value of authentication key
      */
-    private String provideAuthenticateKey(final List<EidLispAddress> eidLispAddresses) {
+    private MappingAuthkey provideAuthenticateKey(final List<EidLispAddress> eidLispAddresses) {
         MappingAuthkey firstAuthKey = null;
         for (int i = 0; i < eidLispAddresses.size(); i++) {
             final Eid eid = eidLispAddresses.get(i).getEid();
@@ -310,7 +319,7 @@ public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramP
                 }
             }
         }
-        return firstAuthKey.getKeyString();
+        return firstAuthKey;
 
     }