Search in sources :

Example 96 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of 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 97 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of in project netvirt by opendaylight.

the class ArpResponderUtil method getEgressActionsForInterface.

/**
 * Get List of Egress Action for the VPN interface.
 *
 * @param ifaceMgrRpcService
 *            Interface Manager RPC reference that invokes API to retrieve
 *            Egress Action
 * @param ifName
 *            VPN Interface for which Egress Action to be retrieved
 * @param actionCounter
 *            Action Key
 * @return List of Egress Actions
 */
public static List<Action> getEgressActionsForInterface(IInterfaceManager ifaceMgrRpcService, String ifName, int actionCounter) {
    List<ActionInfo> actionInfos = ifaceMgrRpcService.getInterfaceEgressActions(ifName);
    AtomicInteger counter = new AtomicInteger(actionCounter);
    return actionInfos.stream().map(v -> v.buildAction(counter.getAndIncrement())).collect(Collectors.toList());
}
Also used : Arrays(java.util.Arrays) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) LoggerFactory(org.slf4j.LoggerFactory) NxActionResubmitRpcAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.group.input.buckets.bucket.action.action.NxActionResubmitRpcAddGroupCase) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) Future(java.util.concurrent.Future) MatchArpTpa(org.opendaylight.genius.mdsalutil.matches.MatchArpTpa) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BigInteger(java.math.BigInteger) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) ActionLoadMacToSha(org.opendaylight.genius.mdsalutil.actions.ActionLoadMacToSha) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionMoveSpaToTpa(org.opendaylight.genius.mdsalutil.actions.ActionMoveSpaToTpa) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ActionLoadIpToSpa(org.opendaylight.genius.mdsalutil.actions.ActionLoadIpToSpa) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) ActionNxLoadInPort(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort) Collectors(java.util.stream.Collectors) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) List(java.util.List) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ActionSetArpOp(org.opendaylight.genius.mdsalutil.actions.ActionSetArpOp) MatchArpOp(org.opendaylight.genius.mdsalutil.matches.MatchArpOp) Supplier(java.util.function.Supplier) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) ActionMoveShaToTha(org.opendaylight.genius.mdsalutil.actions.ActionMoveShaToTha) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionPuntToController(org.opendaylight.genius.mdsalutil.actions.ActionPuntToController) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Logger(org.slf4j.Logger) ElanHelper(org.opendaylight.netvirt.elanmanager.api.ElanHelper) GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity) ActionMoveSourceDestinationEth(org.opendaylight.genius.mdsalutil.actions.ActionMoveSourceDestinationEth) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) ExecutionException(java.util.concurrent.ExecutionException) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) Collections(java.util.Collections) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo)

Example 98 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of 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 99 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of in project netvirt by opendaylight.

the class ElanServiceChainHandler method programElanScfPipeline.

/**
 * Programs the needed flows for sending traffic to the SCF pipeline when
 * it is comming from an L2-GW (ELAN) and also for handing over that
 * traffic from SCF to ELAN when the packets does not match any Service
 * Chain.
 *
 * @param elanName Name of the ELAN to be considered
 * @param tableId Table id, in the SCF Pipeline, to which the traffic must
 *        go to.
 * @param scfTag Tag of the ServiceChain
 * @param elanLportTag LPortTag of the ElanPseudoPort that participates in
 *        the ServiceChain
 * @param addOrRemove States if the flows must be created or removed
 */
