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);
}
}
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));
}
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));
}
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);
}
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);
}
Aggregations