Search in sources :

Example 21 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent 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.rev131007.Open)) {
        return false;
    }
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessage o = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.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.rev131005.open.object.Open)

Example 22 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent in project bgpcep by opendaylight.

the class PCEPSessionImpl method sendMessage.

/**
 * Sends message to serialization.
 *
 * @param msg to be sent
 */
@Override
public Future<Void> sendMessage(final Message msg) {
    final ChannelFuture f = this.channel.writeAndFlush(msg);
    this.lastMessageSentAt = TICKER.read();
    this.sessionState.updateLastSentMsg();
    if (!(msg instanceof KeepaliveMessage)) {
        LOG.debug("PCEP Message enqueued: {}", msg);
    }
    if (msg instanceof PcerrMessage) {
        this.sessionState.setLastSentError(msg);
    }
    f.addListener((ChannelFutureListener) arg -> {
        if (arg.isSuccess()) {
            LOG.trace("Message sent to socket: {}", msg);
        } else {
            LOG.debug("Message not sent: {}", msg, arg.cause());
        }
    });
    return f;
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) KeepaliveMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder) Date(java.util.Date) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open) LoggerFactory(org.slf4j.LoggerFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OpenMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) CloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.CloseBuilder) KeepaliveMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage) ToStringHelper(com.google.common.base.MoreObjects.ToStringHelper) InetAddress(java.net.InetAddress) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) PCEPErrors(org.opendaylight.protocol.pcep.spi.PCEPErrors) CloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseMessage) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage) Objects.requireNonNull(java.util.Objects.requireNonNull) ChannelFutureListener(io.netty.channel.ChannelFutureListener) LinkedList(java.util.LinkedList) PCEPCloseTermination(org.opendaylight.protocol.pcep.PCEPCloseTermination) PCEPSessionListener(org.opendaylight.protocol.pcep.PCEPSessionListener) KeepaliveBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder) CCloseMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.CCloseMessageBuilder) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs) TerminationReason(org.opendaylight.protocol.pcep.TerminationReason) Messages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages) Logger(org.slf4j.Logger) MoreObjects(com.google.common.base.MoreObjects) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref) IOException(java.io.IOException) Ticker(com.google.common.base.Ticker) GuardedBy(javax.annotation.concurrent.GuardedBy) InetSocketAddress(java.net.InetSocketAddress) ChannelFuture(io.netty.channel.ChannelFuture) Channel(io.netty.channel.Channel) TimeUnit(java.util.concurrent.TimeUnit) Util(org.opendaylight.protocol.pcep.impl.spi.Util) PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Keepalive(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive) CCloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CCloseBuilder) SimpleChannelInboundHandler(io.netty.channel.SimpleChannelInboundHandler) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Queue(java.util.Queue) Future(io.netty.util.concurrent.Future) PeerPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerPref) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage) KeepaliveMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage)

Example 23 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent in project bgpcep by opendaylight.

the class Stateful07TopologySessionListener method redelegate.

private ListenableFuture<OperationResult> redelegate(final Lsp reportedLsp, final Srp srp, final Lsp lsp, final UpdateLspArgs input) {
    // the D bit that was reported decides the type of PCE message sent
    requireNonNull(reportedLsp.isDelegate());
    final Message msg;
    if (reportedLsp.isDelegate()) {
        // we already have delegation, send update
        final UpdatesBuilder rb = new UpdatesBuilder();
        rb.setSrp(srp);
        rb.setLsp(lsp);
        final PathBuilder pb = new PathBuilder();
        pb.fieldsFrom(input.getArguments());
        rb.setPath(pb.build());
        final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
        ub.setUpdates(Collections.singletonList(rb.build()));
        msg = new PcupdBuilder().setPcupdMessage(ub.build()).build();
    } else {
        final Lsp1 lspCreateFlag = reportedLsp.getAugmentation(Lsp1.class);
        // we only retake delegation for PCE initiated tunnels
        if (lspCreateFlag != null && !lspCreateFlag.isCreate()) {
            LOG.warn("Unable to retake delegation of PCC-initiated tunnel: {}", reportedLsp);
            return OperationResults.createUnsent(PCEPErrors.UPDATE_REQ_FOR_NON_LSP).future();
        }
        // we want to revoke delegation, different type of message
        // is sent because of specification by Siva
        // this message is also sent, when input delegate bit is set to 0
        // generating an error in PCC
        final List<Requests> reqs = new ArrayList<>();
        reqs.add(new RequestsBuilder().setSrp(srp).setLsp(lsp).build());
        final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder();
        ib.setRequests(reqs);
        msg = new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build();
    }
    return sendMessage(msg, srp.getOperationId(), input.getArguments().getMetadata());
}
Also used : PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessageBuilder) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder) PcrptMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcrptMessage) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) PcupdMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.PcupdMessageBuilder) ArrayList(java.util.ArrayList) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder) UpdatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.UpdatesBuilder) Lsp1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Lsp1) PcupdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcupdBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)

Example 24 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent in project netvirt by opendaylight.

the class ElanUtils method getEgressActionsForInterface.

