use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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());
}
Aggregations