Bug 5005: Send Map-Notify to all affected xTRs 93/32993/2
authorLorand Jakab <lojakab@cisco.com>
Tue, 19 Jan 2016 10:11:07 +0000 (12:11 +0200)
committerLorand Jakab <lojakab@cisco.com>
Wed, 20 Jan 2016 14:04:26 +0000 (16:04 +0200)
When merging is on, when a Map-Register is received send Map-Notify
containing the merged locator set to all xTRs that registered the same
prefix.

Change-Id: I50990371a077d2f405d99f0285e113333c9e2e76
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/dao/SubKeys.java
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/lisp/IFlowMapping.java
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/lisp/IMapNotifyHandler.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/mapcache/SimpleMapCache.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtil.java
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java
mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/serializer/MapRegisterSerializer.java
mappingservice/lisp-proto/src/main/yang/odl-lisp-proto.yang

index cb8f4f12e00204ad4b8b06e4999742d7fcfc3fd2..44e7935b7398abdb25f43aa651da5dd9bf0e6937 100644 (file)
@@ -524,13 +524,13 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
     private MapReply sendMapRegisterTwiceWithDiffrentValues(Eid eid, Rloc rloc1, Rloc rloc2)
             throws SocketTimeoutException {
         MapRegister mb = createMapRegister(eid, rloc1);
-        MapNotify mapNotify = lms.handleMapRegister(mb);
+        MapNotify mapNotify = lms.handleMapRegister(mb).getLeft();
         MapRequest mr = createMapRequest(eid);
         MapReply mapReply = lms.handleMapRequest(mr);
         assertEquals(mb.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc(), mapReply.getMappingRecordItem().get(0).getMappingRecord()
                 .getLocatorRecord().get(0).getRloc());
         mb = createMapRegister(eid, rloc2);
-        mapNotify = lms.handleMapRegister(mb);
+        mapNotify = lms.handleMapRegister(mb).getLeft();
         assertEquals(8, mapNotify.getNonce().longValue());
         mr = createMapRequest(eid);
         sendMapRequest(mr);
index 352428d5f5d8f01464a4d5da91fc5e27106cf619..1b9e8b419f41b547bca889b81f3a877d5631622f 100644 (file)
@@ -20,6 +20,7 @@ public interface SubKeys {
     String RECORD = "address";
     String XTRID_RECORDS = "xtrid";
     String SUBSCRIBERS = "subscribers";
+    String SRC_RLOCS = "src_rlocs";
     String REGDATE = "date";
     String VNI = "vni";
     String LCAF_SRCDST = "lcaf_srcdst";
index be645e04c881956dd33359eda234c025cfd57989..909c66a922e7b5f9b649b1fe6b921a36c414eca4 100644 (file)
@@ -7,10 +7,14 @@
  */
 package org.opendaylight.lispflowmapping.interfaces.lisp;
 
+import java.util.List;
+
+import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
 
 /**
  * The LISP Mapping Service interface
@@ -23,7 +27,7 @@ public interface IFlowMapping {
      *            The map-register message
      * @return a map-notify message, if requested in the map-register or null otherwise
      */
-    MapNotify handleMapRegister(MapRegister mapRegister);
+    Pair<MapNotify, List<TransportAddress>> handleMapRegister(MapRegister mapRegister);
 
     /**
      * Handle southbound map-request
index 25716034bac6000791b383fb63dc0040fda13e00..11595b718774ef1b4cb22e7e2031b96f184b948a 100644 (file)
@@ -7,9 +7,12 @@
  */
 package org.opendaylight.lispflowmapping.interfaces.lisp;
 
+import java.util.List;
+
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
 
 /**
  * An interface for dealing with a map notify message.
@@ -20,8 +23,11 @@ public interface IMapNotifyHandler {
      *
      * @param mapNotify
      *            The map-notify message
+     *
+     * @param rlocs
+     *            A list of RLOCs which need to be notified
      */
-    void handleMapNotify(MapNotify mapNotify);
+    void handleMapNotify(MapNotify mapNotify, List<TransportAddress> rlocs);
 
     /**
      * Handle Solicit Map Request message
index 366bd6b53de0c56289ba121880c796a866ba6f55..e3916bffa42d13f21a380382bfedbd035fd68c52 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.lispflowmapping.implementation;
 
+import java.util.List;
+
 import org.apache.commons.lang3.tuple.MutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
@@ -61,7 +63,7 @@ public class LispMappingService implements IFlowMapping, BindingAwareProvider, I
     private volatile String elpPolicy = ConfigIni.getInstance().getElpPolicy();
 
     private ThreadLocal<MapReply> tlsMapReply = new ThreadLocal<MapReply>();
-    private ThreadLocal<MapNotify> tlsMapNotify = new ThreadLocal<MapNotify>();
+    private ThreadLocal<Pair<MapNotify, List<TransportAddress>>> tlsMapNotify = new ThreadLocal<Pair<MapNotify, List<TransportAddress>>>();
     private ThreadLocal<Pair<MapRequest, TransportAddress>> tlsMapRequest = new ThreadLocal<Pair<MapRequest, TransportAddress>>();
 
     private OdlLispSbService lispSB = null;
@@ -147,7 +149,7 @@ public class LispMappingService implements IFlowMapping, BindingAwareProvider, I
         }
     }
 
-    public MapNotify handleMapRegister(MapRegister mapRegister) {
+    public Pair<MapNotify, List<TransportAddress>> handleMapRegister(MapRegister mapRegister) {
         LOG.debug("DAO: Adding mapping for {}",
                 LispAddressStringifier.getString(mapRegister.getMappingRecordItem().get(0)
                         .getMappingRecord().getEid()));
@@ -158,7 +160,7 @@ public class LispMappingService implements IFlowMapping, BindingAwareProvider, I
         return tlsMapNotify.get();
     }
 
-    public MapNotify handleMapRegister(MapRegister mapRegister, boolean smr) {
+    public Pair<MapNotify, List<TransportAddress>> handleMapRegister(MapRegister mapRegister, boolean smr) {
         LOG.debug("DAO: Adding mapping for {}",
                 LispAddressStringifier.getString(mapRegister.getMappingRecordItem().get(0)
                         .getMappingRecord().getEid()));
@@ -179,17 +181,29 @@ public class LispMappingService implements IFlowMapping, BindingAwareProvider, I
         return shouldAuthenticate;
     }
 
+    private void sendMapNotify(MapNotify mapNotify, TransportAddress address) {
+        SendMapNotifyInputBuilder smnib = new SendMapNotifyInputBuilder();
+        smnib.setMapNotify(new MapNotifyBuilder(mapNotify).build());
+        smnib.setTransportAddress(address);
+        getLispSB().sendMapNotify(smnib.build());
+    }
+
     @Override
     public void onAddMapping(AddMapping mapRegisterNotification) {
-        MapNotify mapNotify = handleMapRegister(mapRegisterNotification.getMapRegister());
+        Pair<MapNotify, List<TransportAddress>> result = handleMapRegister(mapRegisterNotification.getMapRegister());
+        MapNotify mapNotify = result.getLeft();
+        List<TransportAddress> rlocs = result.getRight();
         if (mapNotify != null) {
-            TransportAddressBuilder tab = new TransportAddressBuilder();
-            tab.setIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
-            tab.setPort(new PortNumber(LispMessage.PORT_NUM));
-            SendMapNotifyInputBuilder smnib = new SendMapNotifyInputBuilder();
-            smnib.setMapNotify(new MapNotifyBuilder(mapNotify).build());
-            smnib.setTransportAddress(tab.build());
-            getLispSB().sendMapNotify(smnib.build());
+            if (rlocs == null) {
+                TransportAddressBuilder tab = new TransportAddressBuilder();
+                tab.setIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
+                tab.setPort(new PortNumber(LispMessage.PORT_NUM));
+                sendMapNotify(mapNotify, tab.build());
+            } else {
+                for (TransportAddress ta : rlocs) {
+                    sendMapNotify(mapNotify, ta);
+                }
+            }
         } else {
             LOG.warn("got null map notify");
         }
@@ -241,8 +255,8 @@ public class LispMappingService implements IFlowMapping, BindingAwareProvider, I
     }
 
     @Override
-    public void handleMapNotify(MapNotify notify) {
-        tlsMapNotify.set(notify);
+    public void handleMapNotify(MapNotify notify, List<TransportAddress> rlocs) {
+        tlsMapNotify.set(new MutablePair<MapNotify, List<TransportAddress>>(notify, rlocs));
     }
 
     @Override
index 223f4a6c8e19d679e0df17ea82c0129ae041dcb4..75857aa62316bf8d1685cd58da02c47057a65016 100644 (file)
@@ -13,6 +13,7 @@ import java.net.NetworkInterface;
 import java.net.SocketException;
 import java.util.ArrayList;
 import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -26,11 +27,14 @@ import org.opendaylight.lispflowmapping.interfaces.dao.SubscriberRLOC;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapNotifyHandler;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapServerAsync;
 import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingService;
+import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
 import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
 import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
 import org.opendaylight.lispflowmapping.lisp.util.MapNotifyBuilderHelper;
 import org.opendaylight.lispflowmapping.lisp.util.MapRequestUtil;
 import org.opendaylight.lispflowmapping.lisp.util.SourceDestKeyHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
@@ -42,6 +46,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.ma
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChange;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
@@ -90,6 +96,7 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener {
         authenticate = shouldAuthenticate;
     }
 
+    @SuppressWarnings("unchecked")
     public void handleMapRegister(MapRegister mapRegister) {
         boolean failed = false;
         boolean updated = false;
@@ -130,15 +137,21 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener {
         if (!failed && BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
             LOG.trace("MapRegister wants MapNotify");
             MapNotifyBuilder builder = new MapNotifyBuilder();
+            List<TransportAddress> rlocs = null;
             if (ConfigIni.getInstance().mappingMergeIsSet()) {
-                List<MappingRecordItem> mappings = new ArrayList<MappingRecordItem>();
+                Set<IpAddress> notifyRlocs = new HashSet<IpAddress>();
+                List<MappingRecordItem> mergedMappings = new ArrayList<MappingRecordItem>();
                 for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
                     MappingRecord mapping = record.getMappingRecord();
                     MappingRecord currentRecord = (MappingRecord) mapService.getMapping(MappingOrigin.Southbound,
                             mapping.getEid());
-                    mappings.add(new MappingRecordItemBuilder().setMappingRecord(currentRecord).build());
+                    mergedMappings.add(new MappingRecordItemBuilder().setMappingRecord(currentRecord).build());
+                    Set<IpAddress> sourceRlocs = (Set<IpAddress>) mapService.getData(MappingOrigin.Southbound,
+                            mapping.getEid(), SubKeys.SRC_RLOCS);
+                    notifyRlocs.addAll(sourceRlocs);
                 }
-                MapNotifyBuilderHelper.setFromMapRegisterAndMappingRecordItems(builder, mapRegister, mappings);
+                MapNotifyBuilderHelper.setFromMapRegisterAndMappingRecordItems(builder, mapRegister, mergedMappings);
+                rlocs = getTransportAddresses(notifyRlocs);
             } else {
                 MapNotifyBuilderHelper.setFromMapRegister(builder, mapRegister);
             }
@@ -146,8 +159,19 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener {
                 builder.setAuthenticationData(LispAuthenticationUtil.createAuthenticationData(builder.build(),
                         password));
             }
-            notifyHandler.handleMapNotify(builder.build());
+            notifyHandler.handleMapNotify(builder.build(), rlocs);
+        }
+    }
+
+    private static List<TransportAddress> getTransportAddresses(Set<IpAddress> addresses) {
+        List<TransportAddress> rlocs = new ArrayList<TransportAddress>();
+        for (IpAddress address : addresses) {
+            TransportAddressBuilder tab = new TransportAddressBuilder();
+            tab.setIpAddress(address);
+            tab.setPort(new PortNumber(LispMessage.PORT_NUM));
+            rlocs.add(tab.build());
         }
+        return rlocs;
     }
 
     private SiteId getSiteId(MapRegister mapRegister) {
index b33bf33390ac25500d0f4280aff11ac1113ee0ba..0755030cca97dd712f355a498c25ed8b06d53e7b 100644 (file)
@@ -11,8 +11,10 @@ package org.opendaylight.lispflowmapping.implementation.mapcache;
 import java.util.AbstractMap.SimpleImmutableEntry;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
 import org.opendaylight.lispflowmapping.implementation.util.MappingMergeUtil;
@@ -22,6 +24,7 @@ import org.opendaylight.lispflowmapping.interfaces.dao.MappingEntry;
 import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys;
 import org.opendaylight.lispflowmapping.interfaces.mapcache.IMapCache;
 import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
@@ -114,12 +117,15 @@ public class SimpleMapCache implements IMapCache {
         }
 
         if (ConfigIni.getInstance().mappingMergeIsSet()) {
-            SimpleImmutableEntry<MappingRecord, List<byte[]>> mergedEntry =
-                    MappingMergeUtil.mergeXtrIdMappings(getXtrIdMappingList(xtrIdDao));
-            removeExpiredXtrIdTableEntries(xtrIdDao, mergedEntry.getValue());
-            regdate = new Date(mergedEntry.getKey().getTimestamp());
+            List<byte[]> expiredMappings = new ArrayList<byte[]>();
+            Set<IpAddress> sourceRlocs = new HashSet<IpAddress>();
+            MappingRecord mergedEntry = MappingMergeUtil.mergeXtrIdMappings(getXtrIdMappingList(xtrIdDao),
+                    expiredMappings, sourceRlocs);
+            removeExpiredXtrIdTableEntries(xtrIdDao, expiredMappings);
+            regdate = new Date(mergedEntry.getTimestamp());
             table.put(eid, new MappingEntry<>(SubKeys.REGDATE, regdate));
-            table.put(eid, new MappingEntry<>(SubKeys.RECORD, mergedEntry.getKey()));
+            table.put(eid, new MappingEntry<>(SubKeys.RECORD, mergedEntry));
+            table.put(eid, new MappingEntry<>(SubKeys.SRC_RLOCS, sourceRlocs));
         } else {
             table.put(eid, new MappingEntry<>(SubKeys.REGDATE, regdate));
             table.put(eid, new MappingEntry<>(SubKeys.RECORD, value));
index 0423b5c9bcc49388a32abea2bbe8d2e37e986623..e72bb3c1cf3b48a5e7822546b3d3a1bb3ca1187c 100644 (file)
@@ -7,13 +7,14 @@
  */
 package org.opendaylight.lispflowmapping.implementation.util;
 
-import java.util.AbstractMap.SimpleImmutableEntry;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder;
@@ -127,8 +128,8 @@ public final class MappingMergeUtil {
         return mrb.build();
     }
 
-    public static SimpleImmutableEntry<MappingRecord, List<byte[]>> mergeXtrIdMappings(List<Object> records) {
-        List<byte[]> expiredMappings = new ArrayList<byte[]>();
+    public static MappingRecord mergeXtrIdMappings(List<Object> records, List<byte[]> expiredMappings,
+            Set<IpAddress> sourceRlocs) {
         MappingRecordBuilder mrb = new MappingRecordBuilder((MappingRecord) records.get(0));
         byte[] xtrId = mrb.getXtrId();
         Long timestamp = mrb.getTimestamp();
@@ -151,11 +152,14 @@ public final class MappingMergeUtil {
             // Merge record fields and locators
             mergeCommonMappingRecordFields(mrb, record);
             mergeLocatorRecords(mrb, record);
+
+            // Save source locator for use in Map-Notify
+            sourceRlocs.add(record.getSourceRloc());
         }
         mrb.setXtrId(xtrId);
         mrb.setTimestamp(timestamp);
 
-        return new SimpleImmutableEntry<MappingRecord, List<byte[]>>(mrb.build(), expiredMappings);
+        return mrb.build();
     }
 
     public static boolean timestampIsExpired(Date timestamp) {
index fc6d9bb581acee326c65e2dcba737cd403bbf887..1491db09bc680f5f29f77f8ec19707df87af5839 100644 (file)
@@ -133,7 +133,7 @@ public class MapServerTest extends BaseTestCase {
         addDefaultPutAndGetExpectations(new EidBuilder().setAddressType(NoAddressAfi.class).setAddress(
                 (Address) new NoAddressBuilder().setNoAddress(true).build()).build());
         MapRegister mr = mapRegisterBuilder.build();
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mr);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mr).getLeft();
         assertEquals(mr.getMappingRecordItem(), mapNotify.getMappingRecordItem());
         ArrayAssert.assertEquals(mr.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mr.getKeyId(), mapNotify.getKeyId());
@@ -158,7 +158,7 @@ public class MapServerTest extends BaseTestCase {
 
         addDefaultPutAndGetExpectations(eid);
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterBuilder.build());
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterBuilder.build()).getLeft();
 
         MappingRecord actualEidToLocator = mapNotify.getMappingRecordItem().get(0).getMappingRecord();
         assertEquals(eid, actualEidToLocator.getEid());
@@ -182,7 +182,7 @@ public class MapServerTest extends BaseTestCase {
 
         addDefaultPutAndGetExpectations(newEid);
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mr);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mr).getLeft();
         assertEquals(newEid, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mr.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mr.getMappingRecordItem(), mapNotify.getMappingRecordItem());
@@ -207,7 +207,7 @@ public class MapServerTest extends BaseTestCase {
 
         MapRegister mapRegister = mapRegisterBuilder.build();
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister).getLeft();
         assertEquals(addr, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mapRegister.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mapRegister.getMappingRecordItem(), mapNotify.getMappingRecordItem());
@@ -232,7 +232,7 @@ public class MapServerTest extends BaseTestCase {
 
         MapRegister mapRegister = mapRegisterBuilder.build();
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister).getLeft();
         assertEquals(addr, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mapRegister.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mapRegister.getMappingRecordItem(), mapNotify.getMappingRecordItem());
@@ -256,7 +256,7 @@ public class MapServerTest extends BaseTestCase {
 
         addDefaultPutAndGetExpectations(newEid);
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mr);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mr).getLeft();
         assertEquals(newEid, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mr.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mr.getMappingRecordItem(), mapNotify.getMappingRecordItem());
