Search in sources :

Example 6 with InstructionGotoTable

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

the class IngressAclServiceImpl method programIpv4BroadcastRule.

/**
 * Programs IPv4 broadcast rules.
 *
 * @param port the Acl Interface port
 * @param addOrRemove whether to delete or add flow
 */
private void programIpv4BroadcastRule(AclInterface port, int addOrRemove) {
    BigInteger dpId = port.getDpId();
    int lportTag = port.getLPortTag();
    MatchInfoBase lportMatchInfo = AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode);
    List<IpPrefixOrAddress> cidrs = port.getSubnetIpPrefixes();
    if (cidrs != null) {
        List<String> broadcastAddresses = AclServiceUtils.getIpBroadcastAddresses(cidrs);
        for (String broadcastAddress : broadcastAddresses) {
            List<MatchInfoBase> matches = AclServiceUtils.buildBroadcastIpV4Matches(broadcastAddress);
            matches.add(lportMatchInfo);
            List<InstructionInfo> instructions = new ArrayList<>();
            instructions.add(new InstructionGotoTable(getAclConntrackClassifierTable()));
            String flowName = "Ingress_v4_Broadcast_" + dpId + "_" + lportTag + "_" + broadcastAddress + "_Permit";
            syncFlow(dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_MATCH_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
        }
    } else {
        LOG.warn("IP Broadcast CIDRs are missing for port {}", port.getInterfaceId());
    }
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 7 with InstructionGotoTable

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

the class ExternalRoutersListener method buildSnatFlowEntityForPrmrySwtch.

private FlowEntity buildSnatFlowEntityForPrmrySwtch(BigInteger dpId, String routerName, long routerId) {
    LOG.debug("buildSnatFlowEntityForPrmrySwtch : called for primary NAPT switch dpId {}, routerName {}", dpId, routerName);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionGotoTable(NwConstants.OUTBOUND_NAPT_TABLE));
    String flowRef = getFlowRefSnat(dpId, NwConstants.PSNAT_TABLE, routerName);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
    LOG.debug("buildSnatFlowEntityForPrmrySwtch : Returning SNAT Flow Entity {}", flowEntity);
    return flowEntity;
}
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) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 8 with InstructionGotoTable

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

the class ExternalRoutersListener method makeLFibTableEntry.

private void makeLFibTableEntry(BigInteger dpId, long serviceId, short tableId, WriteTransaction writeFlowInvTx) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.MPLS_UNICAST);
    matches.add(new MatchMplsLabel(serviceId));
    List<Instruction> instructions = new ArrayList<>();
    List<ActionInfo> actionsInfos = new ArrayList<>();
    actionsInfos.add(new ActionPopMpls());
    Instruction writeInstruction = new InstructionApplyActions(actionsInfos).buildInstruction(0);
    instructions.add(writeInstruction);
    instructions.add(new InstructionGotoTable(tableId).buildInstruction(1));
    // Install the flow entry in L3_LFIB_TABLE
    String flowRef = getFlowRef(dpId, NwConstants.L3_LFIB_TABLE, serviceId, "");
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef, 10, flowRef, 0, 0, COOKIE_VM_LFIB_TABLE, matches, instructions);
    mdsalManager.addFlowToTx(dpId, flowEntity, writeFlowInvTx);
    LOG.debug("makeLFibTableEntry : LFIB Entry for dpID {} : label : {} modified successfully", dpId, serviceId);
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) 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) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 9 with InstructionGotoTable

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

the class ExternalRoutersListener method buildSnatFlowEntityWithUpdatedVpnIdForPrimrySwtch.

public FlowEntity buildSnatFlowEntityWithUpdatedVpnIdForPrimrySwtch(BigInteger dpId, String routerName, long changedVpnId) {
    LOG.debug("buildSnatFlowEntityWithUpdatedVpnIdForPrimrySwtch : called for dpId {}, routerName {} " + "changed VPN ID {}", dpId, routerName, changedVpnId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(changedVpnId), MetaDataUtil.METADATA_MASK_VRFID));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionGotoTable(NwConstants.OUTBOUND_NAPT_TABLE));
    String flowRef = getFlowRefSnat(dpId, NwConstants.PSNAT_TABLE, routerName);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
    LOG.debug("buildSnatFlowEntityWithUpdatedVpnIdForPrimrySwtch : Returning SNAT Flow Entity {}", flowEntity);
    return flowEntity;
}
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) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 10 with InstructionGotoTable

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

the class ExternalRoutersListener method buildTsFlowEntityWithUpdatedVpnId.

private FlowEntity buildTsFlowEntityWithUpdatedVpnId(BigInteger dpId, String routerName, long routerIdLongVal, long changedVpnId, ProviderTypes extNwProvType) {
    LOG.debug("buildTsFlowEntityWithUpdatedVpnId : called for switch {}, routerName {}, BGP VPN ID {}", dpId, routerName, changedVpnId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    BigInteger tunnelId = BigInteger.valueOf(changedVpnId);
    if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
        tunnelId = NatOverVxlanUtil.getRouterVni(idManager, routerName, changedVpnId);
    }
    matches.add(new MatchTunnelId(tunnelId));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionWriteMetadata(MetaDataUtil.getVpnIdMetadata(changedVpnId), MetaDataUtil.METADATA_MASK_VRFID));
    instructions.add(new InstructionGotoTable(NwConstants.OUTBOUND_NAPT_TABLE));
    BigInteger routerId = BigInteger.valueOf(routerIdLongVal);
    String flowRef = getFlowRefTs(dpId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId.longValue());
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_TS_TABLE, matches, instructions);
    return flowEntity;
}
Also used : MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) 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) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Aggregations

InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)44 ArrayList (java.util.ArrayList)43 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)33 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)25 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)17 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)15 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)14 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)14 BigInteger (java.math.BigInteger)13 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)12 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)12 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)10 ActionPopMpls (org.opendaylight.genius.mdsalutil.actions.ActionPopMpls)7 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)6 CreateFibEntryInput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInput)6 CreateFibEntryInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInputBuilder)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)5 MatchMplsLabel (org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel)5 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)5