Bug-1152:Converting PopVlan to StripVlan for OF1.0 87/7887/2
authorKamal Rameshan <kramesha@cisco.com>
Wed, 11 Jun 2014 02:09:23 +0000 (19:09 -0700)
committerKamal Rameshan <kramesha@cisco.com>
Wed, 11 Jun 2014 22:05:15 +0000 (15:05 -0700)
Change-Id: If2d3e8f1ffdc6bbd089d5d073fab55d88fac9900
Signed-off-by: Kamal Rameshan <kramesha@cisco.com>
Bug-1152:Converting StripVlan to PopVlan for OFP-SAL traffic

Change-Id: If2d3e8f1ffdc6bbd089d5d073fab55d88fac9900
Signed-off-by: Kamal Rameshan <kramesha@cisco.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java

index bd99edfdbcdb4ab666188814a1b2e1a7c114a1b2..01eb366118eb215cca32858078d30ebe1e494d86 100644 (file)
@@ -123,7 +123,8 @@ public final class ActionConvertor {
             else if (action instanceof PushVlanActionCase)
                 ofAction = SalToOFPushVlanAction(action, actionBuilder);
             else if (action instanceof PopVlanActionCase)
-                ofAction = SalToOFPopVlan(actionBuilder);
+                ofAction = (version == OFConstants.OFP_VERSION_1_0) ? SalToOFStripVlan(actionBuilder, version)
+                        : SalToOFPopVlan(actionBuilder);
             else if (action instanceof PushMplsActionCase)
                 ofAction = SalToOFPushMplsAction(action, actionBuilder);
             else if (action instanceof PopMplsActionCase)
@@ -696,64 +697,78 @@ public final class ActionConvertor {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
         for (Action action : actionList) {
             if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
                 bucketActions.add(ofToSALOutputAction(action));
-            else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class))
+
+            } else if (action.getType().equals(
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
                 bucketActions.add(ofToSALGroupAction(action));
-            else if (action.getType().equals(
+
+            } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
                 CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
                 bucketActions.add(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
+
             } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
                 CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
                 bucketActions.add(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
+
             } else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
                 bucketActions.add(ofToSALSetMplsTtl(action));
-            else if (action.getType().equals(
+
+            } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
                 DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
                 bucketActions.add(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
+
             } else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
                 bucketActions.add(ofToSALPushVlanAction(action));
-            else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)) {
+
+            } else if (action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)
+                    || action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class)) {
+                // OF1.0 nodes will emit StripVlan and OF1.3+ will emit StripVlan/PopVlan, convert both to PopVlan for SAL
                 PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
                 bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
+
             } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
                 PushMplsActionBuilder pushMpls = new PushMplsActionBuilder();
                 bucketActions.add(new PushMplsActionCaseBuilder().setPushMplsAction(pushMpls.build()).build());
+
             } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
                 PopMplsActionBuilder popMpls = new PopMplsActionBuilder();
                 bucketActions.add(new PopMplsActionCaseBuilder().setPopMplsAction(popMpls.build()).build());
+
             } else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
                 bucketActions.add(ofToSALSetQueue(action));
 
-            else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class))
+            else if (action.getType().equals(
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
                 bucketActions.add(ofToSALSetNwTtl(action));
-            else if (action.getType().equals(
+
+            } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
                 DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
                 bucketActions.add(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
+
             } else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
                 bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.ofToSALSetField(action))
                         .build());
-
-            else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class))
+            } else if (action.getType().equals(
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
                 bucketActions.add(ofToSALPushPbbAction(action));
-            else if (action.getType().equals(
+
+            } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
                 PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
                 bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
+
             } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
                 // bucketActions.add(ofToSALExperimenter(action));