Clear Flow registry on all flow remove 09/92109/8
authorHarshini M <hm@luminanetworks.com>
Wed, 12 Aug 2020 12:01:25 +0000 (17:31 +0530)
committerHarshini M <hm@luminanetworks.com>
Fri, 21 Aug 2020 09:29:53 +0000 (14:59 +0530)
The RPC to clean all flows for an OF switch does not clear the flow descriptors for the deleted flows,
so when RPC Add flow comes later, it finds old descriptor and generates alien ID. Solution is to delete all flow descriptors
when RPC to clean all flows is received.

JIRA : OPNFLWPLUG-1101

Change-Id: I7bc6c6c54ef80c9a8be2a054cb0259dbf268b15d
Signed-off-by: Harshini M <hm@luminanetworks.com>
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/DeviceFlowRegistry.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImpl.java

index b6f355f214fc46e9824140536018bec22dd79d96..7f6e7ea343d31f9a1aa03f6d532b66b613f13ae4 100644 (file)
@@ -28,4 +28,6 @@ public interface DeviceFlowRegistry extends CommonDeviceRegistry<FlowRegistryKey
     @Nullable
     FlowDescriptor retrieveDescriptor(@NonNull FlowRegistryKey flowRegistryKey);
 
+    void clearFlowRegistry();
+
 }
index 0fee0d39aadaeda0f5280055282574e5ee43514b..cea9f5effd166bd998ae4097eb3b813da9b8bcde 100644 (file)
@@ -280,4 +280,9 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
     Map<FlowRegistryKey, FlowDescriptor> getAllFlowDescriptors() {
         return flowRegistry;
     }
+
+    @Override
+    public void clearFlowRegistry() {
+        flowRegistry.clear();
+    }
 }
index ff1f3c8ea2b4bd6fe613ca80d0a79f49266a74a2..ffe22fb4b21a9a394e190d37687ca40021fed604 100644 (file)
@@ -44,6 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,6 +57,7 @@ public class SalFlowServiceImpl implements SalFlowService {
     private final SingleLayerFlowService<UpdateFlowOutput> flowUpdateMessage;
     private final SingleLayerFlowService<RemoveFlowOutput> flowRemoveMessage;
     private final DeviceContext deviceContext;
+    private static final Uint8 OFPTT_ALL = Uint8.MAX_VALUE;
 
     public SalFlowServiceImpl(final RequestContextStack requestContextStack,
                               final DeviceContext deviceContext,
@@ -242,9 +244,13 @@ public class SalFlowServiceImpl implements SalFlowService {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Flow remove finished without error for flow={}", input);
                 }
-                FlowRegistryKey flowRegistryKey =
-                        FlowRegistryKeyFactory.create(deviceContext.getDeviceInfo().getVersion(), input);
-                deviceContext.getDeviceFlowRegistry().addMark(flowRegistryKey);
+                if (input.getTableId() != null && !input.getTableId().equals(OFPTT_ALL)) {
+                    FlowRegistryKey flowRegistryKey =
+                            FlowRegistryKeyFactory.create(deviceContext.getDeviceInfo().getVersion(), input);
+                    deviceContext.getDeviceFlowRegistry().addMark(flowRegistryKey);
+                } else {
+                    deviceContext.getDeviceFlowRegistry().clearFlowRegistry();
+                }
             } else {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Flow remove failed for flow={}, errors={}", input,