Search in sources :

Example 31 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey in project lispflowmapping by opendaylight.

the class MappingSystem method removeMapping.

@Override
public void removeMapping(MappingOrigin origin, Eid key) {
    Eid dstAddr = null;
    Set<Subscriber> subscribers = null;
    Set<Subscriber> dstSubscribers = null;
    MappingData mapping = (MappingData) tableMap.get(origin).getMapping(null, key);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Removing mapping for EID {} from {}", LispAddressStringifier.getString(key), origin);
    }
    if (LOG.isTraceEnabled() && mapping != null) {
        LOG.trace(mapping.getString());
    }
    MappingRecord notificationMapping = null;
    if (mapping != null) {
        notificationMapping = mapping.getRecord();
        subscribers = getSubscribers(key);
        // For SrcDst LCAF also send SMRs to Dst prefix
        if (key.getAddress() instanceof SourceDestKey) {
            dstAddr = SourceDestKeyHelper.getDstBinary(key);
            dstSubscribers = getSubscribers(dstAddr);
        }
    }
    removeSubscribersConditionally(origin, key);
    if (origin == MappingOrigin.Southbound) {
        removeFromSbTimeoutService(key);
    }
    if (origin == MappingOrigin.Southbound && mapping != null && mapping.isPositive().or(false)) {
        mergeNegativePrefixes(key);
    } else {
        // mergeNegativePrefixes() above removes the mapping, so addNegativeMapping() will work correctly
        tableMap.get(origin).removeMapping(key);
    }
    if (notificationMapping != null) {
        publishNotification(notificationMapping, key, subscribers, dstSubscribers, MappingChange.Removed);
        notifyChildren(key, notificationMapping, MappingChange.Removed);
        if (dstAddr != null) {
            notifyChildren(dstAddr, notificationMapping, MappingChange.Removed);
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 32 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey in project lispflowmapping by opendaylight.

the class MapServer method onMappingChanged.

@Override
public void onMappingChanged(MappingChanged notification) {
    if (subscriptionService) {
        Eid eid = notification.getEid();
        if (eid == null) {
            eid = notification.getMappingRecord().getEid();
        }
        LOG.trace("MappingChanged event for {} of type: `{}'", LispAddressStringifier.getString(eid), notification.getChangeType());
        Set<Subscriber> subscribers = MSNotificationInputUtil.toSubscriberSet(notification.getSubscriberItem());
        LoggingUtil.logSubscribers(LOG, eid, subscribers);
        if (mapService.isMaster()) {
            sendSmrs(eid, subscribers);
            if (eid.getAddress() instanceof SourceDestKey) {
                Set<Subscriber> dstSubscribers = MSNotificationInputUtil.toSubscriberSetFromDst(notification.getDstSubscriberItem());
                LoggingUtil.logSubscribers(LOG, SourceDestKeyHelper.getDstBinary(eid), dstSubscribers);
                sendSmrs(SourceDestKeyHelper.getDstBinary(eid), dstSubscribers);
            }
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)

Example 33 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey in project lispflowmapping by opendaylight.

the class MappingMergeUtil method computeNbSbIntersection.

private static MappingRecord computeNbSbIntersection(MappingRecord nbMapping, MappingRecord sbMapping) {
    // returns a MappingRecord which has the more specific EID, and intersection of locator records.
    // If locators intersection is empty, original NB mapping is returned.
    // The intersection is only computed for mappings with maskable EIDs.
    // Supports both maskable and non-maskable EIDs
    MappingRecordBuilder mrb = new MappingRecordBuilder(nbMapping);
    if (MaskUtil.isMaskable(sbMapping.getEid().getAddress()) && MaskUtil.isMaskable(nbMapping.getEid().getAddress())) {
        short sbMask = MaskUtil.getMaskForAddress(sbMapping.getEid().getAddress());
        short nbMask = MaskUtil.getMaskForAddress(nbMapping.getEid().getAddress());
        if (nbMapping.getEid().getAddress() instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) {
            nbMask = SourceDestKeyHelper.getDstMask(nbMapping.getEid());
            if (nbMask < sbMask) {
                // We have to create a new SourceDest EID, where the source is same as the
                // one in NB record, and dest EID is the more specific from SB mapping record.
                SourceDestKey srcDstKey = ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) nbMapping.getEid().getAddress()).getSourceDestKey();
                SourceDestKeyBuilder sdb = new SourceDestKeyBuilder(srcDstKey);
                sdb.setDest(new SimpleAddress(getIpPrefix(sbMapping.getEid().getAddress())));
                mrb.setEid(LispAddressUtil.asSrcDstEid(sdb.build(), nbMapping.getEid().getVirtualNetworkId()));
            }
        } else if (nbMask < sbMask) {
            // Both EIDs are IP prefixes. SB mapping is a subprefix so we have to update EID intersection
            mrb.setEid(sbMapping.getEid());
        }
    }
    // find and update locators intersection if not empty
    List<LocatorRecord> commonLocators = getCommonLocatorRecords(nbMapping, sbMapping);
    if (commonLocators != null && !commonLocators.isEmpty()) {
        mrb.setLocatorRecord(commonLocators);
    }
    return mrb.build();
}
Also used : SourceDestKeyBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder) Preconditions(com.google.common.base.Preconditions) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Example 34 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey in project lispflowmapping by opendaylight.

the class MapServerTest method handleMapRegisterTest_withTwoMappingRecords.

@Test
@Ignore
public void handleMapRegisterTest_withTwoMappingRecords() throws NoSuchFieldException, IllegalAccessException {
    setConfigIniMappingMergeField(true);
    // Input
    // Add a MappingRecord with SrcDestKey Eid Type
    final MappingRecordItemBuilder mappingRecordItemBuilder = new MappingRecordItemBuilder().setMappingRecord(getDefaultMappingRecordBuilder().setEid(SOURCE_DEST_KEY_EID).build());
    final MapRegisterBuilder mapRegisterSrcDstBuilder = getDefaultMapRegisterBuilder();
    final List<MappingRecordItem> list = mapRegisterSrcDstBuilder.getMappingRecordItem();
    list.add(mappingRecordItemBuilder.build());
    // ------------- Stubbing for SourceDestKey type Eid mapping -------------------
    Mockito.when(mapService.getAuthenticationKey(SOURCE_DEST_KEY_EID)).thenReturn(MAPPING_AUTHKEY);
    Mockito.when(mapService.getMapping(MappingOrigin.Southbound, SOURCE_DEST_KEY_EID)).thenReturn(OLD_MAPPING_DATA_1).thenReturn(OLD_MAPPING_DATA_2).thenReturn(OLD_MAPPING_DATA_2);
    // return a subscriberSet for SrcDestKeyEid MappingRecord
    Mockito.when(mapService.getData(MappingOrigin.Southbound, SOURCE_DEST_KEY_EID, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_1);
    // return a subscriberSet for SrcDestKeyEid destination MappingRecord
    Mockito.when(mapService.getData(MappingOrigin.Southbound, SourceDestKeyHelper.getDstBinary(SOURCE_DEST_KEY_EID), SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_2);
    // ----------------- Stubbing for Ipv4 type Eid mapping ------------------------
    Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
    Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1)).thenReturn(OLD_MAPPING_DATA_1).thenReturn(OLD_MAPPING_DATA_2);
    // return a subscriberSet for Ipv4Eid MappingRecord
    Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_3);
    // -----------------------------------------------------------------------------
    // result
    mapServer.handleMapRegister(mapRegisterSrcDstBuilder.build());
    // for SrcDstKey mapping
    final ArgumentCaptor<MapRequest> captor_1 = ArgumentCaptor.forClass(MapRequest.class);
    Mockito.verify(notifyHandler, Mockito.times(1)).handleSMR(captor_1.capture(), Mockito.eq(RLOC_2));
    final Eid resultEid_1 = captor_1.getValue().getEidItem().iterator().next().getEid();
    assertEquals(IPV4_SOURCE_EID_2, resultEid_1);
    // for SrcDst destination mapping
    final ArgumentCaptor<MapRequest> captor_2 = ArgumentCaptor.forClass(MapRequest.class);
    Mockito.verify(notifyHandler, Mockito.times(1)).handleSMR(captor_2.capture(), Mockito.eq(RLOC_4));
    final Eid resultEid_2 = captor_2.getValue().getEidItem().iterator().next().getEid();
    assertEquals(IPV4_SOURCE_EID_4, resultEid_2);
    // for Ipv4 mapping
    final ArgumentCaptor<MapRequest> captor_3 = ArgumentCaptor.forClass(MapRequest.class);
    Mockito.verify(notifyHandler, Mockito.times(2)).handleSMR(captor_3.capture(), Mockito.eq(RLOC_6));
    final Eid resultEid_3 = captor_3.getValue().getEidItem().iterator().next().getEid();
    assertEquals(IPV4_SOURCE_EID_6, resultEid_3);
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 35 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey in project lispflowmapping by opendaylight.

the class MappingMergeUtilTest method computeNbSbIntersectionTest_withMaskableSourceDestKeyEIDs_Ipv6SB.

/**
 * Tests {@link MappingMergeUtil#computeNbSbIntersection} method with SourceDestKey Eid address type, Ipv6Prefix
 * SB Eid, Nb mask less than SB mask.
 */
@Test
public void computeNbSbIntersectionTest_withMaskableSourceDestKeyEIDs_Ipv6SB() {
    MappingRecord nbMappingRecord = getDefaultMappingRecordBuilder().setEid(SOURCE_DEST_KEY_EID_1).build();
    MappingRecord sbMappingRecord = getDefaultMappingRecordBuilder().setEid(IPV6_PREFIX_EID).build();
    MappingData nbMappingData = getDefaultMappingData(nbMappingRecord);
    MappingData sbMappingData = getDefaultMappingData(sbMappingRecord);
    // result
    final MappingData result = MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
    final Eid eid = LispAddressUtil.asSrcDstEid(IPV4_STRING_3, IPV6_STRING, 24, 96, 1);
    assertEquals(eid, result.getRecord().getEid());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Test(org.junit.Test)

Aggregations

Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)28 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)20 Test (org.junit.Test)16 ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)7 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)6 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)6 SourceDestKeyBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder)5 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)4 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey)4 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)3 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)3 LispAddressSerializerContext (org.opendaylight.lispflowmapping.lisp.serializer.address.LispAddressSerializerContext)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 Ipv4PrefixAfi (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv4PrefixAfi)2 Ipv4PrefixBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4PrefixBuilder)2 Ipv4PrefixBinaryAfi (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.Ipv4PrefixBinaryAfi)2 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)2 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)2 Preconditions (com.google.common.base.Preconditions)1 Inet4Address (java.net.Inet4Address)1