Search in sources :

Example 36 with Matches

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.

the class DhcpServiceUtils method getDhcpMatch.

public static List<MatchInfo> getDhcpMatch(String vmMacAddress) {
    List<MatchInfo> matches = getDhcpMatch();
    matches.add(new MatchEthernetSource(new MacAddress(vmMacAddress)));
    return matches;
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchEthernetSource(org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) InterfaceNameMacAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710._interface.name.mac.addresses.InterfaceNameMacAddress)

Example 37 with Matches

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.

the class DhcpServiceUtils method setupDhcpArpRequest.

@SuppressWarnings("checkstyle:IllegalCatch")
public static void setupDhcpArpRequest(BigInteger dpId, short tableId, BigInteger vni, String dhcpIpAddress, int lportTag, Long elanTag, boolean add, IMdsalApiManager mdsalUtil) {
    List<MatchInfo> matches = getDhcpArpMatch(vni, dhcpIpAddress);
    if (add) {
        Flow flow = MDSALUtil.buildFlowNew(tableId, getDhcpArpFlowRef(dpId, tableId, lportTag, dhcpIpAddress), DhcpMConstants.DEFAULT_DHCP_ARP_FLOW_PRIORITY, "DHCPArp", 0, 0, generateDhcpArpCookie(lportTag, dhcpIpAddress), matches, null);
        LOG.trace("Removing DHCP ARP Flow DpId {}, DHCP Port IpAddress {}", dpId, dhcpIpAddress);
        mdsalUtil.removeFlow(dpId, flow);
    } else {
        Flow flow = MDSALUtil.buildFlowNew(tableId, getDhcpArpFlowRef(dpId, tableId, lportTag, dhcpIpAddress), DhcpMConstants.DEFAULT_DHCP_ARP_FLOW_PRIORITY, "DHCPArp", 0, 0, generateDhcpArpCookie(lportTag, dhcpIpAddress), matches, getDhcpArpInstructions(elanTag, lportTag));
        LOG.trace("Adding DHCP ARP Flow DpId {}, DHCPPort IpAddress {}", dpId, dhcpIpAddress);
        mdsalUtil.installFlow(dpId, flow);
    }
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 38 with Matches

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.

the class ElanServiceChainUtils method programLPortDispatcherFromScf.

/**
 * This flow is in charge of handling packets coming from the SCF Pipeline
 * when there is no matching ServiceChain.
 * <ul>
 *  <li> Matches on ElanPseudoPortTag and SI=3 (ELAN)</li>
 *  <li> Sets elanTag and sends to DMAC table</li>
 * </ul>
 * @param dpnId Dpn Id where the flow must be installed
 * @param elanLportTag the Elan Pseudo Lport Id to be used in the Dataplane
 * @param elanTag the Elan Id to be used in the Dataplane
 * @param addOrRemove States if the flow must be added or removed
 */
public static void programLPortDispatcherFromScf(IMdsalApiManager mdsalManager, BigInteger dpnId, int elanLportTag, long elanTag, int addOrRemove) {
    LOG.info("L2-ServiceChaining: programLPortDispatcherFromScf dpId={} elanLportTag={} elanTag={} addOrRemove={} ", dpnId, elanLportTag, elanTag, addOrRemove);
    String flowRef = buildLportDispFromScfFlowRef(elanTag, elanLportTag);
    if (addOrRemove == NwConstants.ADD_FLOW) {
        List<MatchInfo> matches = Collections.singletonList(new MatchMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(elanLportTag, ServiceIndex.getIndex(NwConstants.ELAN_SERVICE_NAME, NwConstants.ELAN_SERVICE_INDEX)), MetaDataUtil.getMetaDataMaskForLPortDispatcher()));
        int instructionKey = 0;
        List<Instruction> instructions = Arrays.asList(// while going through the SCF Pipeline
        MDSALUtil.buildAndGetWriteMetadaInstruction(getElanMetadataLabel(elanTag).or(BigInteger.ONE), MetaDataUtil.METADATA_MASK_SERVICE.or(BigInteger.ONE), instructionKey++), MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.ELAN_SMAC_TABLE, instructionKey));
        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 : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) 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)

Example 39 with Matches

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches 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 40 with Matches

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.

the class VpnServiceChainUtils method buildLPortDispFromScfToL3VpnFlow.

/**
 * Build the flow that must be inserted when there is a ScHop whose
 * egressPort is a VPN Pseudo Port. In that case, packets must be moved
 * from the SCF to VPN Pipeline.
 * <p>
 * Flow matches:  VpnPseudo port lPortTag + SI=L3VPN
 * Actions: Write vrfTag in Metadata + goto FIB Table
 * </p>
 * @param vpnId Dataplane identifier of the VPN, the Vrf Tag.
 * @param dpId The DPN where the flow must be installed/removed
 * @param lportTag Dataplane identifier for the VpnPseudoPort
 * @param addOrRemove States if it must build a Flow to be created or
 *     removed
 *
 * @return the Flow object
 */
public static Flow buildLPortDispFromScfToL3VpnFlow(Long vpnId, BigInteger dpId, Integer lportTag, int addOrRemove) {
    LOG.info("buildLPortDispFlowForScf vpnId={} dpId={} lportTag={} addOrRemove={} ", vpnId, dpId, lportTag, addOrRemove);
    List<MatchInfo> matches = buildMatchOnLportTagAndSI(lportTag, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX));
    List<Instruction> instructions = buildSetVrfTagAndGotoFibInstructions(vpnId.intValue());
    String flowRef = getScfToL3VpnLportDispatcherFlowRef(lportTag);
    Flow result;
    if (addOrRemove == NwConstants.ADD_FLOW) {
        result = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, flowRef, 0, 0, VpnServiceChainUtils.getCookieL3(vpnId.intValue()), matches, instructions);
    } else {
        result = new FlowBuilder().setTableId(NwConstants.LPORT_DISPATCHER_TABLE).setId(new FlowId(flowRef)).build();
    }
    return result;
}
Also used : 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) 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)

Aggregations

ArrayList (java.util.ArrayList)66 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)31 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)30 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)28 Matches (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches)22 BigInteger (java.math.BigInteger)21 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)21 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)20 Test (org.junit.Test)18 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)17 List (java.util.List)16 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)16 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)15 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)15 IpPrefixOrAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress)13 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)12 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)10 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)10 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)8 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)8