Search in sources :

Example 16 with PeerId

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

the class AbstractPeer method reEvaluateAdvertizement.

@Override
public final synchronized <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>> void reEvaluateAdvertizement(final RouteEntryDependenciesContainer entryDep, final List<ActualBestPathRoutes<C, S>> routesToStore) {
    if (ribOutChain == null) {
        LOG.debug("Session closed, skip changes to peer AdjRibsOut {}", getPeerId());
        return;
    }
    final RIBSupport<C, S> ribSupport = entryDep.getRIBSupport();
    final NodeIdentifierWithPredicates tk = ribSupport.tablesKey();
    final boolean addPathSupported = supportsAddPathSupported(ribSupport.getTablesKey());
    final DOMDataTreeWriteTransaction tx = ribOutChain.newWriteOnlyTransaction();
    for (final ActualBestPathRoutes<C, S> actualBestRoute : routesToStore) {
        final PeerId fromPeerId = actualBestRoute.getFromPeerId();
        if (!filterRoutes(fromPeerId, ribSupport.getTablesKey())) {
            continue;
        }
        final YangInstanceIdentifier tableRibout = getRibOutIId(tk);
        // Stale Long-lived Graceful Restart routes should not be propagated
        if (supportsLLGR() || !actualBestRoute.isDepreferenced()) {
            final YangInstanceIdentifier routePath = createRoutePath(ribSupport, tableRibout, actualBestRoute, addPathSupported);
            final MapEntryNode route = actualBestRoute.getRoute();
            final Optional<ContainerNode> effAttr = applyExportPolicy(entryDep, fromPeerId, route, routePath, actualBestRoute.getAttributes());
            if (effAttr.isPresent()) {
                storeRoute(ribSupport, actualBestRoute, route, routePath, effAttr.get(), tx);
                continue;
            }
        }
        deleteRoute(ribSupport, addPathSupported, tableRibout, actualBestRoute, tx);
    }
    final FluentFuture<? extends CommitInfo> future = tx.commit();
    submitted = future;
    future.addCallback(new FutureCallback<CommitInfo>() {

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

        @Override
        public void onFailure(final Throwable trw) {
            LOG.error("Failed update commit", trw);
        }
    }, MoreExecutors.directExecutor());
}
Also used : DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId)

Example 17 with PeerId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId 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 18 with PeerId

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

the class MatchBgpNeighborSetTest method testMatchToBgpNeighborAny.

@Test
public void testMatchToBgpNeighborAny() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("reject-to-neighbor-test")).findFirst().get();
    RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
    doReturn(new PeerId("bgp://127.0.0.2")).when(this.exportParameters).getFromPeerId();
    doReturn(new PeerId("bgp://42.42.42.42")).when(this.exportParameters).getToPeerId();
    RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
    assertNotNull(result.getAttributes());
    doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getToPeerId();
    result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
    assertNull(result.getAttributes());
}
Also used : Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) IPV4UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId) Test(org.junit.Test)

Example 19 with PeerId

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

the class MatchBgpNeighborSetTest method testMatchFromBgpNeighborAny.

@Test
public void testMatchFromBgpNeighborAny() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("reject-from-neighbor-test")).findFirst().get();
    RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
    doReturn(new PeerId("bgp://42.42.42.42")).when(this.exportParameters).getFromPeerId();
    RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
    assertNotNull(result.getAttributes());
    doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getFromPeerId();
    result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
    assertNull(result.getAttributes());
}
Also used : Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) IPV4UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId) Test(org.junit.Test)

Example 20 with PeerId

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

the class IdentifierUtilsTest method testPeerKeyToPeerId.

@Test
public void testPeerKeyToPeerId() throws Exception {
    final PeerId result = IdentifierUtils.peerKeyToPeerId(YII_PEER);
    assertEquals(PEER_ID, result);
}
Also used : PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId) Test(org.junit.Test)

Aggregations

PeerId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId)13 Test (org.junit.Test)7 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)5 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)5 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)4 IPV4UNICAST (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)4 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)4 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)4 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)3 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)3 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)3 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)3 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)2 BmpRouterPeer (org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer)2 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)2 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1