Search in sources :

Example 26 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.

the class ElanUtils method buildMatchesForElanTagShFlagAndDstMac.

public static List<MatchInfo> buildMatchesForElanTagShFlagAndDstMac(long elanTag, boolean shFlag, String macAddr) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(getElanMetadataLabel(elanTag, shFlag), MetaDataUtil.METADATA_MASK_SERVICE_SH_FLAG));
    mkMatches.add(new MatchEthernetDestination(new MacAddress(macAddr)));
    return mkMatches;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 27 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.

the class BaseVrfEntryHandler method buildL3vpnGatewayFlow.

public FlowEntity buildL3vpnGatewayFlow(BigInteger dpId, String gwMacAddress, long vpnId) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
    mkMatches.add(new MatchEthernetDestination(new MacAddress(gwMacAddress)));
    List<InstructionInfo> mkInstructions = new ArrayList<>();
    mkInstructions.add(new InstructionGotoTable(NwConstants.L3_FIB_TABLE));
    String flowId = FibUtil.getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, gwMacAddress);
    return MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_GW_MAC_TABLE, flowId, 20, flowId, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, mkMatches, mkInstructions);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 28 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.

the class BaseVrfEntryHandler method installPingResponderFlowEntry.

public void installPingResponderFlowEntry(BigInteger dpnId, long vpnId, String routerInternalIp, MacAddress routerMac, long label, int addOrRemove) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchIpProtocol.ICMP);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
    matches.add(new MatchIcmpv4((short) 8, (short) 0));
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchIpv4Destination(routerInternalIp, "32"));
    List<ActionInfo> actionsInfos = new ArrayList<>();
    // Set Eth Src and Eth Dst
    actionsInfos.add(new ActionMoveSourceDestinationEth());
    actionsInfos.add(new ActionSetFieldEthernetSource(routerMac));
    // Move Ip Src to Ip Dst
    actionsInfos.add(new ActionMoveSourceDestinationIp());
    actionsInfos.add(new ActionSetSourceIp(routerInternalIp, "32"));
    // Set the ICMP type to 0 (echo reply)
    actionsInfos.add(new ActionSetIcmpType((short) 0));
    actionsInfos.add(new ActionNxLoadInPort(BigInteger.ZERO));
    actionsInfos.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfos));
    int priority = FibConstants.DEFAULT_FIB_FLOW_PRIORITY + FibConstants.DEFAULT_PREFIX_LENGTH;
    String flowRef = FibUtil.getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, label, priority);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_FIB_TABLE, matches, instructions);
    if (addOrRemove == NwConstants.ADD_FLOW) {
        mdsalManager.syncInstallFlow(flowEntity);
    } else {
        mdsalManager.syncRemoveFlow(flowEntity);
    }
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ActionMoveSourceDestinationIp(org.opendaylight.genius.mdsalutil.actions.ActionMoveSourceDestinationIp) ActionSetIcmpType(org.opendaylight.genius.mdsalutil.actions.ActionSetIcmpType) ArrayList(java.util.ArrayList) ActionSetSourceIp(org.opendaylight.genius.mdsalutil.actions.ActionSetSourceIp) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) ActionNxLoadInPort(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) MatchIcmpv4(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv4) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionMoveSourceDestinationEth(org.opendaylight.genius.mdsalutil.actions.ActionMoveSourceDestinationEth) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 29 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.

the class InterVpnLinkUtil method buildLPortDispatcherFlow.

/**
 * Builds a Flow to be installed into LPortDispatcher table, that matches on
 * SI=2 + vpnLinkEndpointPseudoPortTag and sends to FIB.
 *
 * @param interVpnLinkName The name of the InterVpnLink
 * @param vpnId Dataplane identifier of the VPN, the Vrf Tag.
 * @param lportTag DataPlane identifier of the LogicalPort.
 * @return the Flow ready to be installed
 */
public static Flow buildLPortDispatcherFlow(String interVpnLinkName, long vpnId, int lportTag) {
    LOG.info("Inter-vpn-link : buildLPortDispatcherFlow. vpnId {}   lportTag {} ", vpnId, lportTag);
    List<MatchInfo> matches = Collections.singletonList(new MatchMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)), MetaDataUtil.getMetaDataMaskForLPortDispatcher()));
    String flowRef = getLportDispatcherFlowRef(interVpnLinkName, lportTag);
    return MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, VpnConstants.DEFAULT_LPORT_DISPATCHER_FLOW_PRIORITY, flowRef, 0, 0, VpnUtil.getCookieL3((int) vpnId), matches, buildLportDispatcherTableInstructions(vpnId));
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo)

Example 30 with MatchMetadata

use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata 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)

Aggregations

MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)67 ArrayList (java.util.ArrayList)61 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)50 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)40 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)32 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)31 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)23 BigInteger (java.math.BigInteger)15 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)15 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)15 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)13 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)12 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)12 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)11 InetAddress (java.net.InetAddress)7 UnknownHostException (java.net.UnknownHostException)7 ActionNxLoadInPort (org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort)7 MatchEthernetDestination (org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination)7 NxMatchCtState (org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState)7 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)6