Search in sources :

Example 86 with MatchInfo

use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.

the class AbstractSnatService method installInboundTerminatingServiceTblEntry.

protected void installInboundTerminatingServiceTblEntry(BigInteger dpnId, Long routerId, long extSubnetId, int addOrRemove) {
    // Install the tunnel table entry in NAPT switch for inbound traffic to SNAP IP from a non a NAPT switch.
    LOG.info("installInboundTerminatingServiceTblEntry : creating entry for Terminating Service Table " + "for switch {}, routerId {}", dpnId, routerId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    List<ActionInfo> actionsInfos = new ArrayList<>();
    if (addOrRemove == NwConstants.ADD_FLOW) {
        if (extSubnetId == NatConstants.INVALID_ID) {
            LOG.error("installInboundTerminatingServiceTblEntry : external subnet id is invalid.");
            return;
        }
        matches.add(new MatchTunnelId(BigInteger.valueOf(extSubnetId)));
        ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil.getVpnIdMetadata(extSubnetId), LOAD_START, LOAD_END);
        actionsInfos.add(actionLoadMeta);
    }
    actionsInfos.add(new ActionNxResubmit(NwConstants.INBOUND_NAPT_TABLE));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfos));
    String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId.longValue());
    flowRef = flowRef + "INBOUND";
    syncFlow(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef, NatConstants.SNAT_FIB_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
Also used : ActionNxLoadMetadata(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadMetadata) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 87 with MatchInfo

use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.

the class AbstractSnatService method installDefaultFibRouteForSNAT.

protected void installDefaultFibRouteForSNAT(BigInteger dpnId, Long extNetId, int addOrRemove) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extNetId), MetaDataUtil.METADATA_MASK_VRFID));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionGotoTable(NwConstants.PSNAT_TABLE));
    String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, extNetId);
    syncFlow(dpnId, NwConstants.L3_FIB_TABLE, flowRef, NatConstants.DEFAULT_DNAT_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
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)

Example 88 with MatchInfo

use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.

the class ConntrackBasedSnatService method installTerminatingServiceTblEntry.

protected void installTerminatingServiceTblEntry(BigInteger dpnId, Long routerId, int elanId, int addOrRemove) {
    LOG.info("installTerminatingServiceTblEntry : creating entry for Terminating Service Table " + "for switch {}, routerId {}", dpnId, routerId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchTunnelId(BigInteger.valueOf(routerId)));
    List<ActionInfo> actionsInfos = new ArrayList<>();
    List<NxCtAction> ctActionsList = new ArrayList<>();
    NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0, null, null, 0, 0);
    ctActionsList.add(nxCtAction);
    ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants.OUTBOUND_NAPT_TABLE, ctActionsList);
    ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil.getVpnIdMetadata(routerId.longValue()), LOAD_START, LOAD_END);
    actionsInfos.add(actionLoadMeta);
    actionsInfos.add(actionNxConntrack);
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfos));
    String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId.longValue());
    syncFlow(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionNxConntrack(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack) ActionNxLoadMetadata(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadMetadata) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) NxCtAction(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 89 with MatchInfo

use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.

the class EvpnDnatFlowProgrammer method removeTunnelTableEntry.

private void removeTunnelTableEntry(BigInteger dpnId, long l3Vni, WriteTransaction removeFlowInvTx) {
    LOG.debug("removeTunnelTableEntry : Remove terminating service table {} --> table {} flow on DpnId {} " + "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE, NwConstants.PDNAT_TABLE, dpnId, l3Vni);
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchTunnelId(BigInteger.valueOf(l3Vni)));
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, NatEvpnUtil.getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, l3Vni, NatConstants.DNAT_FLOW_NAME), 6, String.format("%s:%d", "TST Flow Entry ", l3Vni), 0, 0, COOKIE_TUNNEL.add(BigInteger.valueOf(l3Vni)), mkMatches, null);
    mdsalManager.removeFlowToTx(dpnId, flowEntity, removeFlowInvTx);
    LOG.debug("removeTunnelTableEntry : Successfully removed terminating service table flow {} on DpnId {}", flowEntity, dpnId);
}
Also used : MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 90 with MatchInfo

use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.

the class ExternalRoutersListener method buildSnatFlowEntityWithUpdatedVpnId.

public FlowEntity buildSnatFlowEntityWithUpdatedVpnId(BigInteger dpId, String routerName, long groupId, long changedVpnId) {
    LOG.debug("buildSnatFlowEntityWithUpdatedVpnId : called for dpId {}, routerName {} groupId {} " + "changed VPN ID {}", dpId, routerName, groupId, changedVpnId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(changedVpnId), MetaDataUtil.METADATA_MASK_VRFID));
    List<ActionInfo> actionsInfo = new ArrayList<>();
    long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, changedVpnId, routerName);
    actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(tunnelId)));
    LOG.debug("buildSnatFlowEntityWithUpdatedVpnId : Setting the tunnel to the list of action infos {}", actionsInfo);
    actionsInfo.add(new ActionGroup(groupId));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfo));
    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("buildSnatFlowEntityWithUpdatedVpnId : Returning SNAT Flow Entity {}", flowEntity);
    return flowEntity;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Aggregations

MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)117 ArrayList (java.util.ArrayList)107 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)63 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)52 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)51 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)50 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)49 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)35 MatchTunnelId (org.opendaylight.genius.mdsalutil.matches.MatchTunnelId)24 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)23 BigInteger (java.math.BigInteger)22 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)18 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)15 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)15 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)11 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)11 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)10 MatchEthernetDestination (org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination)10 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)10 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)9