Search in sources :

Example 41 with Origin

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());
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) MacVrfEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryBuilder) MacVrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry)

Example 42 with Origin

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;
}
Also used : EidLispAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.map.register.cache.metadata.EidLispAddress)

Example 43 with Origin

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);
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Example 44 with Origin

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);
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)

Example 45 with Origin

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);
        }
    }
}
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)

Aggregations

ArrayList (java.util.ArrayList)18 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)18 Test (org.junit.Test)15 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)14 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)13 FibEntries (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries)12 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder)12 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder)12 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)11 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder)11 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)9 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)9 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)9 Ipv4NextHopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder)9 ExecutionException (java.util.concurrent.ExecutionException)8 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)8 LocalPrefBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder)8 ByteBuf (io.netty.buffer.ByteBuf)7 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)7 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)7