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 6a9712b1c6a41a093bd905996606290b4e33289e..75cbf49ee50fa2b529714ae4807f6426ac4f029d 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 cb7289685831b75d275335c1aa6c9b2c44bc4532..74b94c7cba10771fee33f10eeddb6e6a0c2e2b16 100644 (file)
@@ -148,7 +148,7 @@ public class ToSalConversionsUtils {
             target.setActions(actionFrom(actions, node));
         }
 
-        target.setId(source.getCookie().longValue());
+        target.setId(source.getCookie().getValue().longValue());
         return target;
     }
 
index b062b0016d54340040dc6a827b5cf6eb745f4076..63c5664a0c4b2de63e5b6e90279eb59f37e050ef 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 ca16c65f5613ac7682a304aa8e171a6701f5675d..71f2e9480543feae77bb92275595c29d2119f1c6 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 02bdd1a1fa8a8510ebad0b27be5a2aa29e1bdd9e..0d8a0b6f549c1d9583d54386d045cb9bd4b83468 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 f3db3181f7935665a8731d5bb76119aac5036df4..50368e46a6a3f100725ac2fa80f3bca4eb9dcec2 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 b23ceaaf15b69c0bed04977b97e3bcefb7eab50a..9519a2a732491f9fc51bb16f26f8bd3bc6958989 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 9c24ca08303b4f524198808b174ce0af67469bc6..d49d6f0e25e271e43c8550feb5eef63d96301184 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 f49771a953b5ad93d6d60e6cc73f1c3a5473fb6b..065d0ee7ba2a29c55bed1ef157be991e9f2f3a7c 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();