Search in sources :

Example 46 with Table

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

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

the class ArpResponderUtil method getExtInterfaceInstructions.

/**
 * Get instruction list for ARP responder flows originated from ext-net e.g.
 * router-gw/fip.<br>
 * The split-horizon bit should be reset in order to allow traffic from
 * provider network to be routed back to flat/VLAN network and override the
 * egress table drop flow.<br>
 * In order to allow write-metadata in the ARP responder table the resubmit
 * action needs to be replaced with goto instruction.
 */
public static List<Instruction> getExtInterfaceInstructions(IInterfaceManager ifaceMgrRpcService, String extInterfaceName, String ipAddress, String macAddress) {
    AtomicInteger tableId = new AtomicInteger(-1);
    List<Instruction> instructions = new ArrayList<>();
    List<Action> actions = getActions(ifaceMgrRpcService, extInterfaceName, ipAddress, macAddress);
    actions.removeIf(v -> {
        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = v.getAction();
        if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
            tableId.set(((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable());
            return true;
        } else {
            return false;
        }
    });
    instructions.add(MDSALUtil.buildApplyActionsInstruction(actions, 0));
    if (tableId.get() != -1) {
        // write-metadata
        if ((short) tableId.get() > NwConstants.ARP_RESPONDER_TABLE) {
            instructions.add(new InstructionGotoTable((short) tableId.get()).buildInstruction(2));
        } else {
            LOG.warn("Failed to insall responder flow for interface {}. Resubmit to {} can't be replaced with goto", extInterfaceName, tableId);
        }
    }
    return instructions;
}
Also used : NxActionResubmitRpcAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.group.input.buckets.bucket.action.action.NxActionResubmitRpcAddGroupCase) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 48 with Table

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

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table 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)

Example 50 with Table

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

the class ElanMacTableGet method doExecute.

@Override
protected Object doExecute() {
    LOG.debug("Executing elan mac table get command for {}", elanName);
    Collection<MacEntry> macTables = elanProvider.getElanMacTable(elanName);
    if (!macTables.isEmpty()) {
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy:HH:mm:ss");
        session.getConsole().println(getMacTableHeaderOutput());
        session.getConsole().println(elanName);
        for (MacEntry mac : macTables) {
            boolean isStatic = mac.isIsStaticAddress();
            session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", mac.getInterface(), mac.getMacAddress().getValue(), ""));
            session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", isStatic, "", isStatic ? "-" : formatter.format(new Date(mac.getControllerLearnedForwardingEntryTimestamp().longValue()))));
        }
    }
    return null;
}
Also used : MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

ArrayList (java.util.ArrayList)71 BigInteger (java.math.BigInteger)63 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)51 Test (org.junit.Test)38 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)27 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)27 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)26 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)25 List (java.util.List)25 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)25 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)23 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)22 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)22 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)20 ByteBuf (io.netty.buffer.ByteBuf)18 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)18 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)17 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)17 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)17 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)17