Search in sources :

Example 26 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class EvpnSnatFlowProgrammer method removeTunnelTableEntry.

public void removeTunnelTableEntry(BigInteger dpnId, long l3Vni, WriteTransaction removeFlowInvTx) {
    LOG.debug("removeTunnelTableEntry : Remove terminating service table {} --> table {} flow on NAPT DpnId {} " + "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE, NwConstants.INBOUND_NAPT_TABLE, dpnId, l3Vni);
    List<MatchInfo> mkMatches = new ArrayList<>();
    // Matching metadata
    mkMatches.add(new MatchTunnelId(BigInteger.valueOf(l3Vni)));
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, NatEvpnUtil.getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, l3Vni, NatConstants.SNAT_FLOW_NAME), 5, 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 27 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class EvpnSnatFlowProgrammer method evpnDelFibTsAndReverseTraffic.

public void evpnDelFibTsAndReverseTraffic(final BigInteger dpnId, final long routerId, final String externalIp, final String vpnName, String extGwMacAddress, WriteTransaction removeFlowInvTx) {
    /*
      * 1) Remove the flow INTERNAL_TUNNEL_TABLE (table=36)-> INBOUND_NAPT_TABLE (table=44)
      *    (FIP VM on DPN1 is responding back to external fixed IP on DPN2) {DNAT to SNAT traffic on
      *     different Hypervisor}
      *
      * 2) Remove the flow L3_GW_MAC_TABLE (table=19)-> INBOUND_NAPT_TABLE (table=44)
      *    (FIP VM on DPN1 is responding back to external fixed IP on DPN1 itself){DNAT to SNAT traffic on
      *     Same Hypervisor}
      *
      * 3) Remove the flow PDNAT_TABLE (table=25)-> INBOUND_NAPT_TABLE (table=44)
      *    (If there is no FIP Match on table 25 (PDNAT_TABLE) then default flow to INBOUND_NAPT_TABLE (table=44))
      *
      * 4) Remove the flow L3_FIB_TABLE (table=21)-> INBOUND_NAPT_TABLE (table=44)
      *    (FIP VM on DPN1 is responding back to external fixed Ip on DPN1 itself. ie. same Hypervisor)
      *    {DNAT to SNAT Intra DC traffic}
      */
    String rd = NatUtil.getVpnRd(dataBroker, vpnName);
    if (rd == null) {
        LOG.error("evpnDelFibTsAndReverseTraffic : Could not retrieve RD value from VPN Name {}", vpnName);
        return;
    }
    long vpnId = NatUtil.getVpnId(dataBroker, vpnName);
    if (vpnId == NatConstants.INVALID_ID) {
        LOG.error("evpnDelFibTsAndReverseTraffic : Invalid Vpn Id is found for Vpn Name {}", vpnName);
        return;
    }
    if (extGwMacAddress == null) {
        LOG.error("evpnDelFibTsAndReverseTraffic : Unable to Get External Gateway MAC address for " + "External Router ID {} ", routerId);
        return;
    }
    long l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
    if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
        LOG.debug("evpnDelFibTsAndReverseTraffic : L3VNI value is not configured in Internet VPN {} and RD {} " + "Carve-out L3VNI value from OpenDaylight VXLAN VNI Pool and continue with installing " + "SNAT flows for External Fixed IP {}", vpnName, rd, externalIp);
        l3Vni = NatOverVxlanUtil.getInternetVpnVni(idManager, vpnName, routerId).longValue();
    }
    final String externalFixedIp = NatUtil.validateAndAddNetworkMask(externalIp);
    RemoveFibEntryInput input = new RemoveFibEntryInputBuilder().setVpnName(vpnName).setSourceDpid(dpnId).setIpAddress(externalFixedIp).setIpAddressSource(RemoveFibEntryInput.IpAddressSource.ExternalFixedIP).setServiceId(l3Vni).build();
    LOG.debug("evpnDelFibTsAndReverseTraffic : Removing custom FIB table {} --> table {} flow on " + "NAPT Switch {} with l3Vni {}, ExternalFixedIp {}, ExternalVpnName {} for RouterId {}", NwConstants.L3_FIB_TABLE, NwConstants.INBOUND_NAPT_TABLE, dpnId, l3Vni, externalIp, vpnName, routerId);
    Future<RpcResult<Void>> future = fibService.removeFibEntry(input);
    ListenableFuture<RpcResult<Void>> futureVxlan = JdkFutureAdapters.listenInPoolThread(future);
    final long finalL3Vni = l3Vni;
    Futures.addCallback(futureVxlan, new FutureCallback<RpcResult<Void>>() {

        @Override
        public void onFailure(@Nonnull Throwable error) {
            LOG.error("evpnDelFibTsAndReverseTraffic : Error in custom fib routes remove process for " + "External Fixed IP {} on DPN {} with l3Vni {}, ExternalVpnName {} for RouterId {}", externalIp, dpnId, finalL3Vni, vpnName, routerId, error);
        }

        @Override
        public void onSuccess(@Nonnull RpcResult<Void> result) {
            if (result.isSuccessful()) {
                LOG.info("evpnDelFibTsAndReverseTraffic : Successfully removed custom FIB routes for " + "External Fixed IP {} on DPN {} with l3Vni {}, ExternalVpnName {} for " + "RouterId {}", externalIp, dpnId, finalL3Vni, vpnName, routerId);
                // remove INTERNAL_TUNNEL_TABLE (table=36)-> INBOUND_NAPT_TABLE (table=44) flow
                removeTunnelTableEntry(dpnId, finalL3Vni, removeFlowInvTx);
                // remove L3_GW_MAC_TABLE (table=19)-> INBOUND_NAPT_TABLE (table=44) flow
                NatUtil.removePreDnatToSnatTableEntry(mdsalManager, dpnId, removeFlowInvTx);
                // remove PDNAT_TABLE (table=25)-> INBOUND_NAPT_TABLE (table=44) flow
                NatEvpnUtil.removeL3GwMacTableEntry(dpnId, vpnId, extGwMacAddress, mdsalManager, removeFlowInvTx);
            }
        }
    }, MoreExecutors.directExecutor());
}
Also used : RemoveFibEntryInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.RemoveFibEntryInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RemoveFibEntryInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.RemoveFibEntryInput)

