Search in sources :

Example 31 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata 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 32 with MatchMetadata

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

the class ArpResponderUtil method getMatchCriteria.

/**
 * Get Match Criteria for the ARP Responder Flow.
 *
 * <p>
 * List of Match Criteria for ARP Responder
 * </p>
 * <ul>
 * <li>Packet is ARP</li>
 * <li>Packet is ARP Request</li>
 * <li>The ARP packet is requesting for Gateway IP</li>
 * <li>Metadata which is generated by using Service
 * Index({@link NwConstants#L3VPN_SERVICE_INDEX}) Lport Tag
 * ({@link MetaDataUtil#METADATA_MASK_LPORT_TAG}) and VRF
 * ID({@link MetaDataUtil#METADATA_MASK_VRFID})</li>
 * </ul>
 *
 * @param lportTag
 *            LPort Tag
 * @param elanInstance
 *            Elan Instance
 * @param ipAddress
 *            Ip Address to be matched to this flow
 * @return List of Match criteria
 */
public static List<MatchInfo> getMatchCriteria(int lportTag, ElanInstance elanInstance, String ipAddress) {
    BigInteger metadata = ElanHelper.getElanMetadataLabel(elanInstance.getElanTag(), lportTag);
    BigInteger metadataMask = ElanHelper.getElanMetadataMask();
    return Arrays.asList(MatchEthernetType.ARP, MatchArpOp.REQUEST, new MatchArpTpa(ipAddress, "32"), new MatchMetadata(metadata, metadataMask));
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) BigInteger(java.math.BigInteger) MatchArpTpa(org.opendaylight.genius.mdsalutil.matches.MatchArpTpa)

Example 33 with MatchMetadata

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

the class PolicyServiceFlowUtil method getIngressInterfaceMatches.

public List<MatchInfoBase> getIngressInterfaceMatches(String ingressInterface) {
    InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(ingressInterface);
    if (interfaceInfo == null) {
        LOG.warn("No interface info found for {}", ingressInterface);
        return Collections.emptyList();
    }
    int lportTag = interfaceInfo.getInterfaceTag();
    return Collections.singletonList(new MatchMetadata(MetaDataUtil.getMetadataLPort(lportTag), MetaDataUtil.METADATA_MASK_LPORT_TAG));
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 34 with MatchMetadata

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

the class QosNeutronUtils method removeStaleFlowEntry.

public void removeStaleFlowEntry(Interface intrf) {
    List<MatchInfo> matches = new ArrayList<>();
    BigInteger dpnId = getDpIdFromInterface(intrf);
    Integer ifIndex = intrf.getIfIndex();
    matches.add(new MatchMetadata(MetaDataUtil.getLportTagMetaData(ifIndex), MetaDataUtil.METADATA_MASK_LPORT_TAG));
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.QOS_DSCP_TABLE, getQosFlowId(NwConstants.QOS_DSCP_TABLE, dpnId, ifIndex), QosConstants.QOS_DEFAULT_FLOW_PRIORITY, "QoSRemoveFlow", 0, 0, NwConstants.COOKIE_QOS_TABLE, matches, null);
    mdsalUtils.removeFlow(flowEntity);
}
Also used : BigInteger(java.math.BigInteger) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 35 with MatchMetadata

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

the class InterfaceServiceUtil method mergeMetadataMatchsOrAdd.

/**
 * If matches contains MatchMetadata in its list and match is of type MatchMetadata, then this
 * function will merge the MatchMetadatas using "or" of the masks and the values, otherwise it will add
 * the match to the matches list.
 *
 * @param matches - matches list
 * @param match - metadata or other match
 */
public static void mergeMetadataMatchsOrAdd(List<MatchInfoBase> matches, MatchInfoBase match) {
    Iterator<MatchInfoBase> iter = matches.iterator();
    while (iter.hasNext()) {
        MatchInfoBase match2 = iter.next();
        if (match2 instanceof MatchMetadata) {
            if (match instanceof MatchMetadata) {
                MatchMetadata metadataMatch = (MatchMetadata) match;
                BigInteger value = MetaDataUtil.mergeMetadataValues(((MatchMetadata) match2).getMetadata(), metadataMatch.getMetadata());
                BigInteger mask = MetaDataUtil.mergeMetadataMask(((MatchMetadata) match2).getMask(), metadataMatch.getMask());
                match = new MatchMetadata(value, mask);
                iter.remove();
            }
            break;
        }
    }
    matches.add(match);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) BigInteger(java.math.BigInteger) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

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