use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project genius by opendaylight.
the class InterfaceManagerCommonUtils method addTunnelIngressFlow.
public void addTunnelIngressFlow(IfTunnel tunnel, BigInteger dpnId, long portNo, String interfaceName, int ifIndex) {
if (isTunnelWithoutIngressFlow(tunnel)) {
return;
}
LOG.debug("add tunnel ingress flow for {}", interfaceName);
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(new MatchInPort(dpnId, portNo));
if (BooleanUtils.isTrue(tunnel.isTunnelRemoteIpFlow())) {
matches.add(new NxMatchTunnelSourceIp(tunnel.getTunnelDestination().getIpv4Address()));
}
if (BooleanUtils.isTrue(tunnel.isTunnelSourceIpFlow())) {
matches.add(new NxMatchTunnelDestinationIp(tunnel.getTunnelSource().getIpv4Address()));
}
List<InstructionInfo> mkInstructions = new ArrayList<>();
mkInstructions.add(new InstructionWriteMetadata(MetaDataUtil.getLportTagMetaData(ifIndex).or(BigInteger.ONE), MetaDataUtil.METADATA_MASK_LPORT_TAG_SH_FLAG));
short tableId = tunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeMplsOverGre.class) ? NwConstants.L3_LFIB_TABLE : tunnel.isInternal() ? NwConstants.INTERNAL_TUNNEL_TABLE : NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL;
mkInstructions.add(new InstructionGotoTable(tableId));
mdsalApiManager.batchedAddFlow(dpnId, buildTunnelIngressFlowEntity(dpnId, interfaceName, matches, mkInstructions));
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase 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);
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class EgressCountersServiceImpl method syncCounterFlows.
@Override
public void syncCounterFlows(ElementCountersRequest ecr, int operation) {
int lportTag = ecr.getLportTag();
List<MatchInfoBase> flowMatches = CountersServiceUtils.getCounterFlowMatch(ecr, lportTag, ElementCountersDirection.EGRESS);
List<ActionInfo> actionsInfos = new ArrayList<>();
List<InstructionInfo> instructions = CountersServiceUtils.getDispatcherTableResubmitInstructions(actionsInfos, ElementCountersDirection.EGRESS);
BigInteger dpn = ecr.getDpn();
String flowName = createFlowName(ecr, lportTag, dpn);
syncFlow(dpn, NwConstants.EGRESS_COUNTERS_TABLE, flowName, CountersServiceUtils.COUNTER_TABLE_COUNTER_FLOW_PRIORITY, CountersServiceUtils.COUNTER_FLOW_NAME, 0, 0, CountersServiceUtils.COOKIE_COUNTERS_BASE, flowMatches, instructions, operation);
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class EgressCountersServiceImpl method installDefaultCounterRules.
@Override
public void installDefaultCounterRules(String interfaceId) {
BigInteger dpn = interfaceManager.getDpnForInterface(interfaceId);
String defaultFlowName = CountersServiceUtils.DEFAULT_EGRESS_COUNTER_FLOW_PREFIX + dpn + interfaceId;
List<MatchInfoBase> defaultFlowMatches = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
List<InstructionInfo> instructions = CountersServiceUtils.getDispatcherTableResubmitInstructions(actionsInfos, ElementCountersDirection.EGRESS);
syncFlow(dpn, NwConstants.EGRESS_COUNTERS_TABLE, defaultFlowName, CountersServiceUtils.COUNTER_TABLE_DEFAULT_FLOW_PRIORITY, CountersServiceUtils.COUNTER_FLOW_NAME, 0, 0, CountersServiceUtils.COOKIE_COUNTERS_BASE, defaultFlowMatches, instructions, NwConstants.ADD_FLOW);
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class IngressCountersServiceImpl method installDefaultCounterRules.
@Override
public void installDefaultCounterRules(String interfaceId) {
BigInteger dpn = interfaceManager.getDpnForInterface(interfaceId);
String defaultFlowName = CountersServiceUtils.DEFAULT_INGRESS_COUNTER_FLOW_PREFIX + dpn + interfaceId;
List<MatchInfoBase> defaultFlowMatches = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
List<InstructionInfo> instructions = CountersServiceUtils.getDispatcherTableResubmitInstructions(actionsInfos, ElementCountersDirection.INGRESS);
syncFlow(dpn, NwConstants.INGRESS_COUNTERS_TABLE, defaultFlowName, CountersServiceUtils.COUNTER_TABLE_DEFAULT_FLOW_PRIORITY, CountersServiceUtils.COUNTER_FLOW_NAME, 0, 0, CountersServiceUtils.COOKIE_COUNTERS_BASE, defaultFlowMatches, instructions, NwConstants.ADD_FLOW);
}
Aggregations