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