@@ -279,7 +279,7 @@ public class MapServerTest extends BaseTestCase {
 
         addDefaultPutAndGetExpectations(eid);
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mr);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mr).getLeft();
         assertEquals(eid, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mr.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mr.getMappingRecordItem(), mapNotify.getMappingRecordItem());
@@ -304,7 +304,7 @@ public class MapServerTest extends BaseTestCase {
 
         MapRegister mapRegister = mapRegisterBuilder.build();
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister).getLeft();
         assertEquals(addr, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mapRegister.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mapRegister.getMappingRecordItem(), mapNotify.getMappingRecordItem());
@@ -329,7 +329,7 @@ public class MapServerTest extends BaseTestCase {
 
         MapRegister mapRegister = mapRegisterBuilder.build();
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister).getLeft();
         assertEquals(addr, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mapRegister.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mapRegister.getMappingRecordItem(), mapNotify.getMappingRecordItem());
@@ -354,7 +354,7 @@ public class MapServerTest extends BaseTestCase {
 
         MapRegister mapRegister = mapRegisterBuilder.build();
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister).getLeft();
         assertEquals(addr, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mapRegister.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mapRegister.getMappingRecordItem(), mapNotify.getMappingRecordItem());
@@ -379,7 +379,7 @@ public class MapServerTest extends BaseTestCase {
 
         MapRegister mapRegister = mapRegisterBuilder.build();
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister).getLeft();
         assertEquals(addr, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mapRegister.getAuthenticationData(), mapNotify.getAuthenticationData());
         assertEquals(mapRegister.getMappingRecordItem(), mapNotify.getMappingRecordItem());