Example 28 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow 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 29 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ExternalRoutersListener method removeNaptFlowsFromActiveSwitchInternetVpn.

public void removeNaptFlowsFromActiveSwitchInternetVpn(long routerId, String routerName, BigInteger dpnId, Uuid networkId, String vpnName, WriteTransaction writeFlowInvTx) {
    LOG.debug("removeNaptFlowsFromActiveSwitchInternetVpn : Remove NAPT flows from Active switch Internet Vpn");
    BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
    // Remove the NAPT PFIB TABLE entry
    long vpnId = -1;
    if (vpnName != null) {
        // ie called from disassociate vpn case
        LOG.debug("removeNaptFlowsFromActiveSwitchInternetVpn : This is disassociate nw with vpn case " + "with vpnName {}", vpnName);
        vpnId = NatUtil.getVpnId(dataBroker, vpnName);
        LOG.debug("removeNaptFlowsFromActiveSwitchInternetVpn : vpnId for disassociate nw with vpn scenario {}", vpnId);
    }
    if (vpnId != NatConstants.INVALID_ID && !NatUtil.checkForRoutersWithSameExtNetAndNaptSwitch(dataBroker, networkId, routerName, dpnId)) {
        // Remove the NAPT PFIB TABLE which forwards the outgoing packet to FIB Table matching on the VPN ID.
        String natPfibVpnFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, vpnId);
        FlowEntity natPfibVpnFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibVpnFlowRef);
        LOG.info("removeNaptFlowsFromActiveSwitchInternetVpn : Remove the flow in the {} for the active switch " + "with the DPN ID {} and VPN ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, vpnId);
        mdsalManager.removeFlowToTx(natPfibVpnFlowEntity, writeFlowInvTx);
        // Remove IP-PORT active NAPT entries and release port from IdManager
        // For the router ID get the internal IP , internal port and the corresponding
        // external IP and external Port.
        IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
        if (ipPortMapping == null) {
            LOG.error("removeNaptFlowsFromActiveSwitchInternetVpn : Unable to retrieve the IpPortMapping");
            return;
        }
        List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
        for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
            List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
            for (IpPortMap ipPortMap : ipPortMaps) {
                String ipPortInternal = ipPortMap.getIpPortInternal();
                String[] ipPortParts = ipPortInternal.split(":");
                if (ipPortParts.length != 2) {
                    LOG.error("removeNaptFlowsFromActiveSwitchInternetVpn : Unable to retrieve the Internal IP " + "and port");
                    return;
                }
                String internalIp = ipPortParts[0];
                String internalPort = ipPortParts[1];
                // Build the flow for the outbound NAPT table
                naptPacketInHandler.removeIncomingPacketMap(routerId + NatConstants.COLON_SEPARATOR + internalIp + NatConstants.COLON_SEPARATOR + internalPort);
                String switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, String.valueOf(routerId), internalIp, Integer.parseInt(internalPort));
                FlowEntity outboundNaptFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
                LOG.info("removeNaptFlowsFromActiveSwitchInternetVpn : Remove the flow in the {} for the " + "active switch with the DPN ID {} and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, dpnId, routerId);
                mdsalManager.removeFlowToTx(outboundNaptFlowEntity, writeFlowInvTx);
                IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
                String externalIp = ipPortExternal.getIpAddress();
                int externalPort = ipPortExternal.getPortNum();
                // Build the flow for the inbound NAPT table
                switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE, String.valueOf(routerId), externalIp, externalPort);
                FlowEntity inboundNaptFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.INBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
                LOG.info("removeNaptFlowsFromActiveSwitchInternetVpn : Remove the flow in the {} for the " + "active active switch with the DPN ID {} and router ID {}", NwConstants.INBOUND_NAPT_TABLE, dpnId, routerId);
                mdsalManager.removeFlowToTx(inboundNaptFlowEntity, writeFlowInvTx);
                // Finally release port from idmanager
                String internalIpPort = internalIp + ":" + internalPort;
                naptManager.removePortFromPool(internalIpPort, externalIp);
                // Remove sessions from models
                naptManager.removeIpPortMappingForRouterID(routerId);
                naptManager.removeIntIpPortMappingForRouterID(routerId);
            }
        }
    } else {
        LOG.error("removeNaptFlowsFromActiveSwitchInternetVpn : Invalid vpnId {}", vpnId);
    }
}
Also used : IntextIpPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.IntextIpPortMap) IpPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.ip.port.mapping.intext.ip.protocol.type.IpPortMap) IntextIpProtocolType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.ip.port.mapping.IntextIpProtocolType) BigInteger(java.math.BigInteger) IpPortExternal(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.ip.port.mapping.intext.ip.protocol.type.ip.port.map.IpPortExternal) IpPortMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.IpPortMapping) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 30 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ExternalRoutersListener method removeNaptFibExternalOutputFlows.

