use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin in project netvirt by opendaylight.
the class EvpnTestHelper method addMacVrfEntryToDS.
public void addMacVrfEntryToDS(String rd, String macAddress, String prefix, List<String> nextHopList, VrfEntry.EncapType encapType, long l2vni, String gatewayMacAddress, RouteOrigin origin) throws TransactionCommitFailedException {
MacVrfEntryBuilder macEntryBuilder = new MacVrfEntryBuilder().setOrigin(origin.getValue());
buildVpnEncapSpecificInfo(macEntryBuilder, encapType, l2vni, macAddress, gatewayMacAddress, nextHopList);
macEntryBuilder.setMac(macAddress);
macEntryBuilder.setDestPrefix(prefix);
InstanceIdentifier<MacVrfEntry> macEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(MacVrfEntry.class, new MacVrfEntryKey(macAddress)).build();
singleTxdataBroker.syncWrite(LogicalDatastoreType.CONFIGURATION, macEntryId, macEntryBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListener method authKeysForEidsUnchanged.
/**
* We maintain a HashMap with the update times of AuthenticationKey objects in the updatedEntries field. We keep
* entries in the HashMap for the Map-Register cache timeout interval, and lazy remove them afterwards. As a result
* the same EID will be considered updated during that interval, even on subsequent queries. This is necessary
* because more than one xTR may register the same EID, and to avoid complexity we don't store origin information.
* The performance trade-off is not significant, because during a typical cache timeout the same xTR will send only
* a few registration packets (2 for the default value of 90s, when UDP Map-Registers are sent at 1 minute
* intervals).
*
* @param eids List of EIDs to check
* @param timeout MapRegister cache timeout value
* @return false if any of the EIDs in the eids list was updated in the last timout period, true otherwise
*/
public synchronized boolean authKeysForEidsUnchanged(List<EidLispAddress> eids, long timeout) {
boolean result = true;
Long currentTime = System.currentTimeMillis();
for (EidLispAddress eidLispAddress : eids) {
Long updateTime = updatedEntries.get(eidLispAddress.getEid());
if (updateTime != null) {
result = false;
if (currentTime - updateTime > timeout) {
updatedEntries.remove(eidLispAddress.getEid());
}
}
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin in project lispflowmapping by opendaylight.
the class MappingSystem method addMapping.
private void addMapping(MappingOrigin origin, Eid key, MappingData mappingData, MappingChange changeType) {
sbMappingTimeoutService.removeExpiredMappings();
if (mappingData == null) {
LOG.warn("addMapping() called with null mapping, ignoring");
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug("DAO: Adding {} mapping for EID {}", origin, LispAddressStringifier.getString(key));
}
if (LOG.isTraceEnabled()) {
LOG.trace("mappingData = {}", mappingData.getString());
}
// Save the old mapping for the key before we modify anything, so that we can detect changes later
final MappingRecord oldMapping = getMappingRecord(getMapping(key));
if (origin == MappingOrigin.Southbound) {
XtrId xtrId = mappingData.getXtrId();
if (xtrId == null && mappingMerge && mappingData.isMergeEnabled()) {
LOG.warn("addMapping() called will null xTR-ID in MappingRecord, while merge is set, ignoring");
return;
}
if (xtrId != null && mappingMerge) {
if (mappingData.isMergeEnabled()) {
smc.addMapping(key, xtrId, mappingData);
handleMergedMapping(key);
return;
} else {
clearPresentXtrIdMappings(key);
smc.addMapping(key, xtrId, mappingData);
}
}
addOrRefreshMappingInTimeoutService(key, mappingData);
}
tableMap.get(origin).addMapping(key, mappingData);
// We need to check if the newly added mapping is covering negatives in SB, and remove those (with notification)
if (mappingData.isPositive().or(true)) {
handleSbNegativeMappings(key);
}
MappingRecord newMapping = getMappingRecord(getMapping(key));
handleAddMappingNotifications(origin, key, mappingData, oldMapping, newMapping, changeType);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin in project lispflowmapping by opendaylight.
the class MappingSystem method handleAddMappingNotifications.
private void handleAddMappingNotifications(MappingOrigin origin, Eid key, MappingData mappingData, MappingRecord oldMapping, MappingRecord newMapping, MappingChange changeType) {
// account policy as well
if (origin != MappingOrigin.Southbound || MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
notifyChange(key, mappingData.getRecord(), changeType);
Eid dstKey = key;
// for the checks that we do afterwards
if (key.getAddress() instanceof SourceDestKey) {
dstKey = SourceDestKeyHelper.getDstBinary(key);
}
// If the old mapping had a different EID than what was just added, notify those subscribers too
if (oldMapping != null && !oldMapping.getEid().equals(key) && !oldMapping.getEid().equals(dstKey)) {
notifyChange(oldMapping.getEid(), oldMapping, changeType);
}
// subscribers too
if (newMapping != null && !newMapping.getEid().equals(key) && !newMapping.getEid().equals(dstKey)) {
notifyChange(newMapping.getEid(), newMapping, changeType);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin 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);
}
}
}
Aggregations