Search in sources :

Example 66 with MatchInfoBase

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")));
}
Also used : AceIpBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) AceIpv4Builder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

Example 67 with MatchInfoBase

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);
}
Also used : NxMatchCtMark(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtMark) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) NxMatchCtState(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 68 with MatchInfoBase

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;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) NxmNxReg6(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6) ArrayList(java.util.ArrayList) NxMatchRegister(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchRegister) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 69 with MatchInfoBase

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());
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) BigInteger(java.math.BigInteger) List(java.util.List) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 70 with MatchInfoBase

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);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) StypeOpenflow(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) BigInteger(java.math.BigInteger) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Aggregations

MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)70 ArrayList (java.util.ArrayList)60 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)33 BigInteger (java.math.BigInteger)18 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)18 List (java.util.List)16 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)15 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)13 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)11 Test (org.junit.Test)10 NxMatchCtState (org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState)10 AceIpBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder)10 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)9 ActionNxConntrack (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)8 MatchIpv4Source (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source)7 AceIpv4Builder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder)7 HashMap (java.util.HashMap)6 NxCtAction (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction)6