protected void removeNaptFibExternalOutputFlows(long routerId, BigInteger dpnId, Uuid networkId, @Nonnull Collection<String> externalIps, WriteTransaction writeFlowInvTx) {
    long extVpnId = NatConstants.INVALID_ID;
    if (networkId != null) {
        Uuid vpnUuid = NatUtil.getVpnIdfromNetworkId(dataBroker, networkId);
        if (vpnUuid != null) {
            extVpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
        } else {
            LOG.debug("removeNaptFibExternalOutputFlows : vpnUuid is null");
        }
    } else {
        LOG.debug("removeNaptFibExternalOutputFlows : networkId is null");
        extVpnId = NatUtil.getNetworkVpnIdFromRouterId(dataBroker, routerId);
    }
    if (extVpnId == NatConstants.INVALID_ID) {
        LOG.warn("removeNaptFibExternalOutputFlows : extVpnId not found for routerId {}", routerId);
        extVpnId = routerId;
    }
    for (String ip : externalIps) {
        String extIp = removeMaskFromIp(ip);
        String naptFlowRef = getFlowRefNaptPreFib(dpnId, NwConstants.NAPT_PFIB_TABLE, extVpnId);
        LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in table {} for the active switch" + " with the DPN ID {} and router ID {} and IP {} flowRef {}", NwConstants.NAPT_PFIB_TABLE, dpnId, routerId, extIp, naptFlowRef);
        FlowEntity natPfibVpnFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, naptFlowRef);
        mdsalManager.removeFlowToTx(natPfibVpnFlowEntity, writeFlowInvTx);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Aggregations

Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)155 ArrayList (java.util.ArrayList)127 BigInteger (java.math.BigInteger)83 Test (org.junit.Test)67 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)65 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)55 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)51 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)47 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)44 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)41 List (java.util.List)36 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)35 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)35 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)33 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)31 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)30 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)30 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)28 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)24 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)24