Search in sources :

Example 6 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanInterfaceManager method removeElanStateForInterface.

private Elan removeElanStateForInterface(ElanInstance elanInfo, String interfaceName, WriteTransaction tx) {
    String elanName = elanInfo.getElanInstanceName();
    Elan elanState = ElanUtils.getElanByName(broker, elanName);
    if (elanState == null) {
        return elanState;
    }
    List<String> elanInterfaces = elanState.getElanInterfaces();
    boolean isRemoved = elanInterfaces.remove(interfaceName);
    if (!isRemoved) {
        return elanState;
    }
    if (elanInterfaces.isEmpty()) {
        tx.delete(LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanInstanceOperationalDataPath(elanName));
        tx.delete(LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanMacTableOperationalDataPath(elanName));
        tx.delete(LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanInfoEntriesOperationalDataPath(elanInfo.getElanTag()));
    } else {
        Elan updateElanState = new ElanBuilder().setElanInterfaces(elanInterfaces).setName(elanName).setKey(new ElanKey(elanName)).build();
        tx.put(LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanInstanceOperationalDataPath(elanName), updateElanState);
    }
    return elanState;
}
Also used : Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) ElanKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanKey) ElanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanBuilder)

Example 7 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanInterfaceManager method setupEntriesForElanInterface.

List<ListenableFuture<Void>> setupEntriesForElanInterface(ElanInstance elanInstance, ElanInterface elanInterface, InterfaceInfo interfaceInfo, boolean isFirstInterfaceInDpn) throws ElanException {
    String elanInstanceName = elanInstance.getElanInstanceName();
    String interfaceName = elanInterface.getName();
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    BigInteger dpId = interfaceInfo.getDpId();
    WriteTransaction writeFlowGroupTx = broker.newWriteOnlyTransaction();
    installEntriesForElanInterface(elanInstance, elanInterface, interfaceInfo, isFirstInterfaceInDpn, tx, writeFlowGroupTx);
    List<StaticMacEntries> staticMacEntriesList = elanInterface.getStaticMacEntries();
    List<PhysAddress> staticMacAddresses = Lists.newArrayList();
    boolean isInterfaceOperational = isOperational(interfaceInfo);
    if (ElanUtils.isNotEmpty(staticMacEntriesList)) {
        for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
            InstanceIdentifier<MacEntry> macId = getMacEntryOperationalDataPath(elanInstanceName, staticMacEntry.getMacAddress());
            Optional<MacEntry> existingMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macId);
            if (existingMacEntry.isPresent()) {
                elanForwardingEntriesHandler.updateElanInterfaceForwardingTablesList(elanInstanceName, interfaceName, existingMacEntry.get().getInterface(), existingMacEntry.get(), tx);
            } else {
                elanForwardingEntriesHandler.addElanInterfaceForwardingTableList(elanInstanceName, interfaceName, staticMacEntry, tx);
            }
            if (isInterfaceOperational) {
                // Setting SMAC, DMAC, UDMAC in this DPN and also in other
                // DPNs
                String macAddress = staticMacEntry.getMacAddress().getValue();
                LOG.info("programming smac and dmacs for {} on source and other DPNs for elan {} and interface {}", macAddress, elanInstanceName, interfaceName);
                elanUtils.setupMacFlows(elanInstance, interfaceInfo, ElanConstants.STATIC_MAC_TIMEOUT, staticMacEntry.getMacAddress().getValue(), true, writeFlowGroupTx);
            }
        }
        if (isInterfaceOperational) {
            // on purpose.
            for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
                staticMacAddresses.add(staticMacEntry.getMacAddress());
            }
            elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanInstance.getElanInstanceName(), dpId, staticMacAddresses);
        }
    }
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(ElanUtils.waitForTransactionToComplete(tx));
    futures.add(ElanUtils.waitForTransactionToComplete(writeFlowGroupTx));
    if (isInterfaceOperational && !interfaceManager.isExternalInterface(interfaceName)) {
        // At this point, the interface is operational and D/SMAC flows have been configured, mark the port active
        try {
            Port neutronPort = neutronVpnManager.getNeutronPort(interfaceName);
            if (neutronPort != null) {
                NeutronUtils.updatePortStatus(interfaceName, NeutronUtils.PORT_STATUS_ACTIVE, broker);
            }
        } catch (IllegalArgumentException ex) {
            LOG.trace("Interface: {} is not part of Neutron Network", interfaceName);
        }
    }
    return futures;
}
Also used : ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 8 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanNodeListener method addSmacLearnedTableFlow.

