Search in sources :

Example 1 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ElanInterfaceManager method addElanInterface.

List<ListenableFuture<Void>> addElanInterface(ElanInterface elanInterface, InterfaceInfo interfaceInfo, ElanInstance elanInstance) throws ElanException {
    Preconditions.checkNotNull(elanInstance, "elanInstance cannot be null");
    Preconditions.checkNotNull(interfaceInfo, "interfaceInfo cannot be null");
    Preconditions.checkNotNull(elanInterface, "elanInterface cannot be null");
    String interfaceName = elanInterface.getName();
    String elanInstanceName = elanInterface.getElanInstanceName();
    Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    if (elanInfo == null) {
        List<String> elanInterfaces = new ArrayList<>();
        elanInterfaces.add(interfaceName);
        ElanUtils.updateOperationalDataStore(idManager, elanInstance, elanInterfaces, tx);
    } else {
        createElanStateList(elanInstanceName, interfaceName, tx);
    }
    boolean isFirstInterfaceInDpn = false;
    // Specific actions to the DPN where the ElanInterface has been added,
    // for example, programming the
    // External tunnel table if needed or adding the ElanInterface to the
    // DpnInterfaces in the operational DS.
    BigInteger dpId = interfaceInfo.getDpId();
    DpnInterfaces dpnInterfaces = null;
    if (dpId != null && !dpId.equals(ElanConstants.INVALID_DPN)) {
        InstanceIdentifier<DpnInterfaces> elanDpnInterfaces = ElanUtils.getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId);
        Optional<DpnInterfaces> existingElanDpnInterfaces = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaces);
        if (!existingElanDpnInterfaces.isPresent()) {
            isFirstInterfaceInDpn = true;
            // ELAN's 1st ElanInterface added to this DPN
            dpnInterfaces = createElanInterfacesList(elanInstanceName, interfaceName, dpId, tx);
            // table, but only if Elan has VNI
            if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
                setExternalTunnelTable(dpId, elanInstance);
            }
            elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
        } else {
            List<String> elanInterfaces = existingElanDpnInterfaces.get().getInterfaces();
            elanInterfaces.add(interfaceName);
            if (elanInterfaces.size() == 1) {
                // 1st dpn interface
                elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
            }
            dpnInterfaces = updateElanDpnInterfacesList(elanInstanceName, dpId, elanInterfaces, tx);
        }
    }
    // add code to install Local/Remote BC group, unknow DMAC entry,
    // terminating service table flow entry
    // call bindservice of interfacemanager to create ingress table flow
    // enty.
    // Add interface to the ElanInterfaceForwardingEntires Container
    createElanInterfaceTablesList(interfaceName, tx);
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(ElanUtils.waitForTransactionToComplete(tx));
    installEntriesForFirstInterfaceonDpn(elanInstance, interfaceInfo, dpnInterfaces, isFirstInterfaceInDpn);
    // for internal vlan networks
    if (ElanUtils.isVlan(elanInstance) && !elanInstance.isExternal()) {
        if (interfaceManager.isExternalInterface(interfaceName)) {
            LOG.debug("adding vlan prv intf {} to elan {} BC group", interfaceName, elanInstanceName);
            handleExternalInterfaceEvent(elanInstance, dpnInterfaces, dpId);
        }
    }
    if (isFirstInterfaceInDpn && isVxlanNetworkOrVxlanSegment(elanInstance)) {
        // update the remote-DPNs remoteBC group entry with Tunnels
        LOG.trace("update remote bc group for elan {} on other DPNs for newly added dpn {}", elanInstance, dpId);
        setElanAndEtreeBCGrouponOtherDpns(elanInstance, dpId);
    }
    String jobKey = ElanUtils.getElanInterfaceJobKey(interfaceName);
    InterfaceAddWorkerOnElanInterface addWorker = new InterfaceAddWorkerOnElanInterface(jobKey, elanInterface, interfaceInfo, elanInstance, isFirstInterfaceInDpn, this);
    jobCoordinator.enqueueJob(jobKey, addWorker, ElanConstants.JOB_MAX_RETRIES);
    return futures;
}
Also used : ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ArrayList(java.util.ArrayList) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 2 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ElanInterfaceManager method removeFilterEqualsTable.

public void removeFilterEqualsTable(ElanInstance elanInfo, InterfaceInfo interfaceInfo, WriteTransaction deleteFlowGroupTx) {
    int ifTag = interfaceInfo.getInterfaceTag();
    Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE, getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "group"), 9, elanInfo.getElanInstanceName(), 0, 0, ElanConstants.COOKIE_ELAN_FILTER_EQUALS.add(BigInteger.valueOf(ifTag)), ElanUtils.getTunnelIdMatchForFilterEqualsLPortTag(ifTag), elanUtils.getInstructionsInPortForOutGroup(interfaceInfo.getInterfaceName()));
    mdsalManager.removeFlowToTx(interfaceInfo.getDpId(), flow, deleteFlowGroupTx);
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE, getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "drop"), 10, elanInfo.getElanInstanceName(), 0, 0, ElanConstants.COOKIE_ELAN_FILTER_EQUALS.add(BigInteger.valueOf(ifTag)), getMatchesForFilterEqualsLPortTag(ifTag), MDSALUtil.buildInstructionsDrop());
    mdsalManager.removeFlowToTx(interfaceInfo.getDpId(), flowEntity, deleteFlowGroupTx);
}
Also used : Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 3 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ElanNodeListener method createL2ControlProtocolDropFlows.

private void createL2ControlProtocolDropFlows(BigInteger dpId) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    MatchEthernetDestination matchEthDst = new MatchEthernetDestination(new MacAddress(ElanConstants.L2_CONTROL_PACKETS_DMAC), new MacAddress(ElanConstants.L2_CONTROL_PACKETS_DMAC_MASK));
    mkMatches.add(matchEthDst);
    List<ActionInfo> listActionInfo = new ArrayList<>();
    listActionInfo.add(new ActionDrop());
    List<InstructionInfo> mkInstructions = new ArrayList<>();
    mkInstructions.add(new InstructionApplyActions(listActionInfo));
    String flowId = dpId.toString() + NwConstants.ELAN_DMAC_TABLE + "l2control" + ElanConstants.L2_CONTROL_PACKETS_DMAC + ElanConstants.L2_CONTROL_PACKETS_DMAC_MASK;
    FlowEntity flow = MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_DMAC_TABLE, flowId, 15, "L2 control packets dMac Table Flow", 0, 0, ElanConstants.COOKIE_ELAN_KNOWN_DMAC, mkMatches, mkInstructions);
    mdsalManager.installFlow(flow);
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 4 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow 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 5 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ElanEvpnFlowUtils method evpnRemoveTheDropFlow.

private List<ListenableFuture<Void>> evpnRemoveTheDropFlow(long elanTag, BigInteger dpId, String nexthopIp, String macToRemove) {
    String flowId = ElanEvpnFlowUtils.evpnGetKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, nexthopIp, macToRemove, elanTag, true);
    Flow flowToRemove = new FlowBuilder().setId(new FlowId(flowId)).setTableId(NwConstants.ELAN_DMAC_TABLE).build();
    return Collections.singletonList(mdsalManager.removeFlow(dpId, flowToRemove));
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) 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)

Aggregations

Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)155 ArrayList (java.util.ArrayList)127 BigInteger (java.math.BigInteger)83 Test (org.junit.Test)67 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)65 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)55 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)51 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)47 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)44 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)41 List (java.util.List)36 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)35 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)35 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)33 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)31 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)30 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)30 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)28 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)24 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)24