Bug 7984: IDLE_TIMEOUT check required in onFlowRemoved. 88/53288/5
authorcgowdru <chetan.arakere@altencalsoftlabs.com>
Tue, 14 Mar 2017 18:10:56 +0000 (23:40 +0530)
committerVivekanandan Narasimhan <n.vivekanandan@ericsson.com>
Tue, 21 Mar 2017 05:52:40 +0000 (05:52 +0000)
Description: When FlowRemoved notification is received,
We are taking care of deleting the INBOUND_NAPT_TABLE entry
and releasing the allocated external port for an external-ip.
This is valid only if onFlowRemoved received due to OUTBOUND_NAPT_TABLE
removed beause of IDLE_TIMEOUT. When Switch goes down, we re-elect
a new NAPT switch and re-install ongoing session flows. It is required
not to release the allocated external port during Switch down, but
should be done only during IDLE_TIMEOUT.

Initially, we have the check but been removed with review
https://git.opendaylight.org/gerrit/#/c/49214/. Also plugin support
to get the RemovedReason was not available with onFlowRemoved.

Now, we have the plugin support to get the removed reason which can be
used. https://git.opendaylight.org/gerrit/#/c/50335/

Change-Id: I5708fbd1755719ea0cdabe29eaf0787076a46f24
Signed-off-by: cgowdru <chetan.arakere@altencalsoftlabs.com>
vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NaptFlowRemovedEventHandler.java

index 209aa67ee9acfb6197f01094e281f08509dfb6a7..33f95056bffeffb6dcd8275609dd0fe4d202cac5 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Node
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.RemovedFlowReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.TcpMatchFields;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.UdpMatchFields;
@@ -87,8 +88,9 @@ public class NaptFlowRemovedEventHandler implements SalFlowListener {
 */
 
         short tableId = flowRemoved.getTableId();
-
-        if (tableId == NwConstants.OUTBOUND_NAPT_TABLE) {
+        RemovedFlowReason removedReasonFlag = flowRemoved.getReason();
+        if (tableId == NwConstants.OUTBOUND_NAPT_TABLE
+                && RemovedFlowReason.OFPRRIDLETIMEOUT.equals(removedReasonFlag)) {
             LOG.info("NaptFlowRemovedEventHandler : onSwitchFlowRemoved() entry");
 
             //Get the internal internal IP address and the port number from the IPv4 match.