Search in sources :

Example 21 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project netvirt by opendaylight.

the class ElanServiceChainUtils method programLPortDispatcherToScf.

/**
 * This flow is in charge of handling packets coming from ExtTunnelTable
 * that must be redirected to the SCF Pipeline.
 *  + Matches on lportTag=ElanPseudoLportTag + SI=1
 *  + Sets scfTag and sends to the DlSubsFilter table.
 *
 * @param dpnId Dpn Id where the flow must be installed
 * @param elanLportTag the Elan Pseudo Lport Id in Dataplane
 * @param elanTag the Elan Id in the Dataplane
 * @param addOrRemove States if the flow must be added or removed
 */
public static void programLPortDispatcherToScf(IMdsalApiManager mdsalManager, BigInteger dpnId, long elanTag, int elanLportTag, short tableId, long scfTag, int addOrRemove) {
    LOG.info("L2-ServiceChaining: programLPortDispatcherToScf dpId={} elanLportTag={} scfTag={} addOrRemove={} ", dpnId, elanLportTag, scfTag, addOrRemove);
    String flowRef = buildLportDispToScfFlowRef(elanLportTag, scfTag);
    if (addOrRemove == NwConstants.ADD_FLOW) {
        int instructionKey = 0;
        List<Instruction> instructions = new ArrayList<>();
        List<ActionInfo> actionsInfos = new ArrayList<>();
        actionsInfos.add(new ActionRegLoad(NxmNxReg2.class, 0, 31, scfTag));
        instructions.add(MDSALUtil.buildApplyActionsInstruction(MDSALUtil.buildActions(actionsInfos), instructionKey++));
        instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(tableId, instructionKey++));
        List<MatchInfo> matches = Collections.singletonList(new MatchMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(elanLportTag, ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX)), MetaDataUtil.getMetaDataMaskForLPortDispatcher()));
        Flow flow = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, flowRef, 0, 0, CloudServiceChainConstants.COOKIE_LPORT_DISPATCHER_BASE.add(BigInteger.valueOf(elanTag)), matches, instructions);
        mdsalManager.installFlow(dpnId, flow);
    } else {
        Flow flow = new FlowBuilder().setTableId(NwConstants.LPORT_DISPATCHER_TABLE).setId(new FlowId(flowRef)).build();
        mdsalManager.removeFlow(dpnId, flow);
    }
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) NxmNxReg2(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2) ArrayList(java.util.ArrayList) ActionRegLoad(org.opendaylight.genius.mdsalutil.actions.ActionRegLoad) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) 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) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo)

Example 22 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project netvirt by opendaylight.

the class VpnServiceChainUtils method buildLPortDispFromScfToL3VpnFlow.

/**
 * Build the flow that must be inserted when there is a ScHop whose
 * egressPort is a VPN Pseudo Port. In that case, packets must be moved
 * from the SCF to VPN Pipeline.
 * <p>
 * Flow matches:  VpnPseudo port lPortTag + SI=L3VPN
 * Actions: Write vrfTag in Metadata + goto FIB Table
 * </p>
 * @param vpnId Dataplane identifier of the VPN, the Vrf Tag.
 * @param dpId The DPN where the flow must be installed/removed
 * @param lportTag Dataplane identifier for the VpnPseudoPort
 * @param addOrRemove States if it must build a Flow to be created or
 *     removed
 *
 * @return the Flow object
 */
public static Flow buildLPortDispFromScfToL3VpnFlow(Long vpnId, BigInteger dpId, Integer lportTag, int addOrRemove) {
    LOG.info("buildLPortDispFlowForScf vpnId={} dpId={} lportTag={} addOrRemove={} ", vpnId, dpId, lportTag, addOrRemove);
    List<MatchInfo> matches = buildMatchOnLportTagAndSI(lportTag, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX));
    List<Instruction> instructions = buildSetVrfTagAndGotoFibInstructions(vpnId.intValue());
    String flowRef = getScfToL3VpnLportDispatcherFlowRef(lportTag);
    Flow result;
    if (addOrRemove == NwConstants.ADD_FLOW) {
        result = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, flowRef, 0, 0, VpnServiceChainUtils.getCookieL3(vpnId.intValue()), matches, instructions);
    } else {
        result = new FlowBuilder().setTableId(NwConstants.LPORT_DISPATCHER_TABLE).setId(new FlowId(flowRef)).build();
    }
    return result;
}
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) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 23 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project netvirt by opendaylight.

the class ArpResponderUtil method installFlow.

/**
 * Install ARP Responder FLOW.
 *
 * @param mdSalManager
 *            Reference of MDSAL API RPC that provides API for installing
 *            flow
 * @param dpnId
 *            DPN on which flow to be installed
 * @param flowId
 *            Uniquely Identifiable Arp Responder Table flow Id
 * @param flowName
 *            Readable flow name
 * @param priority
 *            Flow Priority
 * @param cookie
 *            Flow Cookie
 * @param matches
 *            List of Match Criteria for the flow
 * @param instructions
 *            List of Instructions for the flow
 */
