BUG-1056 brocastflow is not proper modified after deleting interface 70/7270/3
authorHsin-Yi Shen <hshen@redhat.com>
Tue, 20 May 2014 22:54:35 +0000 (18:54 -0400)
committerHsin-Yi Shen <hshen@redhat.com>
Thu, 26 Jun 2014 18:02:43 +0000 (18:02 +0000)
Current logic for flow mod is not correct and this fix intends to fix the flow mod logic.

When removing the output action due to port deleting, current logic just record number of output action type in the action list until the loop find the item we want to delete. So if the deleted item happens to be the first output action in the action list (while there are other output actions in the list), the number of output action type is 0 and flow is deleted. This is wrong behavior. The flow should be modified to remove the output action, not removed in this case.

This fix uses boolean flag instead. The flag is set to true if it find any output action other than the deleted one exists in the action list. So the flow only gets removed when no other output actions are found. This is the desired logic and behavior we want.

Signed-off-by: Hsin-Yi Shen <hshen@redhat.com>
neutron/src/main/java/org/opendaylight/ovsdb/neutron/provider/OF13Provider.java

index 542128a4317c76c057f7be39e559c7a7a94a058f..645561a20d84c51c3f266848cdad60f82a6ed2f6 100644 (file)
@@ -3471,7 +3471,7 @@ public class OF13Provider implements NetworkProvider {
                                 Long dpidLong, Long port , List<Instruction> instructions) {
 
         NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
-        logger.debug("createOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}", dpidLong, port, instructions);
+        logger.debug("removeOutputPortFromInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}", dpidLong, port, instructions);
 
         List<Action> actionList = new ArrayList<Action>();
         ActionBuilder ab;
@@ -3487,21 +3487,20 @@ public class OF13Provider implements NetworkProvider {
             }
         }
 
-        int numOutputPort = 0;
         int index = 0;
         boolean isPortDeleted = false;
+        boolean removeFlow = true;
         for (Action action : actionList) {
             if (action.getAction() instanceof OutputActionCase) {
-                numOutputPort++;
                 OutputActionCase opAction = (OutputActionCase)action.getAction();
                 if (opAction.getOutputAction().getOutputNodeConnector().equals(new Uri(ncid))) {
                     /* Find the output port in action list and remove */
                     index = actionList.indexOf(action);
                     actionList.remove(action);
                     isPortDeleted = true;
-                    numOutputPort--;
                     break;
                 }
+                removeFlow = false;
             }
         }
 
@@ -3518,15 +3517,18 @@ public class OF13Provider implements NetworkProvider {
                     actionList.remove(action);
                     actionList.add(i, actionNewOrder);
                 }
+                if (action.getAction() instanceof OutputActionCase) {
+                    removeFlow = false;
+                }
             }
         }
 
         /* Put new action list in Apply Action instruction */
-        if (numOutputPort > 0) {
+        if (!removeFlow) {
             ApplyActionsBuilder aab = new ApplyActionsBuilder();
             aab.setAction(actionList);
             ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-            logger.debug("createOutputPortInstructions() : applyAction {}", aab.build());
+            logger.debug("removeOutputPortFromInstructions() : applyAction {}", aab.build());
             return false;
         } else {
             /* if all output port are removed. Return true to indicate flow remove */