Bug 2368: MD-SAL FRM may update/remove unexpected flow entries. 87/12787/3
authorShigeru Yasuda <s-yasuda@da.jp.nec.com>
Wed, 12 Nov 2014 15:23:08 +0000 (00:23 +0900)
committeravishnoi <vishnoianil@gmail.com>
Fri, 14 Nov 2014 08:16:28 +0000 (08:16 +0000)
FRM should always set strict flag into update-flow/remove-flow
RPC input.

Change-Id: I6027442b56f4cd93cfc3f954dc8501bb57e2d64a
Signed-off-by: Shigeru Yasuda <s-yasuda@da.jp.nec.com>
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/impl/FlowForwarder.java
opendaylight/md-sal/forwardingrules-manager/src/test/java/test/mock/FlowListenerTest.java

index 698dbcb..0d973d6 100644 (file)
@@ -1,4 +1,4 @@
-/**ab
+/**
  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -99,7 +99,13 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
             builder.setFlowRef(new FlowRef(identifier));
             builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
             builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
-            builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+
+            // This method is called only when a given flow object has been
+            // removed from datastore. So FRM always needs to set strict flag
+            // into remove-flow input so that only a flow entry associated with
+            // a given flow object is removed.
+            builder.setTransactionUri(new Uri(provider.getNewTransactionId())).
+                setStrict(Boolean.TRUE);
             provider.getSalFlowService().removeFlow(builder.build());
         }
     }
@@ -116,8 +122,13 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
             builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
             builder.setFlowRef(new FlowRef(identifier));
             builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
-            builder.setUpdatedFlow((new UpdatedFlowBuilder(update)).build());
-            builder.setOriginalFlow((new OriginalFlowBuilder(original)).build());
+
+            // This method is called only when a given flow object in datastore
+            // has been updated. So FRM always needs to set strict flag into
+            // update-flow input so that only a flow entry associated with
+            // a given flow object is updated.
+            builder.setUpdatedFlow((new UpdatedFlowBuilder(update)).setStrict(Boolean.TRUE).build());
+            builder.setOriginalFlow((new OriginalFlowBuilder(original)).setStrict(Boolean.TRUE).build());
 
             provider.getSalFlowService().updateFlow(builder.build());
         }
index 85f4b14..91904cf 100644 (file)
@@ -124,6 +124,8 @@ public class FlowListenerTest extends FRMTest {
         assertEquals(1, updateFlowCalls.size());
         assertEquals("DOM-1", updateFlowCalls.get(0).getTransactionUri().getValue());
         assertEquals(flowII, updateFlowCalls.get(0).getFlowRef().getValue());
+        assertEquals(Boolean.TRUE, updateFlowCalls.get(0).getOriginalFlow().isStrict());
+        assertEquals(Boolean.TRUE, updateFlowCalls.get(0).getUpdatedFlow().isStrict());
 
         forwardingRulesManager.close();
     }
@@ -204,6 +206,7 @@ public class FlowListenerTest extends FRMTest {
         assertEquals(1, removeFlowCalls.size());
         assertEquals("DOM-1", removeFlowCalls.get(0).getTransactionUri().getValue());
         assertEquals(flowII, removeFlowCalls.get(0).getFlowRef().getValue());
+        assertEquals(Boolean.TRUE, removeFlowCalls.get(0).isStrict());
 
         forwardingRulesManager.close();
     }