Search in sources :

Example 41 with ActionInfo

use of org.opendaylight.genius.mdsalutil.ActionInfo in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method createRemoteFibEntry.

private void createRemoteFibEntry(final BigInteger remoteDpnId, final long vpnId, final VrfTablesKey vrfTableKey, final VrfEntry vrfEntry, boolean isNatPrefix, WriteTransaction tx) {
    String rd = vrfTableKey.getRouteDistinguisher();
    List<SubTransaction> subTxns = new ArrayList<>();
    LOG.debug("createremotefibentry: adding route {} for rd {} with transaction {}", vrfEntry.getDestPrefix(), rd, tx);
    List<NexthopManager.AdjacencyResult> tunnelInterfaceList = resolveAdjacency(remoteDpnId, vpnId, vrfEntry, rd);
    if (tunnelInterfaceList.isEmpty()) {
        LOG.error("Could not get interface for route-paths: {} in vpn {}", vrfEntry.getRoutePaths(), rd);
        LOG.warn("Failed to add Route: {} in vpn: {}", vrfEntry.getDestPrefix(), rd);
        return;
    }
    for (NexthopManager.AdjacencyResult adjacencyResult : tunnelInterfaceList) {
        List<ActionInfo> actionInfos = new ArrayList<>();
        BigInteger tunnelId;
        String prefix = adjacencyResult.getPrefix();
        Prefixes prefixInfo = getFibUtil().getPrefixToInterface(vpnId, prefix);
        String interfaceName = prefixInfo.getVpnInterfaceName();
        if (vrfEntry.getOrigin().equals(RouteOrigin.BGP.getValue()) || isNatPrefix) {
            tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
        } else if (elanManager.isOpenStackVniSemanticsEnforced()) {
            tunnelId = BigInteger.valueOf(getFibUtil().getVniForVxlanNetwork(prefixInfo.getSubnetId()).get());
        } else {
            Interface interfaceState = getFibUtil().getInterfaceStateFromOperDS(interfaceName);
            tunnelId = BigInteger.valueOf(interfaceState.getIfIndex());
        }
        LOG.debug("adding set tunnel id action for label {}", tunnelId);
        String macAddress = null;
        String vpnName = getFibUtil().getVpnNameFromId(vpnId);
        if (vpnName == null) {
            LOG.debug("Failed to get VPN name for vpnId {}", vpnId);
            return;
        }
        if (interfaceName != null) {
            macAddress = getFibUtil().getMacAddressFromPrefix(interfaceName, vpnName, prefix);
            actionInfos.add(new ActionSetFieldEthernetDestination(new MacAddress(macAddress)));
        }
        actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
        List<ActionInfo> egressActions = nexthopManager.getEgressActionsForInterface(adjacencyResult.getInterfaceName(), actionInfos.size());
        if (egressActions.isEmpty()) {
            LOG.error("Failed to retrieve egress action for prefix {} route-paths {} interface {}." + " Aborting remote FIB entry creation..", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), adjacencyResult.getInterfaceName());
            return;
        }
        actionInfos.addAll(egressActions);
        List<InstructionInfo> instructions = new ArrayList<>();
        instructions.add(new InstructionApplyActions(actionInfos));
        makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, subTxns);
    }
    LOG.debug("Successfully added FIB entry for prefix {} in rd {}", vrfEntry.getDestPrefix(), rd);
}
Also used : SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) BigInteger(java.math.BigInteger) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 42 with ActionInfo

use of org.opendaylight.genius.mdsalutil.ActionInfo in project netvirt by opendaylight.

the class VpnNodeListener method makeSubnetRouteTableMissFlow.

