Fix stale snatmiss group entry on non-NAPT Switch (conntrack snat) 30/72830/2
authorSridhar Gaddam <sgaddam@redhat.com>
Mon, 11 Jun 2018 04:31:43 +0000 (10:01 +0530)
committerSam Hague <shague@redhat.com>
Tue, 12 Jun 2018 13:11:07 +0000 (13:11 +0000)
NETVIRT-1157: In Conntrack SNAT mode, when the router is disassociated
from the external network, the NAPT Switch is deleted. Now during this
process, the snatmiss group entry was not deleted (aka stale flow)
from the non-NAPT Switch. This patch fixes this issue.

Change-Id: I8acec7532a38b31e045dc586f2d00a91f320cb80
Signed-off-by: Sridhar Gaddam <sgaddam@redhat.com>
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/AbstractSnatService.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/VxlanGreConntrackBasedSnatService.java

index e5939d1518fe01657f5e51c7bee1e3e76b9d5c77..bfaeb4b8b658b181c1e0cbe344f16d13d19365a2 100644 (file)
@@ -239,8 +239,15 @@ public abstract class AbstractSnatService implements SnatServiceListener {
         long groupId = createGroupId(getGroupIdKey(routerName));
         GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll,
                 listBucketInfo);
-        LOG.debug("installSnatMissEntry : installing the SNAT to NAPT GroupEntity:{}", groupEntity);
-        mdsalManager.installGroup(groupEntity);
+
+        if (addOrRemove == NwConstants.ADD_FLOW) {
+            LOG.debug("installing the PSNAT to NAPTSwitch GroupEntity:{} with GroupId: {}", groupEntity, groupId);
+            mdsalManager.installGroup(groupEntity);
+        } else {
+            LOG.debug("removing the PSNAT to NAPTSwitch GroupEntity:{} with GroupId: {}", groupEntity, groupId);
+            mdsalManager.syncRemoveGroup(groupEntity);
+        }
+
         // Install miss entry pointing to group
         LOG.debug("installSnatMissEntry : buildSnatFlowEntity is called for dpId {}, routerName {} and groupId {}",
                 dpnId, routerName, groupId);
index dbfaa55a6026788bbc989ac28d2b68f8e858d6f5..975b86051f40444b560a2ffb86365d1d83eab8f6 100644 (file)
@@ -83,7 +83,8 @@ public class VxlanGreConntrackBasedSnatService extends ConntrackBasedSnatService
         ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(dataBroker, routers.getNetworkId());
         LOG.debug("VxlanGreConntrackBasedSnatService: handleSnatAllSwitch ProviderTypes {}", extNwProviderType);
         if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
-            return false;
+            LOG.debug("handleSnatAllSwitch : Skip FLAT/VLAN provider networks.");
+            return true;
         }
         return super.handleSnatAllSwitch(routers, primarySwitchId, addOrRemove);
     }
@@ -93,7 +94,8 @@ public class VxlanGreConntrackBasedSnatService extends ConntrackBasedSnatService
         ProviderTypes extNwProviderType = NatUtil.getProviderTypefromNetworkId(dataBroker, routers.getNetworkId());
         LOG.debug("VxlanGreConntrackBasedSnatService: handleSnat ProviderTypes {}", extNwProviderType);
         if (extNwProviderType == ProviderTypes.FLAT || extNwProviderType == ProviderTypes.VLAN) {
-            return false;
+            LOG.debug("handleSnat : Skip FLAT/VLAN provider networks.");
+            return true;
         }
         return super.handleSnat(routers, primarySwitchId, dpnId, addOrRemove);
     }