Search in sources :

Example 11 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project netvirt by opendaylight.

the class ExternalRoutersListener method updateNaptFlowsWithVpnId.

public void updateNaptFlowsWithVpnId(BigInteger dpnId, String routerName, long routerId, long bgpVpnId) {
    // 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("updateNaptFlowsWithVpnId : Unable to retrieve the IpPortMapping");
        return;
    }
    // Get the External Gateway MAC Address
    String extGwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
    if (extGwMacAddress != null) {
        LOG.debug("updateNaptFlowsWithVpnId : External Gateway MAC address {} found for External Router ID {}", extGwMacAddress, routerId);
    } else {
        LOG.error("updateNaptFlowsWithVpnId : No External Gateway MAC address found for External Router ID {}", routerId);
        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("updateNaptFlowsWithVpnId : Unable to retrieve the Internal IP and port");
                return;
            }
            String internalIp = ipPortParts[0];
            String internalPort = ipPortParts[1];
            LOG.debug("updateNaptFlowsWithVpnId : Found Internal IP {} and Internal Port {}", internalIp, internalPort);
            ProtocolTypes protocolTypes = intextIpProtocolType.getProtocol();
            NAPTEntryEvent.Protocol protocol;
            switch(protocolTypes) {
                case TCP:
                    protocol = NAPTEntryEvent.Protocol.TCP;
                    break;
                case UDP:
                    protocol = NAPTEntryEvent.Protocol.UDP;
                    break;
                default:
                    protocol = NAPTEntryEvent.Protocol.TCP;
            }
            SessionAddress internalAddress = new SessionAddress(internalIp, Integer.parseInt(internalPort));
            SessionAddress externalAddress = naptManager.getExternalAddressMapping(routerId, internalAddress, protocol);
            long internetVpnid = NatUtil.getNetworkVpnIdFromRouterId(dataBroker, routerId);
            naptEventHandler.buildAndInstallNatFlows(dpnId, NwConstants.INBOUND_NAPT_TABLE, internetVpnid, routerId, bgpVpnId, externalAddress, internalAddress, protocol, extGwMacAddress);
            naptEventHandler.buildAndInstallNatFlows(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, internetVpnid, routerId, bgpVpnId, internalAddress, externalAddress, protocol, extGwMacAddress);
        }
    }
}
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) ProtocolTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProtocolTypes) IpPortMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.IpPortMapping)

Example 12 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project netvirt by opendaylight.

the class ExternalRoutersListener method handleDisableSnat.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void handleDisableSnat(Routers router, Uuid networkUuid, @Nonnull Collection<String> externalIps, boolean routerFlag, String vpnName, BigInteger naptSwitchDpnId, long routerId, WriteTransaction removeFlowInvTx) {
    LOG.info("handleDisableSnat : Entry");
    String routerName = router.getRouterName();
    try {
        if (routerFlag) {
            removeNaptSwitch(routerName);
        } else {
            updateNaptSwitch(routerName, BigInteger.ZERO);
        }
        LOG.debug("handleDisableSnat : Remove the ExternalCounter model for the router ID {}", routerId);
        naptManager.removeExternalCounter(routerId);
        LOG.debug("handleDisableSnat : got primarySwitch as dpnId {}", naptSwitchDpnId);
        if (naptSwitchDpnId == null || naptSwitchDpnId.equals(BigInteger.ZERO)) {
            LOG.error("handleDisableSnat : Unable to retrieve the primary NAPT switch for the " + "router ID {} from RouterNaptSwitch model", routerId);
            return;
        }
        ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, networkUuid);
        if (extNwProvType == null) {
            LOG.error("handleDisableSnat : External Network Provider Type missing");
            return;
        }
        Collection<Uuid> externalSubnetList = NatUtil.getExternalSubnetIdsFromExternalIps(router.getExternalIps());
        removeNaptFlowsFromActiveSwitch(routerId, routerName, naptSwitchDpnId, networkUuid, vpnName, externalIps, externalSubnetList, removeFlowInvTx, extNwProvType);
        removeFlowsFromNonActiveSwitches(routerId, routerName, naptSwitchDpnId, removeFlowInvTx);
        try {
            String externalSubnetVpn = null;
            for (Uuid externalSubnetId : externalSubnetList) {
                Optional<Subnets> externalSubnet = NatUtil.getOptionalExternalSubnets(dataBroker, externalSubnetId);
                // externalSubnet data model will exist for FLAT/VLAN external netowrk UCs.
                if (externalSubnet.isPresent()) {
                    externalSubnetVpn = externalSubnetId.getValue();
                    clrRtsFromBgpAndDelFibTs(naptSwitchDpnId, routerId, networkUuid, externalIps, externalSubnetVpn, router.getExtGwMacAddress(), removeFlowInvTx);
                }
            }
            if (externalSubnetVpn == null) {
                clrRtsFromBgpAndDelFibTs(naptSwitchDpnId, routerId, networkUuid, externalIps, vpnName, router.getExtGwMacAddress(), removeFlowInvTx);
            }
        } catch (Exception ex) {
            LOG.error("handleDisableSnat : Failed to remove fib entries for routerId {} in naptSwitchDpnId {}", routerId, naptSwitchDpnId, ex);
        }
        // Use the NaptMananager removeMapping API to remove the entire list of IP addresses maintained
        // for the router ID.
        LOG.debug("handleDisableSnat : Remove the Internal to external IP address maintained for the " + "router ID {} in the DS", routerId);
        naptManager.removeMapping(routerId);
    } catch (Exception ex) {
        LOG.error("handleDisableSnat : Exception while handling disableSNAT for router :{}", routerName, ex);
    }
    LOG.info("handleDisableSnat : Exit");
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets) 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) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException)

