Search in sources :

Example 16 with Mac

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac in project netvirt by opendaylight.

the class ElanServiceProvider method addExternalTunnelArpResponderFlow.

@Override
public void addExternalTunnelArpResponderFlow(ArpResponderInput arpResponderInput, String elanInstanceName) {
    BigInteger dpnId = arpResponderInput.getDpId();
    String ipAddress = arpResponderInput.getSpa();
    String macAddress = arpResponderInput.getSha();
    LOG.trace("Installing the ExternalTunnel ARP responder flow on DPN {} for ElanInstance {} with MAC {} & IP {}", dpnId, elanInstanceName, macAddress, ipAddress);
    ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
    if (elanInstance == null) {
        LOG.warn("Null elan instance {}", elanInstanceName);
        return;
    }
    int lportTag = arpResponderInput.getLportTag();
    String flowId = ArpResponderUtil.getFlowId(lportTag, ipAddress);
    ArpResponderUtil.installFlow(mdsalManager, dpnId, flowId, flowId, NwConstants.DEFAULT_ARP_FLOW_PRIORITY, ArpResponderUtil.generateCookie(lportTag, ipAddress), ArpResponderUtil.getMatchCriteria(lportTag, elanInstance, ipAddress), arpResponderInput.getInstructions());
    LOG.trace("Installed the ExternalTunnel ARP Responder flow for ElanInstance {}", elanInstanceName);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) BigInteger(java.math.BigInteger)

Example 17 with Mac

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac in project netvirt by opendaylight.

the class ElanServiceProvider method updateElanInterface.

@Override
public void updateElanInterface(String elanInstanceName, String interfaceName, List<String> updatedStaticMacAddresses, String newDescription) {
    Optional<ElanInterface> existingElanInterface = elanInterfaceCache.get(interfaceName);
    if (!existingElanInterface.isPresent()) {
        return;
    }
    List<StaticMacEntries> updatedStaticMacEntries = ElanUtils.getStaticMacEntries(updatedStaticMacAddresses);
    LOG.debug("updating the ElanInterface with new Mac Entries {}", updatedStaticMacAddresses);
    ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName).setName(interfaceName).setDescription(newDescription).setStaticMacEntries(updatedStaticMacEntries).setKey(new ElanInterfaceKey(interfaceName)).build();
    MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
}
Also used : ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) ElanInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey)

Example 18 with Mac

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac in project netvirt by opendaylight.

the class ElanSmacFlowEventListener method onFlowRemoved.