public void programElanScfPipeline(String elanName, short tableId, long scfTag, int elanLportTag, int addOrRemove) {
    LOG.info("programElanScfPipeline:  elanName={}   scfTag={}   elanLportTag={}    addOrRemove={}", elanName, scfTag, elanLportTag, addOrRemove);
    // There are 3 rules to be considered:
    // 1. LportDispatcher To Scf. Matches on elanPseudoPort + SI=1. Goes to DL Subscriber table
    // 2. LportDispatcher From Scf. Matches on elanPseudoPort + SI=3. Goes to ELAN DMAC
    // 3. ExtTunnelTable From L2GwDevice. Matches on VNI + SI=1. Sets ElanPseudoPort tag and goes
    // to LportDispatcher table.
    // And these rules must be programmed in all the Elan footprint
    // Find the ElanInstance
    Optional<ElanInstance> elanInstance = ElanServiceChainUtils.getElanInstanceByName(broker, elanName);
    if (!elanInstance.isPresent()) {
        LOG.debug("Could not find an Elan Instance with name={}", elanName);
        return;
    }
    Collection<BigInteger> elanDpnsOpc = ElanServiceChainUtils.getElanDpnsByName(broker, elanName);
    if (elanDpnsOpc.isEmpty()) {
        LOG.debug("Could not find any DPN related to Elan {}", elanName);
        return;
    }
    // updates map which stores relationship between elan and elanLPortTag and scfTag
    ElanServiceChainUtils.updateElanToLportTagMap(broker, elanName, elanLportTag, scfTag, addOrRemove);
    Long vni = elanInstance.get().getSegmentationId();
    if (vni == null) {
        LOG.warn("There is no VNI for elan {}. VNI is mandatory. Returning", elanName);
        return;
    }
    int elanTag = elanInstance.get().getElanTag().intValue();
    LOG.debug("elanName={}  ->  vni={}  elanTag={}", elanName, vni, elanTag);
    // Program ExtTunnelTable.
    for (BigInteger dpnId : elanDpnsOpc) {
        ElanServiceChainUtils.programLPortDispatcherToScf(mdsalManager, dpnId, elanTag, elanLportTag, tableId, scfTag, addOrRemove);
        ElanServiceChainUtils.programLPortDispatcherFromScf(mdsalManager, dpnId, elanLportTag, elanTag, addOrRemove);
        ElanServiceChainUtils.programExternalTunnelTable(mdsalManager, dpnId, elanLportTag, vni, elanTag, addOrRemove);
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) BigInteger(java.math.BigInteger)

Example 100 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of in project netvirt by opendaylight.

the class VPNServiceChainHandler method programVpnToScfPipeline.

/**
 * Programs the necessary flows in LFIB and LPortDispatcher table so that
 * the packets coming from a given VPN are delivered to a given
 * ServiceChain Pipeline.
 *
 * @param vpnName Name of the VPN. Typically the UUID
 * @param tableId Table to which the LPortDispatcher table sends the packet
 *                 to (Uplink or Downlink Subsc table)
 * @param scfTag Scf tag to the SCF to which the Vpn is linked to.
 * @param lportTag VpnPseudo Port lportTag
 * @param addOrRemove States if the VPN2SCF Pipeline must be installed or
 *        removed
 */
public void programVpnToScfPipeline(String vpnName, short tableId, long scfTag, int lportTag, int addOrRemove) {
    // This entries must be created in the DPN where the CGNAT is installed. Since it is not possible
    // to know where CGNAT is located, this entries are installed in all the VPN footprint.
    // LFIB:
    // - Match: cgnatLabel   Instr: lportTag=vpnPseudoPortTag + SI=SCF  +  GOTO 17
    // LportDisp:
    // - Match: vpnPseudoPortTag + SI==SCF   Instr:  scfTag  +  GOTO 70
    LOG.info("programVpnToScfPipeline ({}) : Parameters VpnName:{} tableId:{} scftag:{}  lportTag:{}", addOrRemove == NwConstants.ADD_FLOW ? "Creation" : "Removal", vpnName, tableId, scfTag, lportTag);
    String rd = VpnServiceChainUtils.getVpnRd(dataBroker, vpnName);
    LOG.debug("Router distinguisher (rd):{}", rd);
    if (rd == null || rd.isEmpty()) {
        LOG.warn("programVpnToScfPipeline: Could not find Router-distinguisher for VPN {}. No further actions", vpnName);
        return;
    }
    VpnInstanceOpDataEntry vpnInstance = getVpnInstance(rd);
    if (vpnInstance == null) {
        LOG.warn("Could not find a suitable VpnInstance for Route-Distinguisher={}", rd);
        return;
    }
    // Find out the set of DPNs for the given VPN ID
    Collection<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
    List<VrfEntry> vrfEntries = VpnServiceChainUtils.getAllVrfEntries(dataBroker, rd);
    if (vrfEntries != null) {
        if (addOrRemove == NwConstants.ADD_FLOW) {
            AddVpnPseudoPortDataJob updateVpnToPseudoPortTask = new AddVpnPseudoPortDataJob(dataBroker, rd, lportTag, tableId, (int) scfTag);
            jobCoordinator.enqueueJob(updateVpnToPseudoPortTask.getDsJobCoordinatorKey(), updateVpnToPseudoPortTask);
        } else {
            RemoveVpnPseudoPortDataJob removeVpnPseudoPortDataTask = new RemoveVpnPseudoPortDataJob(dataBroker, rd);
            jobCoordinator.enqueueJob(removeVpnPseudoPortDataTask.getDsJobCoordinatorKey(), removeVpnPseudoPortDataTask);
        }
        for (VpnToDpnList dpnInVpn : vpnToDpnList) {
            BigInteger dpnId = dpnInVpn.getDpnId();
            programVpnToScfPipelineOnDpn(dpnId, vrfEntries, tableId, (int) scfTag, lportTag, addOrRemove);
            if (dpnInVpn.getVpnInterfaces() != null) {
                long vpnId = vpnInstance.getVpnId();
                Flow flow = VpnServiceChainUtils.buildLPortDispFromScfToL3VpnFlow(vpnId, dpnId, lportTag, NwConstants.ADD_FLOW);
                if (addOrRemove == NwConstants.ADD_FLOW) {
                    mdsalManager.installFlow(dpnId, flow);
                } else {
                    mdsalManager.removeFlow(dpnId, flow);
                }
                dpnInVpn.getVpnInterfaces().forEach(vpnIf -> {
                    if (addOrRemove == NwConstants.ADD_FLOW) {
                        bindScfOnVpnInterface(vpnIf.getInterfaceName(), (int) scfTag);
                    } else {
                        unbindScfOnVpnInterface(vpnIf.getInterfaceName());
                    }
                });
            }
        }
    }
}
Also used : 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) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) BigInteger(java.math.BigInteger) AddVpnPseudoPortDataJob(org.opendaylight.netvirt.cloudservicechain.jobs.AddVpnPseudoPortDataJob) RemoveVpnPseudoPortDataJob(org.opendaylight.netvirt.cloudservicechain.jobs.RemoveVpnPseudoPortDataJob) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Aggregations

ArrayList (java.util.ArrayList)300 Test (org.junit.Test)245 ByteBuf (io.netty.buffer.ByteBuf)224 BigInteger (java.math.BigInteger)110 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)109 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)100 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)100 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder)99 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)98 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder)93 ApplyActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)91 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)89 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)85 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)83 DropActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder)82 ControllerActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder)81 DropAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction)81 PushMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder)81 PushPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder)81 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)80