Bug 8112: IT: send SMR-invoked Map-Request on SMR 86/54186/8
authorLorand Jakab <lojakab@cisco.com>
Fri, 31 Mar 2017 11:40:45 +0000 (14:40 +0300)
committerLorand Jakab <lojakab@cisco.com>
Tue, 15 Aug 2017 06:13:15 +0000 (09:13 +0300)
Change-Id: I3458ef941460ad5af91ef097c16f17894f5bbfa9
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java
integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MultiSiteScenario.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapResolver.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java

index 68caed3e6cb27f5a5739737987fdb55558f6bca0..1c0ff00b0ca9d5a705ce7bb833922907730979ab 100644 (file)
@@ -173,7 +173,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
 
     public static final String ODL = "org.opendaylight.controller";
     public static final String YANG = "org.opendaylight.yangtools";
-    private static final int MULTI_SITE_SLEEP_TIME = 1;
+    private static final int MULTI_SITE_SLEEP_TIME = 2;
     private static final int MAX_NOTIFICATION_RETRYS = 20;
     private static final MappingAuthkey NULL_AUTH_KEY = new MappingAuthkeyBuilder().setKeyType(0).build();
 
@@ -703,7 +703,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
         multiSiteScenario.assertPingFails(SITE_A, 1, SITE_C, 4);
 
         //TEST CASE 2
-        //following action should trigger generatting of SMR messages:
+        //following action should trigger generating of SMR messages:
         // 1) 192.0.2.5/32
         // 2) 192.0.1.1/32
         multiSiteScenario.storeNorthMappingSrcDst(SITE_A, SITE_C);
@@ -714,7 +714,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
         multiSiteScenario.assertPingFails(SITE_D4, 5, SITE_C, 4);
 
         //TEST CASE 3
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.2.5/32
         // 2) 192.0.1.1/32
         // 3) 192.0.1.5/32
@@ -727,76 +727,87 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
         multiSiteScenario.assertPingWorks(SITE_D4, 5, SITE_C, 4);
 
         //TEST CASE 4
-        // following action should trigger generatting of SMR messages:
-        // 1) 192.0.4.5/32
+        // following action should trigger generating of SMR messages:
+        // 1) 192.0.2.5/32
+        // 2) 192.0.1.1/32
+        // 3) 192.0.1.5/32
+        // 4) 192.0.4.5/32
         multiSiteScenario.storeNorthMappingSrcDst(SITE_B, SITE_C_RLOC_10);
         sleepForSeconds(MULTI_SITE_SLEEP_TIME);
-        multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D4.getHost(5));
+        multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B.getHost(5), SITE_A.getHost(1),
+                SITE_A.getHost(5), SITE_D4.getHost(5));
         //way of testing ping - get RLOC for mapping src-dst and compare it with awaited value doesn't test
         //that ping won't be successfull
         multiSiteScenario.assertPingFails(SITE_B, 5, SITE_C, 4);
 
         //TEST CASE 5
-        // following action should trigger generatting of SMR messages:
-        // 1) 192.0.4.5/32
-        // 2) 192.0.2.5/32
+        // following action should trigger generating of SMR messages:
+        // 1) 192.0.2.5/32
+        // 2) 192.0.1.1/32
+        // 3) 192.0.1.5/32
+        // 4) 192.0.4.5/32
         multiSiteScenario.storeNorthMappingNegative(SITE_C, Action.Drop);
         sleepForSeconds(MULTI_SITE_SLEEP_TIME);
-        multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D4.getHost(5), SITE_B.getHost(5));
+        multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B.getHost(5), SITE_A.getHost(1),
+                SITE_A.getHost(5), SITE_D4.getHost(5));
         multiSiteScenario.assertPingFails(SITE_D4, 5, SITE_C, 4);
 
         //TEST CASE 6
         multiSiteScenario.assertPingFails(SITE_D5, 5, SITE_C, 3);
 
         //TEST CASE 7
-        multiSiteScenario.deleteNorthMapingSrcDst(SITE_A, SITE_C);
-        sleepForSeconds(MULTI_SITE_SLEEP_TIME);
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.4.5/32
         // 2) 192.0.2.5/32
         // 3) 192.0.5.5/32