@Override
public void onFlowRemoved(FlowRemoved flowRemoved) {
    short tableId = flowRemoved.getTableId();
    if (tableId == NwConstants.ELAN_SMAC_TABLE) {
        BigInteger metadata = flowRemoved.getMatch().getMetadata().getMetadata();
        long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
        ElanTagName elanTagInfo = elanUtils.getElanInfoByElanTag(elanTag);
        if (elanTagInfo == null) {
            return;
        }
        final String srcMacAddress = flowRemoved.getMatch().getEthernetMatch().getEthernetSource().getAddress().getValue().toUpperCase(Locale.getDefault());
        int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
        if (portTag == 0) {
            LOG.debug("Flow removed event on SMAC flow entry. But having port Tag as 0 ");
            return;
        }
        Optional<IfIndexInterface> existingInterfaceInfo = elanUtils.getInterfaceInfoByInterfaceTag(portTag);
        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<Void>> 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);
            if (macEntry != null && interfaceInfo != null) {
                ListenableFuture<Void> result = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> elanUtils.deleteMacFlows(elanInstanceCache.get(elanInstanceName).orNull(), interfaceInfo, macEntry, 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()) {
                ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
                    tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
                    MacEntry macEntryInElanInstance = elanUtils.getMacEntryForElanInstance(elanInstanceName, physAddress).orNull();
                    if (macEntryInElanInstance != null && macEntryInElanInstance.getInterface().equals(interfaceName)) {
                        InstanceIdentifier<MacEntry> macEntryIdForElanInstance = ElanUtils.getMacEntryOperationalDataPath(elanInstanceName, physAddress);
                        tx.delete(LogicalDatastoreType.OPERATIONAL, 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) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 19 with Mac

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac in project netvirt by opendaylight.

the class LogicalSwitchAddedJob method call.

@Override
public List<ListenableFuture<Void>> call() {
    elanL2GatewayUtils.cancelDeleteLogicalSwitch(new NodeId(elanL2GwDevice.getHwvtepNodeId()), logicalSwitchName);
    LOG.debug("running logical switch added job for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    LOG.info("creating vlan bindings for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
    futures.add(elanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(new NodeId(elanL2GwDevice.getHwvtepNodeId()), logicalSwitchName, physicalDevice, defaultVlanId));
    LOG.info("creating mast mac entries for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
    futures.add(elanL2GatewayMulticastUtils.handleMcastForElanL2GwDeviceAdd(logicalSwitchName, elanL2GwDevice));
    futures.add(elanL2GatewayUtils.installElanMacsInL2GatewayDevice(logicalSwitchName, elanL2GwDevice));
    return futures;
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 20 with Mac

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac in project netvirt by opendaylight.

the class VpnInterfaceManager method addNewAdjToVpnInterface.

protected void addNewAdjToVpnInterface(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, String primaryRd, Adjacency adj, BigInteger dpnId, WriteTransaction writeOperTxn, WriteTransaction writeConfigTxn) {
    Optional<VpnInterfaceOpDataEntry> optVpnInterface = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, identifier);
    if (optVpnInterface.isPresent()) {
        VpnInterfaceOpDataEntry currVpnIntf = optVpnInterface.get();
        String prefix = VpnUtil.getIpPrefix(adj.getIpAddress());
        String vpnName = currVpnIntf.getVpnInstanceName();
        VpnInstanceOpDataEntry vpnInstanceOpData = VpnUtil.getVpnInstanceOpData(dataBroker, primaryRd);
        InstanceIdentifier<AdjacenciesOp> adjPath = identifier.augmentation(AdjacenciesOp.class);
        Optional<AdjacenciesOp> optAdjacencies = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, adjPath);
        boolean isL3VpnOverVxLan = VpnUtil.isL3VpnOverVxLan(vpnInstanceOpData.getL3vni());
        VrfEntry.EncapType encapType = VpnUtil.getEncapType(isL3VpnOverVxLan);
        long l3vni = vpnInstanceOpData.getL3vni() == null ? 0L : vpnInstanceOpData.getL3vni();
        VpnPopulator populator = L3vpnRegistry.getRegisteredPopulator(encapType);
        List<Adjacency> adjacencies;
        if (optAdjacencies.isPresent()) {
            adjacencies = optAdjacencies.get().getAdjacency();
        } else {
            // This code will be hit in case of first PNF adjacency
            adjacencies = new ArrayList<>();
        }
        long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
        L3vpnInput input = new L3vpnInput().setNextHop(adj).setVpnName(vpnName).setInterfaceName(currVpnIntf.getName()).setPrimaryRd(primaryRd).setRd(primaryRd);
        Adjacency operationalAdjacency = null;
        if (adj.getNextHopIpList() != null && !adj.getNextHopIpList().isEmpty()) {
            RouteOrigin origin = adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency ? RouteOrigin.LOCAL : RouteOrigin.STATIC;
            String nh = adj.getNextHopIpList().get(0);
            String vpnPrefixKey = VpnUtil.getVpnNamePrefixKey(vpnName, prefix);
            synchronized (vpnPrefixKey.intern()) {
                java.util.Optional<String> rdToAllocate = VpnUtil.allocateRdForExtraRouteAndUpdateUsedRdsMap(dataBroker, vpnId, null, prefix, vpnName, nh, dpnId);
                if (rdToAllocate.isPresent()) {
                    input.setRd(rdToAllocate.get());
                    operationalAdjacency = populator.createOperationalAdjacency(input);
                    int label = operationalAdjacency.getLabel().intValue();
                    vpnManager.addExtraRoute(vpnName, adj.getIpAddress(), nh, rdToAllocate.get(), currVpnIntf.getVpnInstanceName(), l3vni, origin, currVpnIntf.getName(), operationalAdjacency, encapType, writeConfigTxn);
                    LOG.info("addNewAdjToVpnInterface: Added extra route ip {} nh {} rd {} vpnname {} label {}" + " Interface {} on dpn {}", adj.getIpAddress(), nh, rdToAllocate.get(), vpnName, label, currVpnIntf.getName(), dpnId);
                } else {
                    LOG.error("addNewAdjToVpnInterface: No rds to allocate extraroute vpn {} prefix {}", vpnName, prefix);
                    return;
                }
                // Keeping the MPLS check for now.
                if (encapType.equals(VrfEntryBase.EncapType.Mplsgre)) {
                    final Adjacency opAdjacency = new AdjacencyBuilder(operationalAdjacency).build();
                    List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
                    vpnsToImportRoute.forEach(vpn -> {
                        if (vpn.getVrfId() != null) {
                            VpnUtil.allocateRdForExtraRouteAndUpdateUsedRdsMap(dataBroker, vpn.getVpnId(), vpnId, prefix, VpnUtil.getVpnName(dataBroker, vpn.getVpnId()), nh, dpnId).ifPresent(rds -> vpnManager.addExtraRoute(VpnUtil.getVpnName(dataBroker, vpn.getVpnId()), adj.getIpAddress(), nh, rds, currVpnIntf.getVpnInstanceName(), l3vni, RouteOrigin.SELF_IMPORTED, currVpnIntf.getName(), opAdjacency, encapType, writeConfigTxn));
                        }
                    });
                }
            }
        } else if (adj.isPhysNetworkFunc()) {
            // PNF adjacency.
            LOG.trace("addNewAdjToVpnInterface: Adding prefix {} to interface {} for vpn {}", prefix, currVpnIntf.getName(), vpnName);
            String parentVpnRd = getParentVpnRdForExternalSubnet(adj);
            writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, VpnUtil.getPrefixToInterfaceIdentifier(VpnUtil.getVpnId(dataBroker, adj.getSubnetId().getValue()), prefix), VpnUtil.getPrefixToInterface(BigInteger.ZERO, currVpnIntf.getName(), prefix, adj.getSubnetId(), Prefixes.PrefixCue.PhysNetFunc), true);
            fibManager.addOrUpdateFibEntry(adj.getSubnetId().getValue(), adj.getMacAddress(), adj.getIpAddress(), Collections.emptyList(), null, /* EncapType */
            0, /* label */
            0, /*l3vni*/
            null, /* gw-mac */
            parentVpnRd, RouteOrigin.LOCAL, writeConfigTxn);
            input.setRd(adj.getVrfId());
        }
        if (operationalAdjacency == null) {
            operationalAdjacency = populator.createOperationalAdjacency(input);
        }
        adjacencies.add(operationalAdjacency);
        AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(adjacencies);
        VpnInterfaceOpDataEntry newVpnIntf = VpnUtil.getVpnInterfaceOpDataEntry(currVpnIntf.getName(), currVpnIntf.getVpnInstanceName(), aug, dpnId, currVpnIntf.isScheduledForRemove(), currVpnIntf.getLportTag(), currVpnIntf.getGatewayMacAddress());
        writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, identifier, newVpnIntf, true);
    }
}
Also used : AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) VpnPopulator(org.opendaylight.netvirt.vpnmanager.populator.intfc.VpnPopulator) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) L3vpnInput(org.opendaylight.netvirt.vpnmanager.populator.input.L3vpnInput)

Aggregations

ArrayList (java.util.ArrayList)57 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)50 BigInteger (java.math.BigInteger)36 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)34 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)21 Test (org.junit.Test)20 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)19 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)18 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)18 Collections (java.util.Collections)17 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)17 List (java.util.List)16 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)16 Logger (org.slf4j.Logger)16 LoggerFactory (org.slf4j.LoggerFactory)16 ExecutionException (java.util.concurrent.ExecutionException)15 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)15 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)15 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)15 Inject (javax.inject.Inject)14