Search in sources :

Example 96 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class ElanTunnelInterfaceStateListener method add.

@Override
public void add(InstanceIdentifier<StateTunnelList> key, StateTunnelList add) {
    LOG.info("processing add state for StateTunnelList {}", add);
    if (!isInternalTunnel(add)) {
        LOG.trace("tunnel {} is not a internal vxlan tunnel", add);
        return;
    }
    if (elanUtils.isTunnelInLogicalGroup(add.getTunnelInterfaceName())) {
        LOG.trace("MULTIPLE_VxLAN_TUNNELS: ignoring the tunnel event for {}", add.getTunnelInterfaceName());
        return;
    }
    TunnelOperStatus tunOpStatus = add.getOperState();
    if (tunOpStatus != TunnelOperStatus.Down && tunOpStatus != TunnelOperStatus.Up) {
        LOG.trace("Returning because unsupported tunnelOperStatus {}", tunOpStatus);
        return;
    }
    try {
        Uint64 srcDpId = Uint64.valueOf(add.getSrcInfo().getTepDeviceId());
        Uint64 dstDpId = Uint64.valueOf(add.getDstInfo().getTepDeviceId());
        jobCoordinator.enqueueJob(add.getTunnelInterfaceName(), () -> {
            LOG.info("Handling tunnel state event for srcDpId {} and dstDpId {} ", srcDpId, dstDpId);
            elanInterfaceManager.handleInternalTunnelStateEvent(srcDpId, dstDpId);
            return Collections.emptyList();
        }, ElanConstants.JOB_MAX_RETRIES);
    } catch (NumberFormatException e) {
        LOG.error("Invalid source TepDeviceId {} or destination TepDeviceId {}", add.getSrcInfo().getTepDeviceId(), add.getDstInfo().getTepDeviceId());
    }
}
Also used : TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 97 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class ElanEvpnFlowUtils method evpnRemoveFlowThatSendsThePacketOnAnExternalTunnel.

private List<ListenableFuture<?>> evpnRemoveFlowThatSendsThePacketOnAnExternalTunnel(long elanTag, Uint64 dpId, String nexthopIp, String macToRemove) {
    String flowId = ElanEvpnFlowUtils.evpnGetKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, nexthopIp, macToRemove, elanTag, false);
    Flow flowToRemove = new FlowBuilder().setId(new FlowId(flowId)).setTableId(NwConstants.ELAN_DMAC_TABLE).build();
    return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> mdsalManager.removeFlow(tx, dpId, flowToRemove)));
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ElanItmUtils(org.opendaylight.netvirt.elan.utils.ElanItmUtils) Acquired(org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.Acquired) ElanConstants(org.opendaylight.netvirt.elan.utils.ElanConstants) ElanEtreeUtils(org.opendaylight.netvirt.elan.utils.ElanEtreeUtils) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) HashMap(java.util.HashMap) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Singleton(javax.inject.Singleton) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ElanUtils(org.opendaylight.netvirt.elan.utils.ElanUtils) Map(java.util.Map) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) EtreeLeafTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagName) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) Collections(java.util.Collections) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 98 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class ElanPacketInHandler method onPacketReceived.