@@ -409,7 +409,7 @@ public class MapServerTest extends BaseTestCase {
 
         MapRegister mapRegister = mapRegisterBuilder.build();
 
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegister).getLeft();
         assertEquals(eid, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getEid());
         assertEquals(addr, mapNotify.getMappingRecordItem().get(1).getMappingRecord().getEid());
         ArrayAssert.assertEquals(mapRegister.getAuthenticationData(), mapNotify.getAuthenticationData());
@@ -548,7 +548,7 @@ public class MapServerTest extends BaseTestCase {
         mapRegisterBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlrBuilder.build()).build());
         mapRegisterBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr2Builder.build()).build());
         addDefaultPutAndGetExpectations(address);
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterBuilder.build());
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterBuilder.build()).getLeft();
 
         assertEquals(rloc1, mapNotify.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0)
                 .getRloc());
@@ -563,7 +563,7 @@ public class MapServerTest extends BaseTestCase {
     public void handleMapRegisterIpv4__CheckWrongPassword() throws Exception {
 
         addGetExpectations(LispAddressUtil.asIpv4PrefixEid("153.16.254.1"), 0, 31, "bla");
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterWithAuthentication);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterWithAuthentication).getLeft();
         assertEquals(null, mapNotify);
     }
 
@@ -572,7 +572,7 @@ public class MapServerTest extends BaseTestCase {
 
         addGetExpectations(LispAddressUtil.asIpv4PrefixEid("153.16.254.1"), 0, 25, "password");
         addPutExpectations(LispAddressUtil.asIpv4PrefixEid("153.16.254.1"));
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterWithAuthentication);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterWithAuthentication).getLeft();
         assertEquals(mapRegisterWithAuthentication.getMappingRecordItem(), mapNotify.getMappingRecordItem());
         assertEquals(mapRegisterWithAuthentication.getKeyId(), mapNotify.getKeyId());
         assertEquals(mapRegisterWithAuthentication.getNonce(), mapNotify.getNonce());
