fix for BUG-709 - mixed up flow cookie and connection cookie 59/6259/4
authorMichal Rehak <mirehak@cisco.com>
Thu, 17 Apr 2014 15:08:42 +0000 (17:08 +0200)
committerMichal Rehak <mirehak@cisco.com>
Thu, 17 Apr 2014 16:19:17 +0000 (18:19 +0200)
- flow cookie [64b] is present at receivedPacket (to distinguish responsible flow)
- connection cookie [32b] is present at receivedPacket and is expected
  to be copied into corresponding transmitPacketInput (to distinguish auxiliary connection)
- fixed sal-compatibility, l2switch/implementation, sal-binding-it

Change-Id: I331aa3a0f582219a1c604e21466c7a893ee4ed67
Signed-off-by: Michal Rehak <mirehak@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.xtend
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java
opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-flow-types.yang
opendaylight/md-sal/model/model-flow-service/src/main/yang/packet-processing.yang
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NoficationTest.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceTest.java
opendaylight/md-sal/samples/l2switch/implementation/src/main/java/org/opendaylight/controller/sample/l2switch/md/flow/FlowWriterServiceImpl.java

index 6a9712b..75cbf49 100644 (file)
@@ -113,6 +113,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie
 
 public class MDFlowMapping {
 
@@ -127,7 +128,7 @@ public class MDFlowMapping {
 
         hardTimeout = sourceFlow.hardTimeout as int
         idleTimeout = sourceFlow.idleTimeout as int
-        cookie = BigInteger.valueOf(sourceFlow.id)
+        cookie = new FlowCookie(BigInteger.valueOf(sourceFlow.id))
         priority = sourceFlow.priority as int
 
         val sourceActions = sourceFlow.actions;
@@ -150,7 +151,7 @@ public class MDFlowMapping {
        val it = new FlowBuilder();
        hardTimeout = sourceFlow.hardTimeout as int
        idleTimeout = sourceFlow.idleTimeout as int
-       cookie = BigInteger.valueOf(sourceFlow.id)
+       cookie = new FlowCookie(BigInteger.valueOf(sourceFlow.id))
        priority = sourceFlow.priority as int
        id = new FlowId(flowId)
     
@@ -404,7 +405,7 @@ public class MDFlowMapping {
 
         hardTimeout = sourceFlow.hardTimeout as int
         idleTimeout = sourceFlow.idleTimeout as int
-        cookie = BigInteger.valueOf(sourceFlow.id)
+        cookie = new FlowCookie(BigInteger.valueOf(sourceFlow.id))
         priority = sourceFlow.priority as int
 
         val sourceActions = sourceFlow.actions;
index b062b00..63c5664 100644 (file)
@@ -177,7 +177,7 @@ public class TestFromSalConversionsUtils {
     }
 
     private void checkOdFlow(NodeFlow odNodeFlow) {
-        assertEquals("Cookie is incorrect.", 9223372036854775807L, odNodeFlow.getCookie().longValue());
+        assertEquals("Cookie is incorrect.", 9223372036854775807L, odNodeFlow.getCookie().getValue().longValue());
         assertEquals("Hard timeout is incorrect.", 32765, odNodeFlow.getHardTimeout().shortValue());
         assertEquals("Iddle timeout is incorrect.", 32766, odNodeFlow.getIdleTimeout().shortValue());
         assertEquals("Priority is incorrect.", 32767, odNodeFlow.getPriority().shortValue());
index ca16c65..71f2e94 100644 (file)
@@ -105,6 +105,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.addr
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
@@ -347,7 +348,7 @@ public class TestToSalConversionsUtils {
     private FlowAddedBuilder prepareOdFlowCommon() {
         FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
 
-        odNodeFlowBuilder.setCookie(new BigInteger("9223372036854775807"));
+        odNodeFlowBuilder.setCookie(new FlowCookie(new BigInteger("9223372036854775807")));
         odNodeFlowBuilder.setHardTimeout(32767);
         odNodeFlowBuilder.setIdleTimeout(32767);
         odNodeFlowBuilder.setPriority(32767);
index 02bdd1a..0d8a0b6 100644 (file)
@@ -15,6 +15,11 @@ module opendaylight-flow-types {
         type instance-identifier;
     }
     
+    typedef flow-cookie {
+        description "openflow specific type - flow cookie / flow cookie mask";
+        type uint64;
+    }
+    
     typedef output-port-values {
         type enumeration {
             enum MAX {
@@ -143,7 +148,7 @@ module opendaylight-flow-types {
         }
         
         leaf cookie {
-            type uint64;
+            type flow-cookie;
         }
         
         leaf table_id {
@@ -167,7 +172,7 @@ module opendaylight-flow-types {
         }
         
         leaf cookie_mask {
-            type uint64;
+            type flow-cookie;
         }
         
         leaf buffer_id {
index f3db318..50368e4 100644 (file)
@@ -9,13 +9,14 @@ module packet-processing {
     import opendaylight-match-types {prefix match-type;revision-date "2013-10-26";}
     import opendaylight-table-types {prefix table-type;revision-date "2013-10-26";}
     import opendaylight-action-types {prefix action-type;revision-date "2013-11-12";}
+    import opendaylight-flow-types {prefix flow-type;revision-date "2013-10-26";}
 
     
     revision "2013-07-09" {
         description "";
     }
 
-    typedef cookie {
+    typedef connection-cookie {
         type uint32;
     }
 
@@ -58,8 +59,12 @@ module packet-processing {
     }
 
     notification packet-received {
-       leaf cookie {
-                type cookie;
+       leaf connection-cookie {
+                type connection-cookie;
+        }
+        
+        leaf flow-cookie {
+            type flow-type:flow-cookie;
         }
         
         leaf table-id {
@@ -83,14 +88,14 @@ module packet-processing {
        input {
             uses inv:node-context-ref;
 
-            leaf cookie {
-                type cookie;
+            leaf connection-cookie {
+                type connection-cookie;
             }
             
                leaf egress {
                        type inv:node-connector-ref;
                }
-               leaf buffer-id {
+            leaf buffer-id {
                   type uint32;
             }
 
index b23ceaa..9519a2a 100644 (file)
@@ -31,6 +31,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.FlowCookie;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.opendaylight.yangtools.yang.binding.RpcService;
@@ -99,7 +100,7 @@ public class NoficationTest extends AbstractTest {
          *
          */
         assertEquals(1, listener1.addedFlows.size());
-        assertEquals(0, listener1.addedFlows.get(0).getCookie().intValue());
+        assertEquals(0, listener1.addedFlows.get(0).getCookie().getValue().intValue());
 
         /**
          * The registration of the Consumer 2. SalFlowListener is registered
@@ -196,7 +197,7 @@ public class NoficationTest extends AbstractTest {
      */
     public static FlowAdded flowAdded(int i) {
         FlowAddedBuilder ret = new FlowAddedBuilder();
-        ret.setCookie(BigInteger.valueOf(i));
+        ret.setCookie(new FlowCookie(BigInteger.valueOf(i)));
         return ret.build();
     }
 
index 9c24ca0..d49d6f0 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
@@ -209,7 +210,7 @@ public class RoutedServiceTest extends AbstractTest {
     static AddFlowInput createSampleAddFlow(NodeRef node, int cookie) {
         AddFlowInputBuilder ret = new AddFlowInputBuilder();
         ret.setNode(node);
-        ret.setCookie(BigInteger.valueOf(cookie));
+        ret.setCookie(new FlowCookie(BigInteger.valueOf(cookie)));
         return ret.build();
     }
 }
index f49771a..065d0ee 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.sample.l2switch.md.flow;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
+
 import org.opendaylight.controller.sample.l2switch.md.topology.NetworkGraphService;
 import org.opendaylight.controller.sample.l2switch.md.util.InstanceIdentifierUtils;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
@@ -25,6 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
@@ -261,7 +263,7 @@ public class FlowWriterServiceImpl implements FlowWriterService {
         .setBufferId(0L) //
         .setHardTimeout(0) //
         .setIdleTimeout(0) //
-        .setCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement()))
+        .setCookie(new FlowCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement())))
         .setFlags(new FlowModFlags(false, false, false, false, false));
 
     return macToMacFlow.build();

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.