@Override
public void onPacketReceived(PacketReceived notification) {
    Class<? extends PacketInReason> pktInReason = notification.getPacketInReason();
    short tableId = notification.getTableId().getValue().toJava();
    if (pktInReason == NoMatch.class && tableId == NwConstants.ELAN_SMAC_TABLE) {
        elanManagerCounters.unknownSmacPktinRcv();
        try {
            byte[] data = notification.getPayload();
            Ethernet res = new Ethernet();
            res.deserialize(data, 0, data.length * Byte.SIZE);
            byte[] srcMac = res.getSourceMACAddress();
            final String macAddress = NWUtil.toStringMacAddress(srcMac);
            final Uint64 metadata = notification.getMatch().getMetadata().getMetadata();
            final Uint32 elanTag = Uint32.valueOf(MetaDataUtil.getElanTagFromMetadata(metadata));
            Uint32 portTag = Uint32.valueOf(MetaDataUtil.getLportFromMetadata(metadata).longValue());
            Optional<IfIndexInterface> interfaceInfoOp = elanUtils.getInterfaceInfoByInterfaceTag(portTag);
            if (!interfaceInfoOp.isPresent()) {
                LOG.warn("There is no interface for given portTag {}", portTag);
                return;
            }
            String interfaceName = interfaceInfoOp.get().getInterfaceName();
            LOG.debug("Received a packet with srcMac: {} ElanTag: {} PortTag: {} InterfaceName: {}", macAddress, elanTag, portTag, interfaceName);
            ElanTagName elanTagName = elanUtils.getElanInfoByElanTag(elanTag);
            if (elanTagName == null) {
                LOG.warn("not able to find elanTagName in elan-tag-name-map for elan tag {}", elanTag);
                return;
            }
            ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(interfaceName);
            if (elanInterfaceMac == null) {
                LOG.info("There is no ElanInterfaceForwardingEntryDS created for interface :{}", interfaceName);
                return;
            }
            String elanName = elanTagName.getName();
            PhysAddress physAddress = new PhysAddress(macAddress);
            MacEntry oldMacEntry = elanUtils.getMacEntryForElanInstance(elanName, physAddress).orElse(null);
            boolean isVlanOrFlatProviderIface = interfaceManager.isExternalInterface(interfaceName);
            Optional<IpAddress> srcIpAddress = elanUtils.getSourceIpAddress(res);
            MacEntry newMacEntry = null;
            BigInteger timeStamp = new BigInteger(String.valueOf(System.currentTimeMillis()));
            if (!srcIpAddress.isPresent()) {
                newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress).withKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp).setIsStaticAddress(false).build();
            } else {
                newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress).setIpPrefix(srcIpAddress.get()).withKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp).setIsStaticAddress(false).build();
            }
            if (srcIpAddress.isPresent()) {
                String prefix = srcIpAddress.get().getIpv4Address().getValue();
                InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
                ElanInstance elanInstance = elanInstanceCache.get(elanName).orElse(null);
                evpnUtils.advertisePrefix(elanInstance, macAddress, prefix, interfaceName, interfaceInfo.getDpId());
            }
            enqueueJobForMacSpecificTasks(macAddress, elanTag, interfaceName, elanName, physAddress, oldMacEntry, newMacEntry, isVlanOrFlatProviderIface);
            ElanInstance elanInstance = elanInstanceCache.get(elanName).orElse(null);
            InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
            if (interfaceInfo == null) {
                LOG.trace("Interface:{} is not present under Config DS", interfaceName);
                return;
            }
            enqueueJobForDPNSpecificTasks(macAddress, elanTag, interfaceName, physAddress, elanInstance, interfaceInfo, oldMacEntry, newMacEntry, isVlanOrFlatProviderIface);
        } catch (PacketException e) {
            LOG.error("Failed to decode packet: {}", notification, e);
        }
    }
}
Also used : ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) IfIndexInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) MacEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder) NoMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.NoMatch) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) MacEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey)

Example 99 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class ElanSmacFlowEventListener method onFlowRemoved.

