Search in sources :

Example 11 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method testNbSourceDest.

private void testNbSourceDest() {
    cleanUP();
    insertNBMappingSourceDest(1L, "192.0.2.0/24", "192.168.0.0/16", MappingServiceIntegrationTestUtil.DEFAULT_IPV4_RLOC_STRING);
    MapReply mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    Eid expectedPositivePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/16");
    MappingRecord mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedPositivePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isPositiveMapping(mr));
    insertNBMapping(1L, "192.168.0.0/16", "10.10.10.10");
    MappingServiceIntegrationTestUtil.checkSmr(socket, lms, mapService, 1L, "192.168.0.0");
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)

Example 12 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method insertNBMapping.

private void insertNBMapping(Eid eid, List<Rloc> rlocs) {
    MappingRecord record = MappingServiceIntegrationTestUtil.getDefaultMappingRecordBuilder(eid, rlocs).build();
    mapService.addMapping(MappingOrigin.Northbound, record.getEid(), null, new MappingData(record));
    sleepForMilliseconds(100);
    MappingServiceIntegrationTestUtil.printMapCacheState(mapService);
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 13 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method testPositivePrefixOverlappingNegativePrefix_moreSpecific.

private void testPositivePrefixOverlappingNegativePrefix_moreSpecific() {
    cleanUP();
    insertNBMappings(1L, "192.167.0.0/16", "192.169.0.0/16");
    MapReply mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    Eid expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/16");
    MappingRecord mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedNegativePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isNegativeMapping(mr));
    insertNBMappings(1L, "192.168.1.0/24");
    MappingServiceIntegrationTestUtil.checkSmr(socket, lms, mapService, 1L, "192.168.0.0");
    mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/24");
    mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedNegativePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isNegativeMapping(mr));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)

Example 14 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingMergeUtil method getCommonLocatorRecords.

private static List<LocatorRecord> getCommonLocatorRecords(MappingRecord nbMapping, MappingRecord sbMapping) {
    // Return null when NB is a negative mapping
    if (nbMapping.getLocatorRecord() == null || nbMapping.getLocatorRecord().isEmpty()) {
        return null;
    }
    List<LocatorRecord> sbLocators = sbMapping.getLocatorRecord();
    // We assume locators are unique and don't show up several times (with different or identical p/w/mp/mw),
    // so we create a HashMap of the locators from the SB mapping record, keyed by the Rloc
    Map<Rloc, LocatorRecord> sbLocatorMap = new HashMap<Rloc, LocatorRecord>();
    for (LocatorRecord locator : sbLocators) {
        sbLocatorMap.put(locator.getRloc(), locator);
    }
    // Gradually building final list of common locators, in order that they appear in NB Mapping
    List<LocatorRecord> commonLocators = new ArrayList<LocatorRecord>();
    for (LocatorRecord nbLocator : nbMapping.getLocatorRecord()) {
        Rloc nbRloc = nbLocator.getRloc();
        if (sbLocatorMap.containsKey(nbRloc)) {
            if (sbLocatorMap.get(nbRloc).getPriority() == (short) 255) {
                // if SB locator has p == 255 then common locator takes all NB fields except for p
                // which must be set to 255
                LocatorRecordBuilder lrb = new LocatorRecordBuilder(nbLocator);
                lrb.setPriority((short) 255);
                commonLocators.add(lrb.build());
            } else {
                commonLocators.add(nbLocator);
            }
        }
    }
    return commonLocators;
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ArrayList(java.util.ArrayList) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 15 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingMergeUtil method mergeLocatorRecords.

private static void mergeLocatorRecords(MappingRecordBuilder mrb, MappingRecord newRecord) {
    List<LocatorRecord> locators = mrb.getLocatorRecord();
    // We assume locators are unique and sorted and don't show up several times (with different or identical
    // p/w/mp/mw), so we create a LinkedHashMap (which preserves order) of the locators from the existing merged
    // record, keyed by the Rloc
    Map<Rloc, LocatorRecord> locatorMap = new LinkedHashMap<Rloc, LocatorRecord>();
    // All locators to be added to the merge set are first stored in this list
    List<LocatorRecord> newLocatorList = new ArrayList<LocatorRecord>();
    for (LocatorRecord locator : locators) {
        locatorMap.put(locator.getRloc(), locator);
    }
    for (LocatorRecord newLocator : newRecord.getLocatorRecord()) {
        Rloc newRloc = newLocator.getRloc();
        if (locatorMap.containsKey(newRloc)) {
            // overlapping locator
            if (!locatorMap.get(newRloc).equals(newLocator)) {
                LocatorRecord mergedLocator = mergeLocators(locatorMap.get(newRloc), newLocator);
                newLocatorList.add(mergedLocator);
            }
        } else {
            // new locator
            newLocatorList.add(newLocator);
        }
    }
    // Build new merged and sorted locator set if need be
    if (!newLocatorList.isEmpty()) {
        List<LocatorRecord> mergedLocators = new ArrayList<LocatorRecord>();
        int mlocIt = 0;
        int locIt = 0;
        while (mlocIt < newLocatorList.size() && locIt < locators.size()) {
            int cmp = compareLocators(locators.get(locIt), newLocatorList.get(mlocIt));
            if (cmp < 0) {
                mergedLocators.add(locators.get(locIt));
                locIt++;
            } else if (cmp > 0) {
                mergedLocators.add(newLocatorList.get(mlocIt));
                mlocIt++;
            } else {
                // when a locator appears in both lists, keep the new (merged) one and skip the old
                mergedLocators.add(newLocatorList.get(mlocIt));
                mlocIt++;
                locIt++;
            }
        }
        while (locIt < locators.size()) {
            mergedLocators.add(locators.get(locIt));
            locIt++;
        }
        while (mlocIt < newLocatorList.size()) {
            mergedLocators.add(newLocatorList.get(mlocIt));
            mlocIt++;
        }
        mrb.setLocatorRecord(mergedLocators);
    }
}
Also used : Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ArrayList(java.util.ArrayList) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)56 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)31 Test (org.junit.Test)28 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)22 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)11 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)10 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)10 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)6 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)6 ArrayList (java.util.ArrayList)5 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)5 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)5 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)4 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)4 XtrId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)4 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)3