private void makeSubnetRouteTableMissFlow(WriteTransaction writeFlowTx, BigInteger dpnId, int addOrRemove) {
    final BigInteger cookieTableMiss = new BigInteger("8000004", 16);
    List<ActionInfo> actionsInfos = new ArrayList<>();
    List<InstructionInfo> instructions = new ArrayList<>();
    actionsInfos.add(new ActionPuntToController());
    instructions.add(new InstructionApplyActions(actionsInfos));
    List<MatchInfo> matches = new ArrayList<>();
    String flowRef = getTableMissFlowRef(dpnId, NwConstants.L3_SUBNET_ROUTE_TABLE, NwConstants.TABLE_MISS_FLOW);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_SUBNET_ROUTE_TABLE, flowRef, NwConstants.TABLE_MISS_PRIORITY, "Subnet Route Table Miss", 0, 0, cookieTableMiss, matches, instructions);
    if (addOrRemove == NwConstants.ADD_FLOW) {
        mdsalManager.addFlowToTx(flowEntity, writeFlowTx);
    } else {
        mdsalManager.removeFlowToTx(flowEntity, writeFlowTx);
    }
}
Also used : InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionPuntToController(org.opendaylight.genius.mdsalutil.actions.ActionPuntToController) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) BigInteger(java.math.BigInteger) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 43 with ActionInfo

use of org.opendaylight.genius.mdsalutil.ActionInfo in project netvirt by opendaylight.

the class VpnNodeListener method createTableMissForVpnGwFlow.

private void createTableMissForVpnGwFlow(WriteTransaction writeFlowTx, BigInteger dpId) {
    List<MatchInfo> matches = new ArrayList<>();
    List<ActionInfo> actionsInfos = Collections.singletonList(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
    List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(actionsInfos));
    FlowEntity flowEntityMissforGw = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_GW_MAC_TABLE, getTableMissFlowRef(dpId, NwConstants.L3_GW_MAC_TABLE, NwConstants.TABLE_MISS_FLOW), NwConstants.TABLE_MISS_PRIORITY, "L3 Gw Mac Table Miss", 0, 0, new BigInteger("1080000", 16), matches, instructions);
    LOG.trace("Invoking MDSAL to install L3 Gw Mac Table Miss Entry");
    mdsalManager.addFlowToTx(flowEntityMissforGw, writeFlowTx);
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) BigInteger(java.math.BigInteger) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 44 with ActionInfo

use of org.opendaylight.genius.mdsalutil.ActionInfo in project netvirt by opendaylight.

the class DhcpManager method setupDhcpAllocationPoolFlow.

private void setupDhcpAllocationPoolFlow(BigInteger dpId) {
    List<MatchInfo> matches = DhcpServiceUtils.getDhcpMatch();
    List<InstructionInfo> instructions = new ArrayList<>();
    List<ActionInfo> actionsInfos = new ArrayList<>();
    actionsInfos.add(new ActionPuntToController());
    instructions.add(new InstructionApplyActions(actionsInfos));
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.DHCP_TABLE, "DhcpAllocationPoolFlow", DhcpMConstants.DEFAULT_DHCP_ALLOCATION_POOL_FLOW_PRIORITY, "Dhcp Allocation Pool Flow", 0, 0, DhcpMConstants.COOKIE_DHCP_BASE, matches, instructions);
    LOG.trace("Installing DHCP Allocation Pool Flow DpId {}", dpId);
    DhcpServiceCounters.install_dhcp_flow.inc();
    mdsalUtil.installFlow(flowEntity);
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionPuntToController(org.opendaylight.genius.mdsalutil.actions.ActionPuntToController) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 45 with ActionInfo

use of org.opendaylight.genius.mdsalutil.ActionInfo 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)

Aggregations

ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)133 ArrayList (java.util.ArrayList)97 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)74 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)73 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)52 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)39 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)33 Test (org.junit.Test)32 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)32 BigInteger (java.math.BigInteger)26 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)20 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)17 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)16 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)15 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)14 ActionNxConntrack (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack)12 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)12 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)12 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)11 ActionDrop (org.opendaylight.genius.mdsalutil.actions.ActionDrop)9