use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class AbstractPeer method initializeRibOut.
@Override
public final synchronized <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>> void initializeRibOut(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 YangInstanceIdentifier tableRibout = getRibOutIId(ribSupport.tablesKey());
final boolean addPathSupported = supportsAddPathSupported(ribSupport.getTablesKey());
final DOMDataTreeWriteTransaction tx = ribOutChain.newWriteOnlyTransaction();
for (final ActualBestPathRoutes<C, S> initRoute : routesToStore) {
if (!supportsLLGR() && initRoute.isDepreferenced()) {
// Stale Long-lived Graceful Restart routes should not be propagated
continue;
}
final PeerId fromPeerId = initRoute.getFromPeerId();
if (!filterRoutes(fromPeerId, ribSupport.getTablesKey())) {
continue;
}
final MapEntryNode route = initRoute.getRoute();
final Peer fromPeer = entryDep.getPeerTracker().getPeer(fromPeerId);
if (fromPeer == null) {
LOG.debug("Failed to acquire peer structure for {}, ignoring route {}", fromPeerId, initRoute);
continue;
}
final YangInstanceIdentifier routePath = createRoutePath(ribSupport, tableRibout, initRoute, addPathSupported);
applyExportPolicy(entryDep, fromPeerId, route, routePath, initRoute.getAttributes()).ifPresent(attributes -> storeRoute(ribSupport, initRoute, route, routePath, attributes, 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.bmp.monitor.rev200120.peers.Peer 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.bmp.monitor.rev200120.peers.Peer 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.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class AbstractPCEPSessionNegotiator method handleMessageOpenWait.
private boolean handleMessageOpenWait(final Message msg) {
if (!(msg instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open)) {
return false;
}
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.message.OpenMessage o = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open) msg).getOpenMessage();
final Open open = o.getOpen();
if (isProposalAcceptable(open)) {
this.sendMessage(KEEPALIVE);
this.remotePrefs = open;
this.remoteOK = true;
if (this.localOK) {
negotiationSuccessful(createSession(this.channel, this.localPrefs, this.remotePrefs));
LOG.info("PCEP peer {} completed negotiation", this.channel);
this.state = State.FINISHED;
} else {
scheduleFailTimer();
this.state = State.KEEP_WAIT;
LOG.debug("Channel {} moved to KeepWait state with remoteOK=1", this.channel);
}
return true;
}
if (this.openRetry) {
sendErrorMessage(PCEPErrors.SECOND_OPEN_MSG);
negotiationFailed(new IllegalStateException("OPEN renegotiation failed"));
this.state = State.FINISHED;
return true;
}
final Open newPrefs = getCounterProposal(open);
if (newPrefs == null) {
sendErrorMessage(PCEPErrors.NON_ACC_NON_NEG_SESSION_CHAR);
negotiationFailed(new IllegalStateException("Peer sent unacceptable session parameters"));
this.state = State.FINISHED;
return true;
}
this.sendMessage(Util.createErrorMessage(PCEPErrors.NON_ACC_NEG_SESSION_CHAR, newPrefs));
this.openRetry = true;
this.state = this.localOK ? State.OPEN_WAIT : State.KEEP_WAIT;
scheduleFailTimer();
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class AbstractPCEPSessionNegotiator method startNegotiation.
@Override
protected final void startNegotiation() {
Preconditions.checkState(this.state == State.IDLE);
if (this.tlsConfiguration != null) {
this.sendMessage(new StarttlsBuilder().setStartTlsMessage(new StartTlsMessageBuilder().build()).build());
this.state = State.START_TLS_WAIT;
scheduleFailTimer();
LOG.info("Started TLS connection negotiation with peer {}", this.channel);
} else {
startNegotiationWithOpen();
}
this.channel.closeFuture().addListener((ChannelFutureListener) f -> cancelTimers());
}
Aggregations