Search in sources :

Example 61 with Peer

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());
}
Also used : DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) Peer(org.opendaylight.protocol.bgp.rib.spi.Peer) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId)

Example 62 with Peer

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());
}
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 63 with Peer

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));
        }
    }
}
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 64 with Peer

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;
}
Also used : Preconditions(com.google.common.base.Preconditions) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open)

Example 65 with Peer

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());
}
Also used : KeepaliveMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.keepalive.message.KeepaliveMessageBuilder) SSLContext(javax.net.ssl.SSLContext) Keepalive(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Keepalive) Pcerr(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr) OpenMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OpenMessage) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) SSLEngine(javax.net.ssl.SSLEngine) Future(java.util.concurrent.Future) PCEPErrors(org.opendaylight.protocol.pcep.spi.PCEPErrors) ChannelFutureListener(io.netty.channel.ChannelFutureListener) SslContextFactory(org.opendaylight.protocol.pcep.impl.tls.SslContextFactory) Tls(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.Tls) ErrorObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObject) OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.OpenBuilder) Logger(org.slf4j.Logger) Promise(io.netty.util.concurrent.Promise) Starttls(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Starttls) Channel(io.netty.channel.Channel) TimeUnit(java.util.concurrent.TimeUnit) Util(org.opendaylight.protocol.pcep.impl.spi.Util) OpenMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.message.OpenMessageBuilder) StarttlsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.StarttlsBuilder) SslHandler(io.netty.handler.ssl.SslHandler) KeepaliveBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.KeepaliveBuilder) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) StartTlsMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.start.tls.message.StartTlsMessageBuilder) SessionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.SessionCase) StartTlsMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.start.tls.message.StartTlsMessageBuilder) StarttlsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.StarttlsBuilder)

Aggregations

Test (org.junit.Test)29 ByteBuf (io.netty.buffer.ByteBuf)13 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)11 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)9 BGPSessionPreferences (org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences)8 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)7 ArrayList (java.util.ArrayList)6 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)6 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)6 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)5 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)5 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters)5 PeerId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId)5 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)4 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)4 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)4 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)4 PortStatusMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage)4