@Override
public void onFlowRemoved(FlowRemoved flowRemoved) {
    short tableId = flowRemoved.getTableId().toJava();
    if (tableId == NwConstants.ELAN_SMAC_TABLE) {
        Uint64 metadata = flowRemoved.getMatch().getMetadata().getMetadata();
        Uint32 elanTag = Uint32.valueOf(MetaDataUtil.getElanTagFromMetadata(metadata));
        ElanTagName elanTagInfo = elanUtils.getElanInfoByElanTag(elanTag);
        if (elanTagInfo == null) {
            return;
        }
        final String srcMacAddress = flowRemoved.getMatch().getEthernetMatch().getEthernetSource().getAddress().getValue().toUpperCase(Locale.getDefault());
        Uint64 portTag = MetaDataUtil.getLportFromMetadata(metadata);
        if (portTag.intValue() == 0) {
            LOG.debug("Flow removed event on SMAC flow entry. But having port Tag as 0 ");
            return;
        }
        Optional<IfIndexInterface> existingInterfaceInfo = elanUtils.getInterfaceInfoByInterfaceTag(Uint32.valueOf(portTag.longValue()));
        if (!existingInterfaceInfo.isPresent()) {
            LOG.debug("Interface is not available for port Tag {}", portTag);
            return;
        }
        String interfaceName = existingInterfaceInfo.get().getInterfaceName();
        PhysAddress physAddress = new PhysAddress(srcMacAddress);
        if (interfaceName == null) {
            LOG.error("LPort record not found for tag {}", portTag);
            return;
        }
        jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), () -> {
            List<ListenableFuture<?>> elanFutures = new ArrayList<>();
            MacEntry macEntry = elanUtils.getInterfaceMacEntriesOperationalDataPath(interfaceName, physAddress);
            InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
            String elanInstanceName = elanTagInfo.getName();
            LOG.info("Deleting the Mac-Entry:{} present on ElanInstance:{}", macEntry, elanInstanceName);
            FluentFuture<? extends Object> result = txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
                if (macEntry != null && interfaceInfo != null) {
                    deleteSmacAndDmacFlows(elanInstanceCache.get(elanInstanceName).orElse(null), interfaceInfo, srcMacAddress, tx);
                } else if (macEntry == null) {
                    // Remove flow of src flow entry only for MAC movement
                    MacEntry macEntryOfElanForwarding = elanUtils.getMacEntryForElanInstance(elanTagInfo.getName(), physAddress).orElse(null);
                    if (macEntryOfElanForwarding != null) {
                        String macAddress = macEntryOfElanForwarding.getMacAddress().getValue();
                        elanUtils.deleteSmacFlowOnly(elanInstanceCache.get(elanInstanceName).orElse(null), interfaceInfo, macAddress, tx);
                    } else {
                        deleteSmacAndDmacFlows(elanInstanceCache.get(elanInstanceName).orElse(null), interfaceInfo, srcMacAddress, tx);
                    }
                }
            });
            elanFutures.add(result);
            addCallBack(result, srcMacAddress);
            InstanceIdentifier<MacEntry> macEntryIdForElanInterface = ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
            Optional<MacEntry> existingInterfaceMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
            if (existingInterfaceMacEntry.isPresent()) {
                FluentFuture<? extends Object> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
                    tx.delete(macEntryIdForElanInterface);
                    MacEntry macEntryInElanInstance = elanUtils.getMacEntryForElanInstance(elanInstanceName, physAddress).orElse(null);
                    if (macEntryInElanInstance != null && macEntryInElanInstance.getInterface().equals(interfaceName)) {
                        InstanceIdentifier<MacEntry> macEntryIdForElanInstance = ElanUtils.getMacEntryOperationalDataPath(elanInstanceName, physAddress);
                        tx.delete(macEntryIdForElanInstance);
                    }
                });
                elanFutures.add(future);
                addCallBack(future, srcMacAddress);
            }
            return elanFutures;
        }, ElanConstants.JOB_MAX_RETRIES);
    }
}
Also used : ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) IfIndexInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 100 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class QosNeutronUtils method getDpnForInterface.

public Uint64 getDpnForInterface(String ifName) {
    Uint64 nodeId = Uint64.ZERO;
    try {
        GetDpidFromInterfaceInput dpIdInput = new GetDpidFromInterfaceInputBuilder().setIntfName(ifName).build();
        Future<RpcResult<GetDpidFromInterfaceOutput>> dpIdOutput = odlInterfaceRpcService.getDpidFromInterface(dpIdInput);
        RpcResult<GetDpidFromInterfaceOutput> dpIdResult = dpIdOutput.get();
        if (dpIdResult.isSuccessful()) {
            nodeId = dpIdResult.getResult().getDpid();
        } else {
            LOG.error("Could not retrieve DPN Id for interface {}", ifName);
        }
    } catch (NullPointerException | InterruptedException | ExecutionException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Exception when getting DPN for interface {} exception ", ifName, e);
        } else {
            LOG.error("Could not retrieve DPN for interface {}", ifName);
        }
    }
    return nodeId;
}
Also used : GetDpidFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput) GetDpidFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder) GetDpidFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

Uint64 (org.opendaylight.yangtools.yang.common.Uint64)306 ArrayList (java.util.ArrayList)119 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)104 ExecutionException (java.util.concurrent.ExecutionException)86 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)66 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)65 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)64 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)64 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)64 Logger (org.slf4j.Logger)63 LoggerFactory (org.slf4j.LoggerFactory)63 Inject (javax.inject.Inject)59 Singleton (javax.inject.Singleton)59 List (java.util.List)58 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)58 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)54 Optional (java.util.Optional)49 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)48 Collections (java.util.Collections)48 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)48