Example 13 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project netvirt by opendaylight.

the class NatTunnelInterfaceStateListener method hndlTepAddOnNaptSwitch.

private boolean hndlTepAddOnNaptSwitch(BigInteger srcDpnId, String tunnelType, String srcTepIp, String destTepIp, String tunnelName, long routerId, Optional<Routers> routerData, String nextHopIp, Uuid vpnName, ProviderTypes extNwProvType, WriteTransaction writeFlowInvTx) {
    if (!routerData.isPresent()) {
        LOG.warn("hndlTepAddOnNaptSwitch: routerData is not present");
        return false;
    }
    Routers router = routerData.get();
    String routerName = router.getRouterName();
    LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Processing TEP add for the DPN {} having the router {} since " + "its THE NAPT switch for the TUNNEL TYPE {} b/w SRC IP {} and DST IP {} " + "and TUNNEL NAME {} ", srcDpnId, routerName, tunnelType, srcTepIp, destTepIp, tunnelName);
    Uuid networkId = router.getNetworkId();
    if (networkId == null) {
        LOG.warn("hndlTepAddOnNaptSwitch : SNAT -> Ignoring TEP add since the router {} is not associated to the " + "external network", routerName);
        return false;
    }
    LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Router {} is associated with Ext nw {}", routerId, networkId);
    Long vpnId;
    if (vpnName == null) {
        LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Internal VPN associated to router {}", routerId);
        vpnId = NatUtil.getNetworkVpnIdFromRouterId(dataBroker, routerId);
        if (vpnId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNaptSwitch : Invalid External VPN-ID returned for routerName {}", routerName);
            return false;
        }
        LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Retrieved External VPN-ID {} for router {}", vpnId, routerId);
    } else {
        LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Private BGP VPN associated to router {}", routerId);
        vpnId = NatUtil.getVpnId(dataBroker, vpnName.getValue());
        if (vpnId == null || vpnId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNaptSwitch : Invalid vpnId returned for routerName {}", routerName);
            return false;
        }
        LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Retrieved vpnId {} for router {}", vpnId, routerId);
    }
    /*1) Withdraw the old route to the external IP from the BGP which was having the
             next hop as the old TEP IP.
          2) Advertise to the BGP about the new route to the external IP having the
          new TEP IP as the next hop.
          3) Populate a new FIB entry with the next hop IP as the new TEP IP using the
          FIB manager.
        */
    // Withdraw the old route to the external IP from the BGP which was having the
    // next hop as the old TEP IP.
    final String externalVpnName = NatUtil.getAssociatedVPN(dataBroker, networkId);
    if (externalVpnName == null) {
        LOG.error("hndlTepAddOnNaptSwitch :  SNAT -> No VPN associated with ext nw {} in router {}", networkId, routerId);
        return false;
    }
    Collection<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerId);
    LOG.debug("hndlTepAddOnNaptSwitch : Clearing the FIB entries but not the BGP routes");
    for (String externalIp : externalIps) {
        String rd = NatUtil.getVpnRd(dataBroker, externalVpnName);
        LOG.debug("hndlTepAddOnNaptSwitch : Removing Fib entry rd {} prefix {}", rd, externalIp);
        fibManager.removeFibEntry(rd, externalIp, null);
    }
    /*
        Advertise to the BGP about the new route to the external IP having the
        new TEP IP as the next hop.
        Populate a new FIB entry with the next hop IP as the new TEP IP using the
        FIB manager.
        */
    String rd = NatUtil.getVpnRd(dataBroker, externalVpnName);
    if (extNwProvType == null) {
        return false;
    }
    String gwMacAddress = null;
    long l3Vni = 0;
    if (extNwProvType == ProviderTypes.VXLAN) {
        // Get the External Gateway MAC Address which is Router gateway MAC address for SNAT
        gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
        if (gwMacAddress != null) {
            LOG.debug("hndlTepAddOnNaptSwitch : External Gateway MAC address {} found for External Router ID {}", gwMacAddress, routerId);
        } else {
            LOG.error("hndlTepAddOnNaptSwitch : No External Gateway MAC address found for External Router ID {}", routerId);
            return false;
        }
        // get l3Vni value for external VPN
        l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
        if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
            LOG.debug("hndlTepAddOnNaptSwitch : L3VNI value is not configured in Internet VPN {} and RD {} " + "Carve-out L3VNI value from OpenDaylight VXLAN VNI Pool and continue to installing " + "NAT flows", vpnName, rd);
            l3Vni = NatOverVxlanUtil.getInternetVpnVni(idManager, externalVpnName, routerId).longValue();
        }
    }
    for (final String externalIp : externalIps) {
        long serviceId = 0;
        String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp);
        if (extNwProvType == ProviderTypes.VXLAN) {
            LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Advertise the route to the externalIp {} " + "having nextHopIp {}", externalIp, nextHopIp);
            NatEvpnUtil.addRoutesForVxLanProvType(dataBroker, bgpManager, fibManager, externalVpnName, rd, externalIp, nextHopIp, l3Vni, tunnelName, gwMacAddress, writeFlowInvTx, RouteOrigin.STATIC, srcDpnId);
            serviceId = l3Vni;
        } else {
            Long label = externalRouterListner.checkExternalIpLabel(routerId, externalIp);
            if (label == null || label == NatConstants.INVALID_ID) {
                LOG.error("hndlTepAddOnNaptSwitch : SNAT->Unable to advertise to the DC GW " + "since label is invalid");
                return false;
            }
            LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Advertise the route to the externalIp {} " + "having nextHopIp {}", externalIp, nextHopIp);
            long l3vni = 0;
            if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
                l3vni = NatOverVxlanUtil.getInternetVpnVni(idManager, externalVpnName, l3vni).longValue();
            }
            Uuid externalSubnetId = NatUtil.getExternalSubnetForRouterExternalIp(externalIp, router);
            NatUtil.addPrefixToBGP(dataBroker, bgpManager, fibManager, externalVpnName, rd, externalSubnetId, fibExternalIp, nextHopIp, networkId.getValue(), null, /* mac-address */
            label, l3vni, RouteOrigin.STATIC, srcDpnId);
            serviceId = label;
        }
        LOG.debug("hndlTepAddOnNaptSwitch: SNAT -> Install custom FIB routes " + "(Table 21 -> Push MPLS label to Tunnel port");
        List<Instruction> customInstructions = new ArrayList<>();
        int customInstructionIndex = 0;
        long externalSubnetVpnId = NatUtil.getExternalSubnetVpnIdForRouterExternalIp(dataBroker, externalIp, router);
        if (externalSubnetVpnId != NatConstants.INVALID_ID) {
            LOG.debug("hndlTepAddOnNaptSwitch : Will install custom FIB router with external subnet VPN ID {}", externalSubnetVpnId);
            BigInteger subnetIdMetaData = MetaDataUtil.getVpnIdMetadata(externalSubnetVpnId);
            customInstructions.add(new InstructionWriteMetadata(subnetIdMetaData, MetaDataUtil.METADATA_MASK_VRFID).buildInstruction(customInstructionIndex));
            customInstructionIndex++;
        }
        customInstructions.add(new InstructionGotoTable(NwConstants.INBOUND_NAPT_TABLE).buildInstruction(customInstructionIndex));
        CreateFibEntryInput input = new CreateFibEntryInputBuilder().setVpnName(externalVpnName).setSourceDpid(srcDpnId).setInstruction(customInstructions).setIpAddress(fibExternalIp).setServiceId(serviceId).setInstruction(customInstructions).build();
        Future<RpcResult<Void>> future = fibRpcService.createFibEntry(input);
        ListenableFuture<RpcResult<Void>> listenableFuture = JdkFutureAdapters.listenInPoolThread(future);
        Futures.addCallback(listenableFuture, new FutureCallback<RpcResult<Void>>() {

            @Override
            public void onFailure(@Nonnull Throwable error) {
                LOG.error("hndlTepAddOnNaptSwitch : SNAT->Error in generate label or fib install process", error);
            }

            @Override
            public void onSuccess(@Nonnull RpcResult<Void> result) {
                if (result.isSuccessful()) {
                    LOG.info("hndlTepAddOnNaptSwitch : SNAT -> Successfully installed custom FIB routes " + "for prefix {}", externalIp);
                } else {
                    LOG.error("hndlTepAddOnNaptSwitch : SNAT -> Error in rpc call to create custom Fib entries " + "for prefix {} in DPN {}, {}", externalIp, srcDpnId, result.getErrors());
                }
            }
        }, MoreExecutors.directExecutor());
    }
    return true;
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) CreateFibEntryInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInputBuilder) 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) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) BigInteger(java.math.BigInteger) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)

