X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=natservice%2Fnatservice-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fnatservice%2Finternal%2FNaptFlowRemovedEventHandler.java;h=55cdaf9e0b0a650822a20c12d35c0eac360752be;hb=HEAD;hp=f0206e2f7136030def0161bf83fa80a82d0675f6;hpb=54e6f5fa42b79688f159edbf435c060d441a9100;p=vpnservice.git diff --git a/natservice/natservice-impl/src/main/java/org/opendaylight/vpnservice/natservice/internal/NaptFlowRemovedEventHandler.java b/natservice/natservice-impl/src/main/java/org/opendaylight/vpnservice/natservice/internal/NaptFlowRemovedEventHandler.java index f0206e2f..55cdaf9e 100644 --- a/natservice/natservice-impl/src/main/java/org/opendaylight/vpnservice/natservice/internal/NaptFlowRemovedEventHandler.java +++ b/natservice/natservice-impl/src/main/java/org/opendaylight/vpnservice/natservice/internal/NaptFlowRemovedEventHandler.java @@ -22,7 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch; import org.opendaylight.controller.md.sal.binding.api.DataBroker; @@ -70,7 +70,7 @@ public class NaptFlowRemovedEventHandler implements SalFlowListener{ short tableId = switchFlowRemoved.getTableId(); RemovedReasonFlags removedReasonFlag = switchFlowRemoved.getRemovedReason(); - if (tableId == NatConstants.OUTBOUND_NAPT_TABLE) { + if (tableId == NatConstants.OUTBOUND_NAPT_TABLE && removedReasonFlag.isIDLETIMEOUT()) { LOG.info("NaptFlowRemovedEventHandler : onSwitchFlowRemoved() entry"); //Get the internal internal IP address and the port number from the IPv4 match. @@ -137,28 +137,26 @@ public class NaptFlowRemovedEventHandler implements SalFlowListener{ InstanceIdentifier nodeRef = switchFlowRemoved.getNode().getValue().firstIdentifierOf(Node.class); String dpn = nodeRef.firstKeyOf(Node.class).getId().getValue(); BigInteger dpnId = getDpnId(dpn); + String switchFlowRef = NatUtil.getNaptFlowRef(dpnId, tableId, String.valueOf(metadata), internalIpv4HostAddress, internalPortNumber); //Inform the MDSAL manager to inform about the flow removal. - String switchFlowRef = NatUtil.getNaptFlowRef(dpnId, tableId, String.valueOf(metadata), internalIpv4HostAddress, internalPortNumber); LOG.debug("NaptFlowRemovedEventHandler : DPN ID {}, Metadata {}, SwitchFlowRef {}, internalIpv4HostAddress{}", dpnId, metadata, switchFlowRef, internalIpv4AddressAsString); FlowEntity snatFlowEntity = NatUtil.buildFlowEntity(dpnId, tableId, switchFlowRef); mdsalManager.removeFlow(snatFlowEntity); - if(removedReasonFlag.isIDLETIMEOUT()) { - LOG.debug("Received flow removed notification due to idleTimeout of flow from switch for flowref {}",switchFlowRef); - //Remove the SourceIP:Port key from the Napt packet handler map. - String internalIpPortKey = internalIpv4HostAddress + ":" + internalPortNumber; - naptPacketInHandler.removeIncomingPacketMap(internalIpPortKey); - - //Remove the mapping of internal fixed ip/port to external ip/port from the datastore. - SessionAddress internalSessionAddress = new SessionAddress(internalIpv4HostAddress, internalPortNumber); - naptManager.releaseIpExtPortMapping(routerId, internalSessionAddress, protocol); - } else { - LOG.debug("Received flow removed notification due to flowdelete from switch for flowref {}",switchFlowRef); - } + LOG.debug("Received flow removed notification due to idleTimeout of flow from switch for flowref {}",switchFlowRef); + //Remove the SourceIP:Port key from the Napt packet handler map. + String internalIpPortKey = internalIpv4HostAddress + ":" + internalPortNumber; + naptPacketInHandler.removeIncomingPacketMap(internalIpPortKey); + //Remove the mapping of internal fixed ip/port to external ip/port from the datastore. + SessionAddress internalSessionAddress = new SessionAddress(internalIpv4HostAddress, internalPortNumber); + naptManager.releaseIpExtPortMapping(routerId, internalSessionAddress, protocol); LOG.info("NaptFlowRemovedEventHandler : onSwitchFlowRemoved() exit"); + }else { + LOG.debug("Received flow removed notification due to flowdelete from switch for flowref"); } + } private BigInteger getDpnId(String node) {