Search in sources :

Example 56 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 BmpRibInWriter method removeRoutes.

private synchronized 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.newWriteOnlyTransaction();
    ctx.removeRoutes(tx, nlri);
    tx.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.trace("Successful commit");
        }

        @Override
        public void onFailure(final Throwable trw) {
            LOG.error("Failed commit", trw);
        }
    }, 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)

Example 57 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 BmpRibInWriter method checkEndOfRib.

/**
 * For each received Update message, the upd sync variable needs to be updated to true, for particular AFI/SAFI
 * combination. Currently we only assume Unicast SAFI. From the Update message we have to extract the AFI. Each
 * Update message can contain BGP Object with one type of AFI. If the object is BGP Link, BGP Node or a BGPPrefix
 * the AFI is Linkstate. In case of BGPRoute, the AFI depends on the IP Address of the prefix.
 *
 * @param msg received Update message
 */
private boolean checkEndOfRib(final UpdateMessage msg) {
    TablesKey type = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
    boolean isEOR = false;
    if (msg.getNlri() == null && msg.getWithdrawnRoutes() == null) {
        if (msg.getAttributes() != null) {
            if (msg.getAttributes().augmentation(AttributesReach.class) != null) {
                final AttributesReach pa = msg.getAttributes().augmentation(AttributesReach.class);
                if (pa.getMpReachNlri() != null) {
                    type = new TablesKey(pa.getMpReachNlri().getAfi(), pa.getMpReachNlri().getSafi());
                }
            } else if (msg.getAttributes().augmentation(AttributesUnreach.class) != null) {
                final AttributesUnreach pa = msg.getAttributes().augmentation(AttributesUnreach.class);
                if (pa.getMpUnreachNlri() != null) {
                    type = new TablesKey(pa.getMpUnreachNlri().getAfi(), pa.getMpUnreachNlri().getSafi());
                }
                if (pa.getMpUnreachNlri().getWithdrawnRoutes() == null) {
                    // EOR message contains only MPUnreach attribute and no NLRI
                    isEOR = true;
                }
            }
        } else {
            // true for empty Update Message
            isEOR = true;
        }
    }
    if (isEOR) {
        markTableUptodated(type);
        LOG.debug("BMP Synchronization finished for table {} ", type);
    }
    return isEOR;
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) AttributesReach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach) AttributesUnreach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach)

Example 58 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 Ipv4ReachabilityTopologyBuilderTest method setUp.

@Before
@Override
public void setUp() {
    super.setUp();
    this.ipv4TopoBuilder = new Ipv4ReachabilityTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID);
    this.ipv4TopoBuilder.start();
    final InstanceIdentifier<Tables> path = LOC_RIB_REF.getInstanceIdentifier().builder().child(LocRib.class).child(Tables.class, new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)).build();
    this.ipv4RouteIID = path.builder().child(Ipv4RoutesCase.class, Ipv4Routes.class).child(Ipv4Route.class, new Ipv4RouteKey(new PathId(PATH_ID), ROUTE_IP4PREFIX)).build();
}
Also used : PathId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) Ipv4RouteKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteKey) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables) Ipv4RoutesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase) Ipv4Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.Ipv4Routes) Before(org.junit.Before)

Example 59 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 AbstractPeer method installRouteRibOut.

private <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>> void installRouteRibOut(final RouteEntryDependenciesContainer entryDep, final List<AdvertizedRoute<C, S>> routes, final DOMDataTreeWriteOperations tx) {
    final RIBSupport<C, S> ribSupport = entryDep.getRIBSupport();
    final TablesKey tk = ribSupport.getTablesKey();
    final BGPPeerTracker peerTracker = entryDep.getPeerTracker();
    final boolean addPathSupported = supportsAddPathSupported(tk);
    final YangInstanceIdentifier tableRibout = getRibOutIId(ribSupport.tablesKey());
    for (final AdvertizedRoute<C, S> advRoute : routes) {
        final PeerId fromPeerId = advRoute.getFromPeerId();
        if (!filterRoutes(fromPeerId, tk) || !advRoute.isFirstBestPath() && !addPathSupported) {
            continue;
        }
        if (!supportsLLGR() && advRoute.isDepreferenced()) {
            // https://tools.ietf.org/html/draft-uttaro-idr-bgp-persistence-04#section-4.3
            // o  The route SHOULD NOT be advertised to any neighbor from which the
            // Long-lived Graceful Restart Capability has not been received.  The
            // exception is described in the Optional Partial Deployment
            // Procedure section (Section 4.7).  Note that this requirement
            // implies that such routes should be withdrawn from any such
            // neighbor.
            deleteRoute(ribSupport, addPathSupported, tableRibout, advRoute, tx);
            continue;
        }
        final Peer fromPeer = peerTracker.getPeer(fromPeerId);
        final ContainerNode attributes = advRoute.getAttributes();
        if (fromPeer != null && attributes != null) {
            final YangInstanceIdentifier routePath = createRoutePath(ribSupport, tableRibout, advRoute, addPathSupported);
            final MapEntryNode route = advRoute.getRoute();
            applyExportPolicy(entryDep, fromPeerId, route, routePath, attributes).ifPresent(attrs -> storeRoute(ribSupport, advRoute, route, routePath, attrs, tx));
        }
    }
}
Also used : BGPPeerTracker(org.opendaylight.protocol.bgp.rib.spi.BGPPeerTracker) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) Peer(org.opendaylight.protocol.bgp.rib.spi.Peer) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId)

Example 60 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 AdjRibOutListener method onDataTreeChanged.

@Override
public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
    LOG.debug("Data change received for AdjRibOut {}", changes);
    for (final DataTreeCandidate tc : changes) {
        LOG.trace("Change {} type {}", tc.getRootNode(), tc.getRootNode().getModificationType());
        for (final DataTreeCandidateNode child : tc.getRootNode().getChildNodes()) {
            for (final DataTreeCandidateNode route : support.changedRoutes(child)) {
                processRouteChange(route);
            }
        }
    }
    if (initalState) {
        final Update endOfRib = BgpPeerUtil.createEndOfRib(tablesKey);
        session.write(endOfRib);
        initalState = false;
    }
    session.flush();
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)

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