Example 14 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project netvirt by opendaylight.

the class NatUtil method isFloatingIpPresentForDpn.

public static Boolean isFloatingIpPresentForDpn(DataBroker dataBroker, BigInteger dpnId, String rd, String vpnName, String externalIp, Boolean isMoreThanOneFipCheckOnDpn) {
    InstanceIdentifier<VpnToDpnList> id = getVpnToDpnListIdentifier(rd, dpnId);
    Optional<VpnToDpnList> dpnInVpn = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
    if (dpnInVpn.isPresent()) {
        LOG.debug("isFloatingIpPresentForDpn : vpn-to-dpn-list is not empty for vpnName {}, dpn id {}, " + "rd {} and floatingIp {}", vpnName, dpnId, rd, externalIp);
        try {
            List<IpAddresses> ipAddressList = dpnInVpn.get().getIpAddresses();
            if (ipAddressList != null && !ipAddressList.isEmpty()) {
                int floatingIpPresentCount = 0;
                for (IpAddresses ipAddress : ipAddressList) {
                    if (!ipAddress.getIpAddress().equals(externalIp) && IpAddresses.IpAddressSource.FloatingIP.equals(ipAddress.getIpAddressSource())) {
                        floatingIpPresentCount++;
                        // Add tunnel table check
                        if (isMoreThanOneFipCheckOnDpn && floatingIpPresentCount > 1) {
                            return Boolean.TRUE;
                        }
                        // Remove tunnel table check
                        if (!isMoreThanOneFipCheckOnDpn) {
                            return Boolean.TRUE;
                        }
                    }
                }
            } else {
                LOG.debug("isFloatingIpPresentForDpn : vpn-to-dpn-list does not contain any floating IP for DPN {}", dpnId);
                return Boolean.FALSE;
            }
        } catch (NullPointerException e) {
            LOG.error("isFloatingIpPresentForDpn: Exception occurred on getting external IP address from " + "vpn-to-dpn-list on Dpn {}", dpnId, e);
            return Boolean.FALSE;
        }
    }
    return Boolean.FALSE;
}
Also used : IpAddresses(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddresses) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)