+        // 4) 192.0.1.5/32
+        // 5) 192.0.1.1/32
+        multiSiteScenario.deleteNorthMapingSrcDst(SITE_A, SITE_C);
+        sleepForSeconds(MULTI_SITE_SLEEP_TIME);
         multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D5.getHost(5), SITE_D4.getHost(5),
-                SITE_B.getHost(5));
+                SITE_B.getHost(5), SITE_A.getHost(1), SITE_A.getHost(5));
 
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.4.5/32
         // 2) 192.0.2.5/32
         // 3) 192.0.5.5/32
+        // 4) 192.0.1.5/32
+        // 5) 192.0.1.1/32
         multiSiteScenario.storeNorthMappingSrcDst(SITE_B, SITE_C);
         sleepForSeconds(MULTI_SITE_SLEEP_TIME);
         multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D5.getHost(5), SITE_D4.getHost(5),
-                SITE_B.getHost(5));
+                SITE_B.getHost(5), SITE_A.getHost(1), SITE_A.getHost(5));
 
         multiSiteScenario.assertPingWorks(SITE_A, 5, SITE_B, 4);
         multiSiteScenario.assertPingWorks(SITE_B, 5, SITE_C, 4);
         multiSiteScenario.assertPingFails(SITE_A, 1, SITE_C, 4);
 
         //TEST CASE 8
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.4.5/32
         // 2) 192.0.2.5/32
         // 3) 192.0.5.5/32
-        // 4) 192.0.1.1/32
+        // 4) 192.0.1.5/32
+        // 5) 192.0.1.1/32
         multiSiteScenario.deleteNorthMapingSrcDst(SITE_B, SITE_C);
         sleepForSeconds(MULTI_SITE_SLEEP_TIME);
         multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D5.getHost(5), SITE_D4.getHost(5),
-                SITE_B.getHost(5),
-                SITE_A.getHost(1));
+                SITE_B.getHost(5), SITE_A.getHost(1), SITE_A.getHost(5));
         multiSiteScenario.assertPingWorks(SITE_A, 5, SITE_B, 4);
         multiSiteScenario.assertPingFails(SITE_B, 5, SITE_C, 4);
         multiSiteScenario.assertPingFails(SITE_A, 1, SITE_C, 4);
 
         //TEST CASE 9
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.4.5/32
         // 2) 192.0.2.5/32
         // 3) 192.0.5.5/32
-        // 4) 192.0.1.1/32
+        // 4) 192.0.1.5/32
+        // 5) 192.0.1.1/32
         multiSiteScenario.deleteNorthMappingNegative(SITE_C);
         sleepForSeconds(MULTI_SITE_SLEEP_TIME);
         multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D5.getHost(5), SITE_D4.getHost(5),
-                SITE_B.getHost(5),
-                SITE_A.getHost(1));
+                SITE_B.getHost(5), SITE_A.getHost(1), SITE_A.getHost(5));
         multiSiteScenario.assertPingWorks(SITE_A, 5, SITE_B, 4);
         multiSiteScenario.assertPingWorks(SITE_B, 5, SITE_C, 4);
         multiSiteScenario.assertPingWorks(SITE_A, 5, SITE_C, 4);
@@ -831,14 +842,14 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
         multiSiteScenario.assertPingWorks(SITE_B_SB, 5, SITE_C_WP_50_2_SB, 4, SITE_D_WP_50_2_SB);
 
         //TEST CASE 2
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.2.5/32
         // 2) 192.0.1.5/32
         multiSiteScenario.storeNorthMappingSrcDst(SITE_A_SB, SITE_C_WP_50_2_SB, SITE_D_WP_50_2_SB);
         sleepForSeconds(MULTI_SITE_SLEEP_TIME);
         multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
 
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.2.5/32
         // 2) 192.0.1.5/32
         multiSiteScenario.storeNorthMappingNegative(SITE_C_SB, Action.Drop);
