Search in sources :

Example 36 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class EvpnSnatFlowProgrammer method evpnAdvToBgpAndInstallFibAndTsFlows.

public void evpnAdvToBgpAndInstallFibAndTsFlows(final Uint64 dpnId, final short tableId, final String externalIp, final String vpnName, final String rd, final String nextHopIp, final Uint32 routerId, final String routerName, final Uuid extNetworkId, TypedWriteTransaction<Configuration> confTx) {
    /*
      * 1) Install 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) Install 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 beyond DC-GW VM){DNAT to SNAT Inter DC traffic}
      *
      * 3) Install 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) Install 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}
      */
    LOG.info("evpnAdvToBgpAndInstallFibAndTsFlows : Handling SNAT Reverse Traffic for External Fixed IP {} for " + "RouterId {}", externalIp, routerId);
    // Get the External Gateway MAC Address which is Router gateway MAC address for SNAT
    String gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
    if (gwMacAddress == null) {
        LOG.error("evpnAdvToBgpAndInstallFibAndTsFlows : Unable to Retrieve External Gateway MAC address " + "from Router ID {}", routerId);
        return;
    }
    // get l3Vni value for external VPN
    Uint32 l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
    if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
        LOG.debug("evpnAdvToBgpAndInstallFibAndTsFlows : 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(vpnName, routerId);
    }
    Uint32 vpnId = NatUtil.getVpnId(dataBroker, vpnName);
    if (vpnId == NatConstants.INVALID_ID) {
        LOG.error("evpnAdvToBgpAndInstallFibAndTsFlows : Invalid Vpn Id is found for Vpn Name {}", vpnName);
        return;
    }
    /* As of now neither SNAT nor DNAT will use mac-address while advertising to FIB and BGP instead
         * use only gwMacAddress. Hence default value of macAddress is null
         */
    // Inform to BGP
    NatEvpnUtil.addRoutesForVxLanProvType(dataBroker, bgpManager, fibManager, vpnName, rd, externalIp, nextHopIp, l3Vni, null, /*InterfaceName*/
    gwMacAddress, confTx, RouteOrigin.STATIC, dpnId, extNetworkId);
    // Install custom FIB routes - FIB table.
    List<Instruction> customInstructions = new ArrayList<>();
    customInstructions.add(new InstructionGotoTable(tableId).buildInstruction(0));
    final String externalFixedIp = NatUtil.validateAndAddNetworkMask(externalIp);
    CreateFibEntryInput input = new CreateFibEntryInputBuilder().setVpnName(vpnName).setSourceDpid(dpnId).setIpAddress(externalFixedIp).setServiceId(l3Vni).setIpAddressSource(CreateFibEntryInput.IpAddressSource.ExternalFixedIP).setInstruction(customInstructions).build();
    LOG.debug("evpnAdvToBgpAndInstallFibAndTsFlows : Installing custom FIB table {} --> table {} flow on " + "NAPT Switch {} with l3Vni {}, ExternalFixedIp {}, ExternalVpnName {} for RouterId {}", NwConstants.L3_FIB_TABLE, tableId, dpnId, l3Vni, externalIp, vpnName, routerId);
    ListenableFuture<RpcResult<CreateFibEntryOutput>> futureVxlan = fibService.createFibEntry(input);
    final Uint32 finalL3Vni = l3Vni;
    Futures.addCallback(futureVxlan, new FutureCallback<RpcResult<CreateFibEntryOutput>>() {

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

        @Override
        public void onSuccess(@NonNull RpcResult<CreateFibEntryOutput> result) {
            if (result.isSuccessful()) {
                LOG.info("evpnAdvToBgpAndInstallFibAndTsFlows : Successfully installed custom FIB routes for " + "External Fixed IP {} on DPN {} with l3Vni {}, ExternalVpnName {} for RouterId {}", externalIp, dpnId, finalL3Vni, vpnName, routerId);
                /* Install the flow INTERNAL_TUNNEL_TABLE (table=36)-> INBOUND_NAPT_TABLE (table=44)
                  * (SNAT to DNAT reverse Traffic: If traffic is Initiated from NAPT to FIP VM on different Hypervisor)
                  */
                makeTunnelTableEntry(dpnId, finalL3Vni, customInstructions, tableId, confTx);
                /* Install the flow L3_GW_MAC_TABLE (table=19)-> INBOUND_NAPT_TABLE (table=44)
                  * (SNAT reverse traffic: If the traffic is Initiated from DC-GW to VM (SNAT Reverse traffic))
                  */
                NatEvpnUtil.makeL3GwMacTableEntry(dpnId, vpnId, gwMacAddress, customInstructions, mdsalManager, confTx);
                /* Install the flow PDNAT_TABLE (table=25)-> INBOUND_NAPT_TABLE (table=44)
                  * If there is no FIP Match on table 25 (PDNAT_TABLE)
                  */
                NatUtil.makePreDnatToSnatTableEntry(mdsalManager, dpnId, tableId, confTx);
            }
        }
    }, MoreExecutors.directExecutor());
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) CreateFibEntryInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInputBuilder) CreateFibEntryOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryOutput) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) CreateFibEntryInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInput) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 37 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class FloatingIPListener method removeNATFlowEntries.