@@ -582,7 +582,7 @@ public class MapServerTest extends BaseTestCase {
     public void handleMapRegisterIpv4__CheckNoPassword() throws Exception {
 
         addGetExpectations(LispAddressUtil.asIpv4PrefixEid("153.16.254.1/32"), 30, 0, "password");
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterWithAuthentication);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterWithAuthentication).getLeft();
         assertEquals(null, mapNotify);
     }
 
@@ -590,7 +590,7 @@ public class MapServerTest extends BaseTestCase {
     public void handleMapRegisterIpv4__CheckNoreturn() throws Exception {
 
         addGetExpectations(LispAddressUtil.asIpv4PrefixEid("153.16.254.1/32"));
-        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterWithAuthentication);
+        MapNotify mapNotify = testedMapServer.handleMapRegister(mapRegisterWithAuthentication).getLeft();
         assertEquals(mapNotify, null);
     }
 
index 9b6d258cd18535c1161149d53f4ca87a7e98015c..673350ac288f4738272fac95349c65af48fdab92 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.lispflowmapping.lisp.serializer;
 
+import java.net.Inet4Address;
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
@@ -16,8 +17,9 @@ import org.apache.commons.lang3.BooleanUtils;
 import org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException;
 import org.opendaylight.lispflowmapping.lisp.util.ByteUtil;
 import org.opendaylight.lispflowmapping.lisp.util.NumberUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.IpAddressBinary;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.IpAddressBinaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder;