@@ -850,7 +861,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
 
 
         //TEST CASE 3
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.2.5/32
         // 2) 192.0.1.5/32
         multiSiteScenario.storeNorthMappingSrcDst(SITE_A_SB, SITE_C_WP_50_2_SB);
@@ -861,7 +872,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
         //TEST CASE 4
         multiSiteScenario.storeNorthMappingSrcDst(SITE_B_SB, SITE_C_WP_50_2_SB, SITE_D_WP_50_2_SB);
         sleepForSeconds(MULTI_SITE_SLEEP_TIME);
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.2.5/32
         // 2) 192.0.1.5/32
         multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
@@ -870,7 +881,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
         //TEST CASE 5
         multiSiteScenario.deleteSouthboundMappings(SITE_D_DELETE_SB);
         sleepForSeconds(MULTI_SITE_SLEEP_TIME);
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.2.5/32
         // 2) 192.0.1.5/32
         multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
@@ -880,7 +891,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
         //TEST CASE 6
         multiSiteScenario.deleteNorthMapingSrcDst(SITE_A_SB, SITE_C_WP_50_2_SB);
         sleepForSeconds(MULTI_SITE_SLEEP_TIME);
-        // following action should trigger generatting of SMR messages:
+        // following action should trigger generating of SMR messages:
         // 1) 192.0.2.5/32
         // 2) 192.0.1.5/32
         multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
index bde37275f61f086d4730ef4541b28f060ad5c15d..6b6ddbd0badfa8a8fddc27b6433e50a4c4c78ec9 100644 (file)
@@ -30,10 +30,12 @@ import org.opendaylight.lispflowmapping.lisp.serializer.MapRequestSerializer;
 import org.opendaylight.lispflowmapping.lisp.type.MappingData;
 import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
 import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
+import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary;
 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.SiteId;
@@ -169,6 +171,55 @@ class MultiSiteScenario {
         return lms.handleMapRequest(mapRequestBuilder.build());
     }
 