void removeNATFlowEntries(Uint64 dpnId, String interfaceName, String vpnName, String routerName, InternalToExternalPortMap mapping, TypedReadWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException {
    String internalIp = mapping.getInternalIp();
    String externalIp = mapping.getExternalIp();
    Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
    if (routerId == NatConstants.INVALID_ID) {
        LOG.error("removeNATFlowEntries : Could not retrieve router id for {} to remove NAT Flow entries", routerName);
        return;
    }
    VpnInstance vpnInstance = NatUtil.getVpnIdToVpnInstance(dataBroker, vpnName);
    if (vpnInstance == null || vpnInstance.getVpnId() == null) {
        LOG.warn("removeNATFlowEntries: VPN Id not found for {} to remove NAT flow entries {}", vpnName, internalIp);
        return;
    }
    Uint32 vpnId = vpnInstance.getVpnId();
    String vrfId = vpnInstance.getVrfId();
    // Delete the DNAT and SNAT table entries
    removeDNATTblEntry(dpnId, internalIp, externalIp, routerId, confTx);
    removeSNATTblEntry(dpnId, internalIp, externalIp, routerId, vpnId, confTx);
    // Remove the DNAT default FIB flow L3_FIB_TABLE (21) -> PSNAT_TABLE (26) if SNAT is disabled
    boolean isSnatEnabled = NatUtil.isSnatEnabledForRouterId(dataBroker, routerName);
    if (!isSnatEnabled) {
        addOrDelDefaultFibRouteForDnat(dpnId, routerName, routerId, confTx, false);
    }
    Uuid externalNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
    ProviderTypes provType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, externalNetworkId);
    if (provType == null) {
        LOG.error("removeNATFlowEntries : External Network Provider Type Missing");
        return;
    }
    if (provType == ProviderTypes.VXLAN) {
        floatingIPHandler.cleanupFibEntries(dpnId, vpnName, externalIp, NatConstants.DEFAULT_L3VNI_VALUE, vrfId, confTx, provType);
        removeOperationalDS(routerName, interfaceName, internalIp);
        return;
    }
    Uint32 label = getOperationalIpMapping(routerName, interfaceName, internalIp);
    if (label != null && label.longValue() < 0) {
        LOG.error("removeNATFlowEntries : Could not retrieve label for prefix {} in router {}", internalIp, routerId);
        return;
    }
    if (provType == ProviderTypes.VXLAN) {
        floatingIPHandler.cleanupFibEntries(dpnId, vpnName, externalIp, NatConstants.DEFAULT_L3VNI_VALUE, vrfId, confTx, provType);
        removeOperationalDS(routerName, interfaceName, internalIp);
        return;
    }
    floatingIPHandler.cleanupFibEntries(dpnId, vpnName, externalIp, label, vrfId, confTx, provType);
    removeOperationalDS(routerName, interfaceName, internalIp);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ProviderTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 38 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class Ipv6ForwardingService method removeCentralizedRouter.

@Override
public boolean removeCentralizedRouter(TypedReadWriteTransaction<Configuration> confTx, Routers routers, Uint64 primarySwitchId, Uint64 dpnId) throws ExecutionException, InterruptedException {
    Uint32 routerId = NatUtil.getVpnId(dataBroker, routers.getRouterName());
    Uint64 routerMetadata = MetaDataUtil.getVpnIdMetadata(routerId.longValue());
    if (!dpnId.equals(primarySwitchId)) {
        LOG.info("handleSnat (non-NAPTSwitch) : {} flows on switch {} for router {}", "Removing", dpnId, routers.getRouterName());
        // Program default flow from FIB_TABLE(21) to PSNAT_TABLE(26) (egress direction)
        addIpv6DefaultFibRoute(confTx, dpnId, routerId, routerMetadata);
        // Currently we are only programming flows when ext-net has an IPv6Subnet
        if (routerHasIpv6ExtSubnet(routers)) {
            // Program flows on non-NAPTSwitch to send N/S packets to the NAPTSwitch
            addIpv6PsNatMissEntryNonNaptSwitch(confTx, dpnId, routerId, routers.getRouterName(), primarySwitchId);
        }
    } else {
        LOG.info("handleSnat (NAPTSwitch) : {} flows on switch {} for router {}", "Removing", dpnId, routers.getRouterName());
        // Program default flow from FIB_TABLE(21) to PSNAT_TABLE(26) (egress direction)
        removeIpv6DefaultFibRoute(confTx, dpnId, routerId);
        // Program flows from PSNAT_TABLE(26) to OUTBOUND_NAPT_TABLE(46) (egress direction)
        removeIpv6SnatMissEntryForNaptSwitch(confTx, dpnId, routerId);
        // Program flows in INTERNAL_TUNNEL_TABLE(36) for packets coming from non-NAPTSwitch (egress direction)
        removeIpv6TerminatingServiceTblEntry(confTx, dpnId, routerId);
        // Program flows from NAPT_PFIB_TABLE(47) to FIB_TABLE(21) (ingress direction)
        removeIpv6NaptPfibInboundFlow(confTx, dpnId, routerId);
        // Now installing flows that use SubnetInfo
        ipv6SubnetFlowProgrammer.removeSubnetSpecificFlows(confTx, dpnId, routerId, routers);
    }
    return true;
}
Also used : Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 39 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class NaptManager method getExternalAddressMapping.

/**
 * method to get external ip/port mapping when provided with internal ip/port pair
 * If already a mapping exist for the given input, then the existing mapping is returned
 * instead of overwriting with new ip/port pair.
 *
 * @param segmentId     - Router ID
 * @param sourceAddress - internal ip address/port pair
 * @param protocol      - TCP/UDP
 * @return external ip address/port
 */
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
@Nullable
public SessionAddress getExternalAddressMapping(Uint32 segmentId, SessionAddress sourceAddress, NAPTEntryEvent.Protocol protocol) {
    LOG.debug("getExternalAddressMapping : called with segmentId {}, internalIp {} and port {}", segmentId, sourceAddress.getIpAddress(), sourceAddress.getPortNumber());
    /*
         1. Get Internal IP, Port in IP:Port format
         2. Inside DB with routerId get the list of entries and check if it matches with existing IP:Port
         3. If True return SessionAddress of ExternalIp and Port
         4. Else check ip Map and Form the ExternalIp and Port and update DB and then return ExternalIp and Port
         */
    // SessionAddress externalIpPort = new SessionAddress();
    String internalIpPort = sourceAddress.getIpAddress() + ":" + sourceAddress.getPortNumber();
    // First check existing Port Map.
    SessionAddress existingIpPort = checkIpPortMap(segmentId, internalIpPort, protocol);
    if (existingIpPort != null) {
        // populate externalIpPort from IpPortMap and return
        LOG.debug("getExternalAddressMapping : successfully returning existingIpPort as {} and {}", existingIpPort.getIpAddress(), existingIpPort.getPortNumber());
        return existingIpPort;
    }
    // Now check in ip-map
    String externalIp = checkIpMap(segmentId, sourceAddress.getIpAddress());
    if (externalIp == null) {
        LOG.error("getExternalAddressMapping : Unexpected error, internal to external " + "ip map does not exist");
        return null;
    }
    /* Logic assuming internalIp is always ip and not subnet
         * case 1: externalIp is ip
         *        a) goto externalIp pool and getPort and return
         *        b) else return error
         * case 2: externalIp is subnet
         *        a) Take first externalIp and goto that Pool and getPort
         *             if port -> return
         *             else Take second externalIp and create that Pool and getPort
         *             if port ->return
         *             else
         *             Continue same with third externalIp till we exhaust subnet
         *        b) Nothing worked return error
         */
    SubnetUtils externalIpSubnet;
    List<String> allIps = new ArrayList<>();
    String subnetPrefix = "/" + String.valueOf(NatConstants.DEFAULT_PREFIX);
    boolean extSubnetFlag = false;
    if (!externalIp.contains(subnetPrefix)) {
        extSubnetFlag = true;
        externalIpSubnet = new SubnetUtils(externalIp);
        allIps = Arrays.asList(externalIpSubnet.getInfo().getAllAddresses());
        LOG.debug("getExternalAddressMapping : total count of externalIps available {}", externalIpSubnet.getInfo().getAddressCount());
    } else {
        LOG.debug("getExternalAddressMapping : getExternalAddress single ip case");
        if (externalIp.contains(subnetPrefix)) {
            // remove /32 what we got from checkIpMap
            externalIp = externalIp.substring(0, externalIp.indexOf(subnetPrefix));
        }
        allIps.add(externalIp);
    }
    boolean nextExtIpFlag = false;
    for (String extIp : allIps) {
        LOG.info("getExternalAddressMapping : Looping externalIPs with externalIP now as {}", extIp);
        if (nextExtIpFlag) {
            createNaptPortPool(extIp);
            LOG.debug("getExternalAddressMapping : Created Pool for next Ext IP {}", extIp);
        }
        Uint32 extPort = NatUtil.getUniqueId(idManager, extIp, internalIpPort);
        if (extPort == NatConstants.INVALID_ID) {
            LOG.error("getExternalAddressMapping : getExternalAddressMapping, idManager could not " + "allocate id retry if subnet");
            if (!extSubnetFlag) {
                LOG.error("getExternalAddressMapping : getExternalAddressMapping returning null " + "for single IP case, may be ports exhausted");
                return null;
            }
            LOG.debug("getExternalAddressMapping : Could be ports exhausted case, " + "try with another externalIP if possible");
            nextExtIpFlag = true;
            continue;
        }
        // Write to ip-port-map before returning
        IpPortExternalBuilder ipExt = new IpPortExternalBuilder();
        IpPortExternal ipPortExt = ipExt.setIpAddress(extIp).setPortNum(extPort.intValue()).build();
        IpPortMap ipm = new IpPortMapBuilder().withKey(new IpPortMapKey(internalIpPort)).setIpPortInternal(internalIpPort).setIpPortExternal(ipPortExt).build();
        LOG.debug("getExternalAddressMapping : writing into ip-port-map with " + "externalIP {} and port {}", ipPortExt.getIpAddress(), ipPortExt.getPortNum());
        try {
            MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, getIpPortMapIdentifier(segmentId, internalIpPort, protocol), ipm);
        } catch (UncheckedExecutionException uee) {
            LOG.error("getExternalAddressMapping : Failed to write into ip-port-map with exception", uee);
        }
        // Write to snat-internal-ip-port-info
        String internalIpAddress = sourceAddress.getIpAddress();
        int ipPort = sourceAddress.getPortNumber();
        ProtocolTypes protocolType = NatUtil.getProtocolType(protocol);
        final ReentrantLock lock = lockFor(segmentId, internalIpAddress, protocolType);
        lock.lock();
        try {
            List<Uint16> portList = new ArrayList<>(NatUtil.getInternalIpPortListInfo(dataBroker, segmentId, internalIpAddress, protocolType));
            portList.add(Uint16.valueOf(ipPort));
            IntIpProtoTypeBuilder builder = new IntIpProtoTypeBuilder();
            IntIpProtoType intIpProtocolType = builder.withKey(new IntIpProtoTypeKey(protocolType)).setPorts(portList).build();
            try {
                MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, NatUtil.buildSnatIntIpPortIdentifier(segmentId, internalIpAddress, protocolType), intIpProtocolType);
            } catch (Exception ex) {
                LOG.error("getExternalAddressMapping : Failed to write into snat-internal-ip-port-info " + "with exception", ex);
            }
        } finally {
            lock.unlock();
        }
        SessionAddress externalIpPort = new SessionAddress(extIp, extPort.intValue());
        LOG.debug("getExternalAddressMapping : successfully returning externalIP {} " + "and port {}", externalIpPort.getIpAddress(), externalIpPort.getPortNumber());
        return externalIpPort;
    }
    // end of for loop
    LOG.error("getExternalAddressMapping : Unable to handle external IP address and port mapping with segmentId {}," + "internalIp {} and internalPort {}", segmentId, sourceAddress.getIpAddress(), sourceAddress.getPortNumber());
    return null;
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) IntIpProtoTypeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.snatint.ip.port.map.intip.port.map.ip.port.IntIpProtoTypeKey) SubnetUtils(org.apache.commons.net.util.SubnetUtils) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ArrayList(java.util.ArrayList) IntIpProtoTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.snatint.ip.port.map.intip.port.map.ip.port.IntIpProtoTypeBuilder) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) IpPortExternalBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.ip.port.mapping.intext.ip.protocol.type.ip.port.map.IpPortExternalBuilder) IpPortMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.ip.port.mapping.intext.ip.protocol.type.IpPortMapBuilder) SnatintIpPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.SnatintIpPortMap) 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) IpPortMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.ip.port.mapping.intext.ip.protocol.type.IpPortMapKey) ProtocolTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProtocolTypes) Uint16(org.opendaylight.yangtools.yang.common.Uint16) IntIpProtoType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.snatint.ip.port.map.intip.port.map.ip.port.IntIpProtoType) 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) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 40 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class ExternalRoutersListener method removeFlowsFromNonActiveSwitches.