Example 15 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project netvirt by opendaylight.

the class InterfaceStateEventListener method removeSnatEntriesForPort.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void removeSnatEntriesForPort(String interfaceName, String routerName) {
    Long routerId = NatUtil.getVpnId(dataBroker, routerName);
    if (routerId == NatConstants.INVALID_ID) {
        LOG.error("removeSnatEntriesForPort : routerId not found for routername {}", routerName);
        return;
    }
    BigInteger naptSwitch = getNaptSwitchforRouter(dataBroker, routerName);
    if (naptSwitch == null || naptSwitch.equals(BigInteger.ZERO)) {
        LOG.error("removeSnatEntriesForPort : NaptSwitch is not elected for router {} with Id {}", routerName, routerId);
        return;
    }
    // getInternalIp for port
    List<String> fixedIps = getFixedIpsForPort(interfaceName);
    if (fixedIps == null) {
        LOG.warn("removeSnatEntriesForPort : Internal Ips not found for InterfaceName {} in router {} with id {}", interfaceName, routerName, routerId);
        return;
    }
    for (String internalIp : fixedIps) {
        LOG.debug("removeSnatEntriesForPort : Internal Ip retrieved for interface {} is {} in router with Id {}", interfaceName, internalIp, routerId);
        IpPort ipPort = NatUtil.getInternalIpPortInfo(dataBroker, routerId, internalIp);
        if (ipPort == null) {
            LOG.debug("removeSnatEntriesForPort : no snatint-ip-port-map found for ip:{}", internalIp);
            continue;
        }
        for (IntIpProtoType protoType : ipPort.getIntIpProtoType()) {
            ProtocolTypes protocol = protoType.getProtocol();
            for (Integer portnum : protoType.getPorts()) {
                // build and remove the flow in outbound table
                try {
                    removeNatFlow(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, routerId, internalIp, portnum);
                } catch (Exception ex) {
                    LOG.error("removeSnatEntriesForPort : Failed to remove snat flow for internalIP {} with " + "Port {} protocol {} for routerId {} in OUTBOUNDTABLE of NaptSwitch {}", internalIp, portnum, protocol, routerId, naptSwitch, ex);
                }
                // Get the external IP address and the port from the model
                NAPTEntryEvent.Protocol proto = protocol.toString().equals(ProtocolTypes.TCP.toString()) ? NAPTEntryEvent.Protocol.TCP : NAPTEntryEvent.Protocol.UDP;
                IpPortExternal ipPortExternal = NatUtil.getExternalIpPortMap(dataBroker, routerId, internalIp, String.valueOf(portnum), proto);
                if (ipPortExternal == null) {
                    LOG.error("removeSnatEntriesForPort : Mapping for internalIp {} with port {} is not found in " + "router with Id {}", internalIp, portnum, routerId);
                    return;
                }
                String externalIpAddress = ipPortExternal.getIpAddress();
                Integer portNumber = ipPortExternal.getPortNum();
                // build and remove the flow in inboundtable
                try {
                    removeNatFlow(naptSwitch, NwConstants.INBOUND_NAPT_TABLE, routerId, externalIpAddress, portNumber);
                } catch (Exception ex) {
                    LOG.error("removeSnatEntriesForPort : Failed to remove snat flow internalIP {} with " + "Port {} protocol {} for routerId {} in INBOUNDTABLE of naptSwitch {}", externalIpAddress, portNumber, protocol, routerId, naptSwitch, ex);
                }
                String internalIpPort = internalIp + ":" + portnum;
                // delete the entry from IntExtIpPortMap DS
                try {
                    naptManager.removeFromIpPortMapDS(routerId, internalIpPort, proto);
                    naptManager.removePortFromPool(internalIpPort, externalIpAddress);
                } catch (Exception ex) {
                    LOG.error("removeSnatEntriesForPort : releaseIpExtPortMapping failed, Removal of " + "ipportmap {} for router {} failed", internalIpPort, routerId, ex);
                }
            }
        }
        // delete the entry from SnatIntIpPortMap DS
        LOG.debug("removeSnatEntriesForPort : Removing InternalIp:{} on router {}", internalIp, routerId);
        naptManager.removeFromSnatIpPortDS(routerId, internalIp);
    }
}
Also used : BigInteger(java.math.BigInteger) ProtocolTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProtocolTypes) BigInteger(java.math.BigInteger) IntIpProtoType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.snatint.ip.port.map.intip.port.map.ip.port.IntIpProtoType) IpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.snatint.ip.port.map.intip.port.map.IpPort) 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) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Test (org.junit.Test)209 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)90 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)79 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)77 ArrayList (java.util.ArrayList)67 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)66 ByteBuf (io.netty.buffer.ByteBuf)57 InetAddress (java.net.InetAddress)57 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)55 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)52 BigInteger (java.math.BigInteger)41 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)41 Inet6Address (java.net.Inet6Address)39 KeyValueAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress)39 Inet4Address (java.net.Inet4Address)36 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)29 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)28 LispAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress)27 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)26 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)25