+    /**
+     * This method expects a SMR Map-Request as input, which it will turn into a SMR-invoked Map-Request and use the
+     * LISP mapping service to send it
+     *
+     * @param mapRequest the SMR Map-Request
+     */
+    private void emitSMRInvokedMapRequestMessage(MapRequest mapRequest) {
+        if (mapRequest.getEidItem().isEmpty()) {
+            fail("Empty SMR received!");
+        }
+
+        Eid srcEid = addMaximumPrefixIfNecessary(mapRequest.getSourceEid().getEid());
+        final EidItemBuilder eidItemBuilder = new EidItemBuilder();
+        eidItemBuilder.setEid(srcEid);
+        eidItemBuilder.setEidItemId(LispAddressStringifier.getString(srcEid));
+        final List<EidItem> eidItem = Collections.singletonList(eidItemBuilder.build());
+
+        final MapRequestBuilder mapRequestBuilder = new MapRequestBuilder(mapRequest);
+        mapRequestBuilder.setSmr(false);
+        mapRequestBuilder.setSmrInvoked(true);
+        mapRequestBuilder.setItrRloc(prepareDummyItrRloc());
+        mapRequestBuilder.setEidItem(eidItem);
+        for (EidItem ei : mapRequest.getEidItem()) {
+            mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(ei.getEid()).build());
+            LOG.debug("Sending SMR-invoked Map-Reqeust for EID {}, Source EID {}",
+                    LispAddressStringifier.getString(srcEid),
+                    LispAddressStringifier.getString(ei.getEid()));
+            lms.handleMapRequest(mapRequestBuilder.build());
+        }
+    }
+
+    /*
+     * Since the Source EID field from a Map-Request packet does not have a prefix length field, IPv4 and IPv6 addresses
+     * are serialized into Ipv4Binary and Ipv6Binary objects. However, when we want to use the addresses in a
+     * SMR-invoked Map-Request, we need to use an Ipv4PrefixBinary or Ipv6PrefixBinary object respectively, since that's
+     * what the EID item field would be deserialized into.
+     */
+    private static Eid addMaximumPrefixIfNecessary(Eid eid) {
+        Address address = eid.getAddress();
+        if (address instanceof Ipv4Binary) {
+            return LispAddressUtil.asIpv4PrefixBinaryEid(
+                    eid, ((Ipv4Binary) address).getIpv4Binary().getValue(), MaskUtil.IPV4_MAX_MASK);
+        } else if (address instanceof Ipv6Binary) {
+            return LispAddressUtil.asIpv6PrefixBinaryEid(
+                    eid, ((Ipv6Binary) address).getIpv6Binary().getValue(), MaskUtil.IPV6_MAX_MASK);
+        }
+        return eid;
+    }
+
     private List<ItrRloc> prepareDummyItrRloc() {
         List<ItrRloc> itrRlocs = new ArrayList<>();
         final ItrRlocBuilder itrRlocBuilder = new ItrRlocBuilder();
@@ -490,6 +541,7 @@ class MultiSiteScenario {
             final List<EidItem> currentEidItems = mapRequest.getEidItem();
             assertNotNull(currentEidItems);
             assertTrue(SMRContainsExpectedEid(eids, currentEidItems));
+            emitSMRInvokedMapRequestMessage(mapRequest);
         }
         //all expected eids should be after looping via mapRequests matched.
         assertTrue("Expected eids wasn't/weren't found " + eids, eids.isEmpty());
index 807e5bc9d1df6ef62759e6f78fc5d90c51a5b23f..c17c2c79c441177067666676e10df2eb54b57d52 100644 (file)
@@ -90,6 +90,7 @@ public class MapResolver implements IMapResolverAsync {
         }
         if (request.isSmrInvoked()) {
             LOG.debug("SMR-invoked request received.");
+            LOG.trace("Map-Request object: {}", request);
             for (EidItem eidItem : request.getEidItem()) {
                 final SmrEvent event = new SmrEvent(
                         subscriberListFromItrRlocs(request.getItrRloc(), request.getSourceEid().getEid()),
index a218d8de949e3e4cb2432ec1652c17338855104f..cc9738e6cdd6ec0d3545fe6174f8d73f9d5fb588 100644 (file)
@@ -395,21 +395,39 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener, IS
         void smrReceived(SmrEvent event) {
             final List<Subscriber> subscriberList = event.getSubscriberList();
             for (Subscriber subscriber : subscriberList) {
-                LOG.trace("SMR-invoked event, EID {}, subscriber {}", LispAddressStringifier.getString(event.getEid()),
-                        subscriber.getString());
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("SMR-invoked event, EID {}, subscriber {}",
+                            LispAddressStringifier.getString(event.getEid()),
+                            subscriber.getString());
+                    LOG.trace("eidFutureMap: {}", eidFutureMap);
+                }
                 final Map<Subscriber, ScheduledFuture<?>> subscriberFutureMap = eidFutureMap.get(event.getEid());
                 if (subscriberFutureMap != null) {
                     final ScheduledFuture<?> future = subscriberFutureMap.get(subscriber);
                     if (future != null && !future.isCancelled()) {
                         future.cancel(true);
-                        LOG.debug("SMR-invoked MapRequest received, scheduled task for subscriber {}, EID {} with"
-                                + " nonce {} has been cancelled", subscriber.getString(),
-                                LispAddressStringifier.getString(event.getEid()), event.getNonce());
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("SMR-invoked MapRequest received, scheduled task for subscriber {}, EID {} with"
+                                    + " nonce {} has been cancelled", subscriber.getString(),
+                                    LispAddressStringifier.getString(event.getEid()), event.getNonce());
+                        }
                         subscriberFutureMap.remove(subscriber);
+                    } else {
+                        if (future == null) {
+                            LOG.trace("No outstanding SMR tasks for EID {}, subscriber {}",
+                                    LispAddressStringifier.getString(event.getEid()), subscriber.getString());
+                        } else {
+                            LOG.trace("Future {} is cancelled", future);
+                        }
                     }
                     if (subscriberFutureMap.isEmpty()) {
                         eidFutureMap.remove(event.getEid());
                     }
+                } else {
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("No outstanding SMR tasks for EID {}",
+                                LispAddressStringifier.getString(event.getEid()));
+                    }
                 }
             }
         }