public void removeFlowsFromNonActiveSwitches(Uint32 routerId, String routerName, Uint64 naptSwitchDpnId, TypedReadWriteTransaction<Configuration> removeFlowInvTx) throws ExecutionException, InterruptedException {
    LOG.debug("removeFlowsFromNonActiveSwitches : Remove NAPT related flows from non active switches");
    // Remove the flows from the other switches which points to the primary and secondary switches
    // for the flows related the router ID.
    List<Uint64> allSwitchList = naptSwitchSelector.getDpnsForVpn(routerName);
    if (allSwitchList.isEmpty()) {
        LOG.error("removeFlowsFromNonActiveSwitches : Unable to get the swithces for the router {}", routerName);
        return;
    }
    for (Uint64 dpnId : allSwitchList) {
        if (!naptSwitchDpnId.equals(dpnId)) {
            LOG.info("removeFlowsFromNonActiveSwitches : Handle Ordinary switch");
            // Remove the PSNAT entry which forwards the packet to Terminating Service table
            String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, String.valueOf(routerName));
            FlowEntity preSnatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
            LOG.info("removeFlowsFromNonActiveSwitches : Remove the flow in the {} for the non active switch " + "with the DPN ID {} and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
            mdsalManager.removeFlow(removeFlowInvTx, preSnatFlowEntity);
            // Remove the group entry which forwards the traffic to the out port (VXLAN tunnel).
            Uint32 groupId = NatUtil.getUniqueId(idManager, NatConstants.SNAT_IDPOOL_NAME, NatUtil.getGroupIdKey(routerName));
            if (groupId != NatConstants.INVALID_ID) {
                LOG.info("removeFlowsFromNonActiveSwitches : Remove the group {} for the non active switch with " + "the DPN ID {} and router ID {}", groupId, dpnId, routerId);
                mdsalManager.removeGroup(removeFlowInvTx, dpnId, groupId.longValue());
            } else {
                LOG.error("removeFlowsFromNonActiveSwitches: Unable to obtained groupID for router:{}", routerName);
            }
        }
    }
}
Also used : Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Aggregations

Uint32 (org.opendaylight.yangtools.yang.common.Uint32)216 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)98 ArrayList (java.util.ArrayList)77 ExecutionException (java.util.concurrent.ExecutionException)68 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)68 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)44 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)44 Logger (org.slf4j.Logger)44 LoggerFactory (org.slf4j.LoggerFactory)44 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)42 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)42 Inject (javax.inject.Inject)41 Singleton (javax.inject.Singleton)41 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)41 List (java.util.List)40 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)38 Optional (java.util.Optional)37 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)36 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)35 Collections (java.util.Collections)34