public static void installFlow(IMdsalApiManager mdSalManager, BigInteger dpnId, String flowId, String flowName, int priority, BigInteger cookie, List<MatchInfo> matches, List<Instruction> instructions) {
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ARP_RESPONDER_TABLE, flowId, priority, flowName, 0, 0, cookie, matches, instructions);
    mdSalManager.installFlow(dpnId, flowEntity);
}
Also used : Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 24 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project netvirt by opendaylight.

the class VPNServiceChainHandler method removeVpnPseudoPortFlows.

/**
 * Removes all Flows in LFIB and LPortDispatcher that are related to this VpnPseudoLPort.
 *
 * @param vpnInstanceName vpn Instance name
 * @param vpnPseudoLportTag vpnPseudoLPort tag
 */
public void removeVpnPseudoPortFlows(String vpnInstanceName, int vpnPseudoLportTag) {
    // At VpnPseudoPort removal time the current Vpn footprint could not be enough, so let's try to
    // remove all possible entries in all DPNs.
    // TODO: Study how this could be enhanced. It could be done at ServiceChain removal, but that
    // could imply check all ServiceChains ending in all DPNs in Vpn footprint to decide that if the entries
    // can be removed, and that sounds even costlier than this.
    String rd = VpnServiceChainUtils.getVpnRd(dataBroker, vpnInstanceName);
    List<VrfEntry> vrfEntries = null;
    if (rd != null) {
        vrfEntries = VpnServiceChainUtils.getAllVrfEntries(dataBroker, rd);
    }
    boolean cleanLFib = vrfEntries != null && !vrfEntries.isEmpty();
    List<BigInteger> operativeDPNs = NWUtil.getOperativeDPNs(dataBroker);
    for (BigInteger dpnId : operativeDPNs) {
        if (cleanLFib) {
            VpnServiceChainUtils.programLFibEntriesForSCF(mdsalManager, dpnId, vrfEntries, vpnPseudoLportTag, NwConstants.DEL_FLOW);
        }
        String vpnToScfflowRef = VpnServiceChainUtils.getL3VpnToScfLportDispatcherFlowRef(vpnPseudoLportTag);
        Flow vpnToScfFlow = new FlowBuilder().setTableId(NwConstants.LPORT_DISPATCHER_TABLE).setId(new FlowId(vpnToScfflowRef)).build();
        mdsalManager.removeFlow(dpnId, vpnToScfFlow);
        String scfToVpnFlowRef = VpnServiceChainUtils.getScfToL3VpnLportDispatcherFlowRef(vpnPseudoLportTag);
        Flow scfToVpnFlow = new FlowBuilder().setTableId(NwConstants.LPORT_DISPATCHER_TABLE).setId(new FlowId(scfToVpnFlowRef)).build();
        mdsalManager.removeFlow(dpnId, scfToVpnFlow);
    }
    if (rd != null) {
        RemoveVpnPseudoPortDataJob removeVpnPseudoPortDataTask = new RemoveVpnPseudoPortDataJob(dataBroker, rd);
        jobCoordinator.enqueueJob(removeVpnPseudoPortDataTask.getDsJobCoordinatorKey(), removeVpnPseudoPortDataTask);
    }
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) BigInteger(java.math.BigInteger) RemoveVpnPseudoPortDataJob(org.opendaylight.netvirt.cloudservicechain.jobs.RemoveVpnPseudoPortDataJob) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 25 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.

the class LearningSwitchHandlerSimpleImpl method onSwitchAppeared.

@Override
public synchronized void onSwitchAppeared(InstanceIdentifier<Table> appearedTablePath) {
    if (isLearning) {
        LOG.debug("already learning a node, skipping {}", nodeId.getValue());
        return;
    }
    LOG.debug("expected table acquired, learning ..");
    // disable listening - simple learning handles only one node (switch)
    if (registrationPublisher != null) {
        LOG.debug("closing dataTreeChangeListenerRegistration");
        registrationPublisher.getDataTreeChangeListenerRegistration().close();
    }
    isLearning = true;
    tablePath = appearedTablePath;
    nodePath = tablePath.firstIdentifierOf(Node.class);
    nodeId = nodePath.firstKeyOf(Node.class, NodeKey.class).getId();
    mac2portMapping = new HashMap<>();
    // start forwarding all packages to controller
    FlowId flowId = new FlowId(String.valueOf(flowIdInc.getAndIncrement()));
    FlowKey flowKey = new FlowKey(flowId);
    InstanceIdentifier<Flow> flowPath = InstanceIdentifierUtils.createFlowPath(tablePath, flowKey);
    int priority = 0;
    // create flow in table with id = 0, priority = 4 (other params are
    // defaulted in OFDataStoreUtil)
    FlowBuilder allToCtrlFlow = FlowUtils.createFwdAllToControllerFlow(InstanceIdentifierUtils.getTableId(tablePath), priority, flowId);
    LOG.debug("writing packetForwardToController flow");
    dataStoreAccessor.writeFlowToConfig(flowPath, allToCtrlFlow.build());
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Aggregations

FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)79 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)53 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)46 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)43 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)25 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)24 ArrayList (java.util.ArrayList)22 BigInteger (java.math.BigInteger)21 Test (org.junit.Test)21 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)21 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)19 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)15 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)13 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)10 List (java.util.List)9 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)9 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)8 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)8 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)8