use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class AclServiceOFFlowBuilderTest method testaddDstIpMatches_v4.
@Test
public void testaddDstIpMatches_v4() {
AceIpBuilder builder = new AceIpBuilder();
AceIpv4Builder v4builder = new AceIpv4Builder();
v4builder.setDestinationIpv4Network(new Ipv4Prefix("10.1.1.1/24"));
builder.setAceIpVersion(v4builder.build());
List<MatchInfoBase> flowMatches = AclServiceOFFlowBuilder.addDstIpMatches(builder.build());
assertTrue(flowMatches.contains(MatchEthernetType.IPV4));
assertTrue(flowMatches.contains(new MatchIpv4Destination("10.1.1.1", "24")));
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class AclNodeDefaultFlowsTxBuilder method programConntrackForwardRule.
/**
* Adds the rule to forward the known packets.
*
* @param priority the priority of the flow
* @param flowId the flowId
* @param conntrackState the conntrack state of the packets thats should be
* send
* @param conntrackMask the conntrack mask
* @param dispatcherTableId the dispatcher table id
* @param tableId the table id
*/
private void programConntrackForwardRule(Integer priority, String flowId, int conntrackState, int conntrackMask, short dispatcherTableId, short tableId) {
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(new NxMatchCtState(conntrackState, conntrackMask));
matches.add(new NxMatchCtMark(AclConstants.CT_MARK_EST_STATE, AclConstants.CT_MARK_EST_STATE_MASK));
List<InstructionInfo> instructions = AclServiceOFFlowBuilder.getResubmitInstructionInfo(dispatcherTableId);
flowId = "Fixed_Conntrk_Trk_" + dpId + "_" + flowId + dispatcherTableId;
addFlowToTx(tableId, flowId, priority, matches, instructions);
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class PolicyServiceFlowUtil method getPolicyRouteMatches.
public List<MatchInfoBase> getPolicyRouteMatches(long policyClassifierId, int lportTag) {
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(new NxMatchRegister(NxmNxReg6.class, lportTag, MetaDataUtil.getLportTagMaskForReg6()));
matches.add(new MatchMetadata(MetaDataUtil.getPolicyClassifierMetaData(policyClassifierId), MetaDataUtil.METADATA_MASK_POLICY_CLASSIFER_ID));
return matches;
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class PolicyAceFlowProgrammer method programAceFlows.
public void programAceFlows(Ace ace, List<InstructionInfo> instructions, BigInteger dpId, int addOrRemove) {
Optional<PolicyAceFlowWrapper> policyFlowWrapperOpt = getPolicyAceFlowWrapper(ace.getMatches());
if (policyFlowWrapperOpt.isPresent()) {
PolicyAceFlowWrapper policyFlowWrapper = policyFlowWrapperOpt.get();
if (policyFlowWrapper.isPartial()) {
LOG.debug("Delaying policy ACE rule {} installation due to partial information", ace.getRuleName());
return;
}
BigInteger policyFlowDpId = policyFlowWrapper.getDpId();
if (!BigInteger.ZERO.equals(policyFlowDpId) && !Objects.equals(dpId, policyFlowDpId)) {
LOG.trace("Ignoring policy ACE rule {} flow {} on DPN {}", ace.getRuleName(), policyFlowWrapper.getFlowName(), dpId);
return;
}
}
Map<String, List<MatchInfoBase>> aclFlowMap = aclServiceUtil.programIpFlow(ace.getMatches());
if (aclFlowMap == null || aclFlowMap.isEmpty()) {
LOG.warn("Failed to create flow matches for ACE rule {}", ace.getRuleName());
return;
}
coordinator.enqueueJob(ace.getRuleName(), () -> {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
aclFlowMap.forEach((flowName, matches) -> {
String policyFlowName = "Policy_" + flowName;
List<MatchInfoBase> policyMatches = matches;
int policyPriority = PolicyServiceConstants.POLICY_FLOW_PRIOPITY;
if (policyFlowWrapperOpt.isPresent()) {
PolicyAceFlowWrapper policyFlowWrapper = policyFlowWrapperOpt.get();
policyFlowName += '_' + policyFlowWrapper.getFlowName();
policyPriority = policyFlowWrapper.getPriority();
policyMatches = Stream.concat(matches.stream(), policyFlowWrapper.getMatches().stream()).collect(Collectors.toList());
}
LOG.debug("{} policy ACE rule {} on DPN {} flow {}", addOrRemove == NwConstants.ADD_FLOW ? "Installing" : "Removing", ace.getRuleName(), dpId, policyFlowName);
policyFlowUtil.updateFlowToTx(dpId, NwConstants.EGRESS_POLICY_CLASSIFIER_TABLE, policyFlowName, policyPriority, NwConstants.EGRESS_POLICY_CLASSIFIER_COOKIE, policyMatches, instructions, addOrRemove, tx);
});
return Collections.singletonList(tx.submit());
});
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project genius by opendaylight.
the class FlowBasedServicesUtils method installEgressDispatcherSplitHorizonFlow.
public static void installEgressDispatcherSplitHorizonFlow(BigInteger dpId, BoundServices boundService, String interfaceName, WriteTransaction writeTransaction, int interfaceTag, short currentServiceIndex, Interface iface) {
// only install split horizon drop flows for external interfaces
if (!isExternal(iface)) {
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Installing split horizon drop flow for external interface {} on dpId {}", interfaceName, dpId);
}
// BigInteger.ONE is used for
BigInteger shFlagSet = BigInteger.ONE;
// checking the Split-Horizon
// flag
List<MatchInfoBase> shMatches = FlowBasedServicesUtils.getMatchInfoForEgressDispatcherTable(interfaceTag, currentServiceIndex);
shMatches.add(new MatchMetadata(shFlagSet, MetaDataUtil.METADATA_MASK_SH_FLAG));
List<InstructionInfo> shInstructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
actionsInfos.add(new ActionDrop());
shInstructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getSplitHorizonFlowRef(dpId, NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, interfaceName, shFlagSet);
String serviceRef = boundService.getServiceName();
// This must be higher priority than the egress flow
int splitHorizonFlowPriority = boundService.getServicePriority() + 1;
StypeOpenflow stypeOpenFlow = boundService.getAugmentation(StypeOpenflow.class);
Flow egressSplitHorizonFlow = MDSALUtil.buildFlow(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, flowRef, splitHorizonFlowPriority, serviceRef, 0, 0, stypeOpenFlow.getFlowCookie(), shMatches, shInstructions);
installFlow(dpId, egressSplitHorizonFlow, writeTransaction);
}
Aggregations