SMR parent prefix
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / lisp / MapResolver.java
index 535e0ba918d87a8422bf43d13d1fb3eace211c66..8c5cda5911819ffa619ae0875c2b5545bc51435e 100644 (file)
@@ -112,20 +112,22 @@ public class MapResolver implements IMapResolverAsync {
         for (EidItem eidRecord : request.getEidItem()) {
             MappingData mappingData = mapService.getMapping(srcEid, eidRecord.getEid());
             MappingRecord mapping;
-            if (mappingData != null) {
+            if (mappingData == null) {
+                mapping = getNegativeMapping(eidRecord.getEid());
+                mapService.addMapping(MappingOrigin.Southbound, mapping.getEid(), null, new MappingData(mapping));
+            } else {
                 mapping = mappingData.getRecord();
-                if (itrRlocs != null && itrRlocs.size() != 0) {
-                    if (subscriptionService) {
-                        final Rloc resolvedRloc = resolveRloc(itrRlocs, sourceRloc);
-                        updateSubscribers(resolvedRloc, eidRecord.getEid(), mapping.getEid(),
-                                srcEid, mapping.getRecordTtl());
-                    }
-                    mapping = updateLocators(mapping, itrRlocs);
+            }
+
+            if (itrRlocs != null && itrRlocs.size() != 0) {
+                if (subscriptionService) {
+                    final Rloc resolvedRloc = resolveRloc(itrRlocs, sourceRloc);
+                    updateSubscribers(resolvedRloc, eidRecord.getEid(), mapping.getEid(),
+                            srcEid, mapping.getRecordTtl());
                 }
-                mapping = fixIfNotSDRequest(mapping, eidRecord.getEid());
-            } else {
-                mapping = getNegativeMapping(eidRecord.getEid());
+                mapping = updateLocators(mapping, itrRlocs);
             }
+            mapping = fixIfNotSDRequest(mapping, eidRecord.getEid());
             replyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mapping).build());
         }
         requestHandler.handleMapReply(replyBuilder.build());