Search in sources :

Example 36 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.

the class ElanUtils method buildDmacRedirectToDispatcherFlow.

public static FlowEntity buildDmacRedirectToDispatcherFlow(BigInteger dpId, String dstMacAddress, String displayName, long elanTag) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
    matches.add(new MatchEthernetDestination(new MacAddress(dstMacAddress)));
    List<InstructionInfo> instructions = new ArrayList<>();
    List<ActionInfo> actions = new ArrayList<>();
    actions.add(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
    instructions.add(new InstructionApplyActions(actions));
    String flowId = getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, dstMacAddress, elanTag);
    return MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_DMAC_TABLE, flowId, 20, displayName, 0, 0, ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), matches, instructions);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) 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) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 37 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.

the class ElanUtils method buildKnownSmacFlow.

public FlowEntity buildKnownSmacFlow(ElanInstance elanInfo, InterfaceInfo interfaceInfo, long macTimeout, String macAddress) {
    int lportTag = interfaceInfo.getInterfaceTag();
    // Matching metadata and eth_src fields
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanInfo.getElanTag(), lportTag), ElanHelper.getElanMetadataMask()));
    mkMatches.add(new MatchEthernetSource(new MacAddress(macAddress)));
    List<InstructionInfo> mkInstructions = new ArrayList<>();
    mkInstructions.add(new InstructionGotoTable(NwConstants.ELAN_DMAC_TABLE));
    BigInteger dpId = interfaceInfo.getDpId();
    long elanTag = getElanTag(elanInfo, interfaceInfo);
    return new FlowEntityBuilder().setDpnId(dpId).setTableId(NwConstants.ELAN_SMAC_TABLE).setFlowId(getKnownDynamicmacFlowRef(NwConstants.ELAN_SMAC_TABLE, dpId, lportTag, macAddress, elanTag)).setPriority(20).setFlowName(elanInfo.getDescription()).setIdleTimeOut((int) macTimeout).setHardTimeOut(0).setCookie(ElanConstants.COOKIE_ELAN_KNOWN_SMAC.add(BigInteger.valueOf(elanTag))).setMatchInfoList(mkMatches).setInstructionInfoList(mkInstructions).setStrictFlag(true).setSendFlowRemFlag(macTimeout != 0).build();
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) FlowEntityBuilder(org.opendaylight.genius.mdsalutil.FlowEntityBuilder) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) MatchEthernetSource(org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource) ArrayList(java.util.ArrayList) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) BigInteger(java.math.BigInteger)

Example 38 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.

the class ElanUtils method buildRemoteDmacFlowEntry.

/**
 * Builds a Flow to be programmed in a remote DPN's DMAC table. This flow
 * consists in: Match: + elanTag in packet's metadata + packet going to a
 * MAC known to be located in another DPN Actions: + set_tunnel_id
 * + output ITM internal tunnel interface with the other DPN
 *
 * @param srcDpId
 *            the src Dpn Id
 * @param destDpId
 *            dest Dp Id
 * @param lportTagOrVni
 *            lportTag or network VNI
 * @param elanTag
 *            elan Tag
 * @param macAddress
 *            macAddress
 * @param displayName
 *            display Name
 * @param elanInstance
 *            elanInstance
 * @return the flow remote Dmac
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public Flow buildRemoteDmacFlowEntry(BigInteger srcDpId, BigInteger destDpId, long lportTagOrVni, long elanTag, String macAddress, String displayName, ElanInstance elanInstance) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
    mkMatches.add(new MatchEthernetDestination(new MacAddress(macAddress)));
    List<Instruction> mkInstructions = new ArrayList<>();
    // List of Action for the provided Source and Destination DPIDs
    try {
        List<Action> actions = null;
        if (isVlan(elanInstance) || isFlat(elanInstance)) {
            String interfaceName = getExternalElanInterface(elanInstance.getElanInstanceName(), srcDpId);
            if (null == interfaceName) {
                LOG.info("buildRemoteDmacFlowEntry: Could not find interfaceName for {} {}", srcDpId, elanInstance);
            }
            actions = getEgressActionsForInterface(interfaceName, null);
        } else if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
            actions = elanItmUtils.getInternalTunnelItmEgressAction(srcDpId, destDpId, lportTagOrVni);
        }
        mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
    } catch (Exception e) {
        LOG.error("Could not get egress actions to add to flow for srcDpId {}, destDpId {}, lportTag/VNI {}", srcDpId, destDpId, lportTagOrVni, e);
    }
    Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcDpId, destDpId, macAddress, elanTag), 20, /* prio */
    displayName, 0, /* idleTimeout */
    0, /* hardTimeout */
    ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
    return flow;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ArrayList(java.util.ArrayList) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ElanException(org.opendaylight.netvirt.elan.ElanException) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo)

Example 39 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.

the class VpnUtil method buildL3vpnGatewayFlow.

public static FlowEntity buildL3vpnGatewayFlow(BigInteger dpId, String gwMacAddress, long vpnId, long subnetVpnId) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
    mkMatches.add(new MatchEthernetDestination(new MacAddress(gwMacAddress)));
    List<InstructionInfo> mkInstructions = new ArrayList<>();
    mkInstructions.add(new InstructionGotoTable(NwConstants.L3_FIB_TABLE));
    if (subnetVpnId != VpnConstants.INVALID_ID) {
        BigInteger subnetIdMetaData = MetaDataUtil.getVpnIdMetadata(subnetVpnId);
        mkInstructions.add(new InstructionWriteMetadata(subnetIdMetaData, MetaDataUtil.METADATA_MASK_VRFID));
    }
    String flowId = getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, gwMacAddress);
    return MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_GW_MAC_TABLE, flowId, 20, flowId, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, mkMatches, mkInstructions);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 40 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.

the class ElanInterfaceManager method getMatchesForFilterEqualsLPortTag.

private List<MatchInfo> getMatchesForFilterEqualsLPortTag(int lportTag) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    // Matching metadata
    mkMatches.add(new MatchMetadata(MetaDataUtil.getLportTagMetaData(lportTag), MetaDataUtil.METADATA_MASK_LPORT_TAG));
    mkMatches.add(new MatchTunnelId(BigInteger.valueOf(lportTag)));
    return mkMatches;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList)

Aggregations

MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)67 ArrayList (java.util.ArrayList)61 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)50 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)40 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)32 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)31 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)23 BigInteger (java.math.BigInteger)15 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)15 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)15 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)13 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)12 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)12 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)11 InetAddress (java.net.InetAddress)7 UnknownHostException (java.net.UnknownHostException)7 ActionNxLoadInPort (org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort)7 MatchEthernetDestination (org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination)7 NxMatchCtState (org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState)7 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)6