private void addSmacLearnedTableFlow(BigInteger dpId) {
    // T50 - match on Reg4 and goto T51
    List<MatchInfoBase> mkMatches = new ArrayList<>();
    mkMatches.add(new NxMatchRegister(NxmNxReg4.class, LEARN_MATCH_REG4_VALUE));
    List<InstructionInfo> mkInstructions = new ArrayList<>();
    mkInstructions.add(new InstructionGotoTable(NwConstants.ELAN_DMAC_TABLE));
    String flowRef = new StringBuffer().append(NwConstants.ELAN_SMAC_TABLE).append(NwConstants.FLOWID_SEPARATOR).append(LEARN_MATCH_REG4_VALUE).toString();
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_SMAC_TABLE, flowRef, 10, "ELAN sMac Table Reg4 Flow", 0, 0, ElanConstants.COOKIE_ELAN_KNOWN_SMAC.add(BigInteger.valueOf(LEARN_MATCH_REG4_VALUE)), mkMatches, mkInstructions);
    mdsalManager.installFlow(flowEntity);
}
Also used : NxmNxReg4(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg4) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) NxMatchRegister(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchRegister) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 9 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan 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();
    if (pktInReason == NoMatch.class && tableId == NwConstants.ELAN_SMAC_TABLE) {
        ElanManagerCounters.unknown_smac_pktin_rcv.inc();
        try {
            byte[] data = notification.getPayload();
            Ethernet res = new Ethernet();
            res.deserialize(data, 0, data.length * NetUtils.NUM_BITS_IN_A_BYTE);
            byte[] srcMac = res.getSourceMACAddress();
            final String macAddress = NWUtil.toStringMacAddress(srcMac);
            final BigInteger metadata = notification.getMatch().getMetadata().getMetadata();
            final long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
            long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
            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).orNull();
            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).setKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp).setIsStaticAddress(false).build();
            } else {
                newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress).setIpPrefix(srcIpAddress.get()).setKey(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).orNull();
                evpnUtils.advertisePrefix(elanInstance, macAddress, prefix, interfaceName, interfaceInfo.getDpId());
            }
            enqueueJobForMacSpecificTasks(macAddress, elanTag, interfaceName, elanName, physAddress, oldMacEntry, newMacEntry, isVlanOrFlatProviderIface);
            ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
            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) 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 10 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class L2GwValidateCli method verifyL2GatewayConnections.

private void verifyL2GatewayConnections() {
    boolean isValid = true;
    for (L2gatewayConnection l2gatewayConnection : l2gatewayConnections) {
        L2gateway l2gateway = uuidToL2Gateway.get(l2gatewayConnection.getL2gatewayId());
        String logicalSwitchName = l2gatewayConnection.getNetworkId().getValue();
        List<Devices> devices = l2gateway.getDevices();
        for (Devices device : devices) {
            L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(device.getDeviceName());
            isValid = verifyL2GatewayDevice(l2gateway, device, l2GatewayDevice);
            if (!isValid) {
                continue;
            }
            NodeId nodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
            InstanceIdentifier<Node> nodeIid = topoIid.child(Node.class, new NodeKey(nodeId));
            isValid = verfiyLogicalSwitch(logicalSwitchName, nodeIid);
            if (isValid) {
                isValid = verifyMcastMac(logicalSwitchName, nodeIid);
                verifyVlanBindings(nodeIid, logicalSwitchName, device, l2gatewayConnection.getSegmentId());
                L2GatewayDevice elanL2gatewayDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(logicalSwitchName, nodeId.getValue());
                if (elanL2gatewayDevice == null) {
                    pw.println("Failed elan l2gateway device not found for network " + logicalSwitchName + " and device " + device.getDeviceName() + " " + l2GatewayDevice.getHwvtepNodeId() + " l2gw connection id " + l2gatewayConnection.getUuid());
                }
            }
        }
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Aggregations

ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)52 BigInteger (java.math.BigInteger)36 ArrayList (java.util.ArrayList)31 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)18 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)18 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)14 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)13 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)13 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)13 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)12 ElanDpnInterfacesList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)9 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)9 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)9 Elan (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan)9 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8