@@ -136,15 +138,16 @@ public final class MapRegisterSerializer {
 
     }
 
-    private static IpAddressBinary getSourceRloc(InetAddress sourceRloc) {
-        byte[] srcRloc;
+    private static IpAddress getSourceRloc(InetAddress sourceRloc) {
         if (sourceRloc == null) {
-            srcRloc = InetAddress.getLoopbackAddress().getAddress();
-        } else {
-            srcRloc = sourceRloc.getAddress();
+            sourceRloc = InetAddress.getLoopbackAddress();
         }
 
-        return IpAddressBinaryBuilder.getDefaultInstance(srcRloc);
+        if (sourceRloc instanceof Inet4Address) {
+            return new IpAddress(new Ipv4Address(sourceRloc.getHostAddress()));
+        } else {
+            return new IpAddress(new Ipv6Address(sourceRloc.getHostAddress()));
+        }
     }
 
     private interface Flags {
index 8f1cc423185f156dc8d127b5e77878c3d53a8197..935a7c450727f3deb170fd9acf5f6defa590d8bc 100644 (file)
@@ -133,7 +133,7 @@ module odl-lisp-proto {
                 "64 bit site identifier.";
         }
         leaf source-rloc {
-            type ip-address-binary;
+            type inet:ip-address;
             description
                 "The Source IP address used for sending the enclosing control
                  packet in RLOC space.";