Search in sources :

Example 61 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.

the class BGPPeer method onUpdateMessage.

/**
 * Process Update message received.
 * Calls {@link #checkMandatoryAttributesPresence(Update)} to check for presence of mandatory attributes.
 *
 * @param message Update message
 */
private synchronized void onUpdateMessage(final Update message) throws BGPDocumentedException {
    checkMandatoryAttributesPresence(message);
    // update AdjRibs
    final Attributes attrs = message.getAttributes();
    MpReachNlri mpReach;
    final boolean isAnyNlriAnnounced = message.getNlri() != null;
    if (isAnyNlriAnnounced) {
        mpReach = prefixesToMpReach(message);
    } else {
        mpReach = MessageUtil.getMpReachNlri(attrs);
    }
    if (mpReach != null) {
        this.ribWriter.updateRoutes(mpReach, nextHopToAttribute(attrs, mpReach));
    }
    final MpUnreachNlri mpUnreach;
    if (message.getWithdrawnRoutes() != null) {
        mpUnreach = prefixesToMpUnreach(message, isAnyNlriAnnounced);
    } else {
        mpUnreach = MessageUtil.getMpUnreachNlri(attrs);
    }
    final boolean endOfRib = BgpPeerUtil.isEndOfRib(message);
    if (mpUnreach != null) {
        if (endOfRib) {
            final TablesKey tablesKey = new TablesKey(mpUnreach.getAfi(), mpUnreach.getSafi());
            this.ribWriter.removeStaleRoutes(tablesKey);
            this.missingEOT.remove(tablesKey);
            handleGracefulEndOfRib();
        } else {
            this.ribWriter.removeRoutes(mpUnreach);
        }
    } else if (endOfRib) {
        this.ribWriter.removeStaleRoutes(IPV4_UCAST_TABLE_KEY);
        this.missingEOT.remove(IPV4_UCAST_TABLE_KEY);
        handleGracefulEndOfRib();
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri)

Example 62 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.

the class BGPPeer method handleGracefulEndOfRib.

@Holding("this")
private void handleGracefulEndOfRib() {
    if (isLocalRestarting()) {
        if (this.missingEOT.isEmpty()) {
            createEffRibInWriter();
            this.effRibInWriter.init();
            registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
            for (final TablesKey key : getAfiSafisAdvertized()) {
                createAdjRibOutListener(key, true);
            }
            setLocalRestartingState(false);
            setGracefulPreferences(false, Collections.emptySet());
        }
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) Holding(org.checkerframework.checker.lock.qual.Holding)

Example 63 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.

the class BGPPeer method onRouteRefreshMessage.

private void onRouteRefreshMessage(final RouteRefresh message) {
    final Class<? extends AddressFamily> rrAfi = message.getAfi();
    final Class<? extends SubsequentAddressFamily> rrSafi = message.getSafi();
    final TablesKey key = new TablesKey(rrAfi, rrSafi);
    synchronized (this) {
        final AdjRibOutListener listener = this.adjRibOutListenerSet.remove(key);
        if (listener != null) {
            listener.close();
            createAdjRibOutListener(key, listener.isMpSupported());
        } else {
            LOG.info("Ignoring RouteRefresh message. Afi/Safi is not supported: {}, {}.", rrAfi, rrSafi);
        }
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)

Example 64 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.

the class AdjRibInWriter method createNewTableInstances.

/**
 * Create new table instances, potentially creating their empty entries.
 */
private static ImmutableMap<TablesKey, TableContext> createNewTableInstances(final YangInstanceIdentifier newPeerPath, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, final DOMDataTreeWriteTransaction tx) {
    final Builder<TablesKey, TableContext> tb = ImmutableMap.builder();
    for (final TablesKey tableKey : tableTypes) {
        final RIBSupportContext rs = registry.getRIBSupportContext(tableKey);
        // TODO: Use returned value once Instance Identifier builder allows for it.
        final NodeIdentifierWithPredicates instanceIdentifierKey = RibSupportUtils.toYangTablesKey(tableKey);
        if (rs == null) {
            LOG.warn("No support for table type {}, skipping it", tableKey);
            continue;
        }
        installAdjRibsOutTables(newPeerPath, rs, instanceIdentifierKey, tableKey, addPathTablesType.get(tableKey), tx);
        installAdjRibInTables(newPeerPath, tableKey, rs, instanceIdentifierKey, tx, tb);
    }
    return tb.build();
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) RIBSupportContext(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Example 65 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.

the class AdjRibInWriter method removeRoutes.

void removeRoutes(final MpUnreachNlri nlri) {
    final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
    final TableContext ctx = this.tables.get(key);
    if (ctx == null) {
        LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
        return;
    }
    LOG.trace("Removing routes {}", nlri);
    final DOMDataTreeWriteTransaction tx = this.chain.getDomChain().newWriteOnlyTransaction();
    ctx.removeRoutes(tx, nlri);
    final FluentFuture<? extends CommitInfo> future = tx.commit();
    this.submitted = future;
    future.addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.trace("Removing routes {}, succeed", nlri);
        }

        @Override
        public void onFailure(final Throwable throwable) {
            LOG.error("Removing routes failed", throwable);
        }
    }, MoreExecutors.directExecutor());
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Aggregations

TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)40 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)15 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)11 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)11 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)9 Before (org.junit.Before)8 Test (org.junit.Test)8 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)8 ArrayList (java.util.ArrayList)7 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)7 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)6 Identifier (org.opendaylight.yangtools.yang.binding.Identifier)6 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)5 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId)5 ChannelFuture (io.netty.channel.ChannelFuture)4 InetSocketAddress (java.net.InetSocketAddress)4 HashMap (java.util.HashMap)4 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)4