/**
 * Returns the list of Actions to be taken when sending the packet through
 * an Elan interface. Note that this interface can refer to an ElanInterface
 * where the Elan VM is attached to a DPN or an ITM tunnel interface where
 * Elan traffic can be sent through. In this latter case, the tunnelKey is
 * mandatory and it can hold serviceId for internal tunnels or the VNI for
 * external tunnels.
 *
 * @param ifName
 *            the if name
 * @param tunnelKey
 *            the tunnel key
 * @return the egress actions for interface
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> getEgressActionsForInterface(String ifName, Long tunnelKey) {
    List<Action> listAction = new ArrayList<>();
    try {
        GetEgressActionsForInterfaceInput getEgressActionInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).setTunnelKey(tunnelKey).build();
        Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActionInput);
        RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.debug("RPC Call to Get egress actions for interface {} returned with Errors {}", ifName, rpcResult.getErrors());
        } else {
            List<Action> actions = rpcResult.getResult().getAction();
            listAction = actions;
        }
    } catch (Exception e) {
        LOG.warn("Exception when egress actions for interface {}", ifName, e);
    }
    return listAction;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) ArrayList(java.util.ArrayList) GetEgressActionsForInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ElanException(org.opendaylight.netvirt.elan.ElanException)

Example 25 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent in project netvirt by opendaylight.

the class VpnFootprintService method createOrUpdateVpnToDpnListForInterfaceName.

private void createOrUpdateVpnToDpnListForInterfaceName(long vpnId, String primaryRd, BigInteger dpnId, String intfName, String vpnName) {
    Boolean newDpnOnVpn = Boolean.FALSE;
    synchronized (vpnName.intern()) {
        WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
        InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(primaryRd, dpnId);
        Optional<VpnToDpnList> dpnInVpn = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
        VpnInterfaces vpnInterface = new VpnInterfacesBuilder().setInterfaceName(intfName).build();
        if (dpnInVpn.isPresent()) {
            VpnToDpnList vpnToDpnList = dpnInVpn.get();
            List<VpnInterfaces> vpnInterfaces = vpnToDpnList.getVpnInterfaces();
            if (vpnInterfaces == null) {
                vpnInterfaces = new ArrayList<>();
            }
            vpnInterfaces.add(vpnInterface);
            VpnToDpnListBuilder vpnToDpnListBuilder = new VpnToDpnListBuilder(vpnToDpnList);
            vpnToDpnListBuilder.setDpnState(VpnToDpnList.DpnState.Active).setVpnInterfaces(vpnInterfaces);
            writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
            /*
                 * If earlier state was inactive, it is considered new DPN coming back to the
                 * same VPN
                 */
            if (vpnToDpnList.getDpnState() == VpnToDpnList.DpnState.Inactive) {
                newDpnOnVpn = Boolean.TRUE;
            }
            LOG.debug("createOrUpdateVpnToDpnList: Updating vpn footprint for vpn {} vpnId {} interface {}" + " on dpn {}", vpnName, vpnId, intfName, dpnId);
        } else {
            List<VpnInterfaces> vpnInterfaces = new ArrayList<>();
            vpnInterfaces.add(vpnInterface);
            VpnToDpnListBuilder vpnToDpnListBuilder = new VpnToDpnListBuilder().setDpnId(dpnId);
            vpnToDpnListBuilder.setDpnState(VpnToDpnList.DpnState.Active).setVpnInterfaces(vpnInterfaces);
            writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
            newDpnOnVpn = Boolean.TRUE;
            LOG.debug("createOrUpdateVpnToDpnList: Creating vpn footprint for vpn {} vpnId {} interface {}" + " on dpn {}", vpnName, vpnId, intfName, dpnId);
        }
        try {
            writeTxn.submit().get();
        } catch (InterruptedException | ExecutionException e) {
            LOG.error("createOrUpdateVpnToDpnList: Error adding to dpnToVpnList for vpn {} vpnId {} interface {}" + " dpn {}", vpnName, vpnId, intfName, dpnId, e);
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    LOG.info("createOrUpdateVpnToDpnList: Created/Updated vpn footprint for vpn {} vpnId {} interfacName{}" + " on dpn {}", vpnName, vpnId, intfName, dpnId);
    /*
         * Informing the FIB only after writeTxn is submitted successfully.
         */
    if (newDpnOnVpn) {
        if (VpnUtil.isVlan(dataBroker, intfName)) {
            if (!VpnUtil.shouldPopulateFibForVlan(dataBroker, vpnName, null, dpnId, interfaceManager)) {
                return;
            }
        }
        fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, new DpnEnterExitVpnWorker(dpnId, vpnName, primaryRd, true));
        LOG.info("createOrUpdateVpnToDpnList: Sent populateFib event for new dpn {} in VPN {} for interface {}", dpnId, vpnName, intfName);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) ArrayList(java.util.ArrayList) VpnToDpnListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ArrayList (java.util.ArrayList)8 ExecutionException (java.util.concurrent.ExecutionException)8 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)4 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)4 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)4 UnknownHostException (java.net.UnknownHostException)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 BigInteger (java.math.BigInteger)2 InetSocketAddress (java.net.InetSocketAddress)2 Date (java.util.Date)2 PacketException (org.opendaylight.openflowplugin.libraries.liblldp.PacketException)2 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)2 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)2 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)2 GetPortFromInterfaceOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput)2 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)2