Search in sources :

Example 6 with InstructionWriteMetadata

use of org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata in project netvirt by opendaylight.

the class VpnServiceChainUtils method buildLFibVpnPseudoPortFlow.

/**
 * Builds a Flow for the LFIB table that sets the LPortTag of the
 * VpnPseudoPort and sends to LPortDispatcher table.
 * <ul>
 * <li>Matching: eth_type = MPLS, mpls_label = VPN MPLS label
 * <li>Actions: setMetadata LportTag and SI=2, pop MPLS, Go to
 *              LPortDispacherTable
 * </ul>
 *
 * @param dpId  DpnId
 * @param label MPLS label
 * @param nextHop Next Hop IP
 * @param lportTag Pseudo Logical Port tag
 * @return the FlowEntity
 */
public static FlowEntity buildLFibVpnPseudoPortFlow(BigInteger dpId, Long label, String nextHop, int lportTag) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.MPLS_UNICAST);
    matches.add(new MatchMplsLabel(label));
    List<ActionInfo> actionsInfos = Collections.singletonList(new ActionPopMpls());
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionWriteMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX)), MetaDataUtil.getMetaDataMaskForLPortDispatcher()));
    instructions.add(new InstructionApplyActions(actionsInfos));
    instructions.add(new InstructionGotoTable(NwConstants.L3_INTERFACE_TABLE));
    String flowRef = getLFibVpnPseudoPortFlowRef(lportTag, label, nextHop);
    return MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_LFIB_TABLE, flowRef, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_VM_LFIB_TABLE, matches, instructions);
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 7 with InstructionWriteMetadata

use of org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata in project netvirt by opendaylight.

the class PolicyServiceFlowUtil method getPolicyClassifierInstructions.

public List<InstructionInfo> getPolicyClassifierInstructions(long policyClassifierId) {
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionWriteMetadata(MetaDataUtil.getPolicyClassifierMetaData(policyClassifierId), MetaDataUtil.METADATA_MASK_POLICY_CLASSIFER_ID));
    instructions.add(new InstructionGotoTable(NwConstants.EGRESS_POLICY_ROUTING_TABLE));
    return instructions;
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)

Example 8 with InstructionWriteMetadata

use of org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata 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));
}
Also used : NxMatchTunnelDestinationIp(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTunnelDestinationIp) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) NxMatchTunnelSourceIp(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTunnelSourceIp) MatchInPort(org.opendaylight.genius.mdsalutil.matches.MatchInPort) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre)

Example 9 with InstructionWriteMetadata

use of org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata in project netvirt by opendaylight.

the class VpnUtil method buildL3vpnGatewayFlow.

public static FlowEntity buildL3vpnGatewayFlow(BigInteger dpId, String gwMacAddress, long vpnId, long subnetVpnId) {
    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));
    if (subnetVpnId != VpnConstants.INVALID_ID) {
        BigInteger subnetIdMetaData = MetaDataUtil.getVpnIdMetadata(subnetVpnId);
        mkInstructions.add(new InstructionWriteMetadata(subnetIdMetaData, MetaDataUtil.METADATA_MASK_VRFID));
    }
    String flowId = 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) BigInteger(java.math.BigInteger) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) 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 10 with InstructionWriteMetadata

use of org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata in project netvirt by opendaylight.

the class EvpnUtils method getInstructionsForExtTunnelTable.

private List<InstructionInfo> getInstructionsForExtTunnelTable(Long elanTag) {
    List<InstructionInfo> mkInstructions = new ArrayList<>();
    mkInstructions.add(new InstructionWriteMetadata(ElanUtils.getElanMetadataLabel(elanTag, false), ElanHelper.getElanMetadataMask()));
    mkInstructions.add(new InstructionGotoTable(NwConstants.ELAN_DMAC_TABLE));
    return mkInstructions;
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)

Aggregations

InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)19 ArrayList (java.util.ArrayList)18 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)16 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)15 BigInteger (java.math.BigInteger)9 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)9 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)8 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)8 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)6 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)5 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)4 ActionPopMpls (org.opendaylight.genius.mdsalutil.actions.ActionPopMpls)3 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)2 ActionSetDestinationIp (org.opendaylight.genius.mdsalutil.actions.ActionSetDestinationIp)2 ActionSetSourceIp (org.opendaylight.genius.mdsalutil.actions.ActionSetSourceIp)2 MatchEthernetDestination (org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination)2 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)2 MatchTunnelId (org.opendaylight.genius.mdsalutil.matches.MatchTunnelId)2