Handling the case where vlan priority is set to 0. 10/5010/3
authorAsad Ahmed <asaahmed@cisco.com>
Wed, 29 Jan 2014 22:36:16 +0000 (14:36 -0800)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 30 Jan 2014 17:00:22 +0000 (17:00 +0000)
Change-Id: I0d9735343633c2efc1f6a3a5c768aad3f7c88c90
Signed-off-by: Asad Ahmed <asaahmed@cisco.com>
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java
opendaylight/protocol_plugins/openflow/src/test/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowProgrammerServiceTest.java
opendaylight/protocol_plugins/openflow/src/test/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6ExtensionTest.java

index 78a2ea5120da60ad09053efb894e039533c52d68..6d1c563aa44729581b5eb46b5e61f8cb0543b47a 100644 (file)
@@ -539,7 +539,7 @@ public class FlowConverter {
                         salMatch.setField(new MatchField(MatchType.DL_VLAN,
                                 vlan));
                     }
                         salMatch.setField(new MatchField(MatchType.DL_VLAN,
                                 vlan));
                     }
-                    if (ofMatch.getDataLayerVirtualLanPriorityCodePoint() != 0) {
+                    if ((ofMatch.getWildcards() & OFMatch.OFPFW_DL_VLAN_PCP) == 0) {
                         salMatch.setField(MatchType.DL_VLAN_PR, ofMatch
                                 .getDataLayerVirtualLanPriorityCodePoint());
                     }
                         salMatch.setField(MatchType.DL_VLAN_PR, ofMatch
                                 .getDataLayerVirtualLanPriorityCodePoint());
                     }
@@ -612,7 +612,7 @@ public class FlowConverter {
                         salMatch.setField(new MatchField(MatchType.DL_VLAN,
                                 vlan));
                     }
                         salMatch.setField(new MatchField(MatchType.DL_VLAN,
                                 vlan));
                     }
-                    if (v6Match.getDataLayerVirtualLanPriorityCodePoint() != 0) {
+                    if ((v6Match.getWildcards() & OFMatch.OFPFW_DL_VLAN_PCP) == 0) {
                         salMatch.setField(MatchType.DL_VLAN_PR, v6Match
                                 .getDataLayerVirtualLanPriorityCodePoint());
                     }
                         salMatch.setField(MatchType.DL_VLAN_PR, v6Match
                                 .getDataLayerVirtualLanPriorityCodePoint());
                     }
index 4daa591ba1e1811c9262b5c1a806d7fa7180a763..cfe20a1fa2a6f13e35804f2eb389787314a6a9b8 100644 (file)
@@ -216,7 +216,7 @@ public class V6Match extends OFMatch implements Cloneable {
             this.dlVlanIDState = MatchFieldState.MATCH_ABSENT;
         }
 
             this.dlVlanIDState = MatchFieldState.MATCH_ABSENT;
         }
 
-        if (match.getDataLayerVirtualLanPriorityCodePoint() != 0) {
+        if ((match.getWildcards() & OFMatch.OFPFW_DL_VLAN_PCP) == 0) {
             this.setDataLayerVirtualLanPriorityCodePoint(
                     match.getDataLayerVirtualLanPriorityCodePoint(), (byte) 0);
         } else {
             this.setDataLayerVirtualLanPriorityCodePoint(
                     match.getDataLayerVirtualLanPriorityCodePoint(), (byte) 0);
         } else {
@@ -839,14 +839,12 @@ public class V6Match extends OFMatch implements Cloneable {
                     // extract the vlan id
                     super.setDataLayerVirtualLan(getVlanID(firstByte,
                             secondByte));
                     // extract the vlan id
                     super.setDataLayerVirtualLan(getVlanID(firstByte,
                             secondByte));
-                } else {
                     this.wildcards ^= (1 << 1); // Sync with 0F 1.0 Match
                 }
                 if ((this.dataLayerVirtualLanTCIMask & 0xe000) != 0) {
                     // else if its a vlan pcp mask
                     // extract the vlan pcp
                     super.setDataLayerVirtualLanPriorityCodePoint(getVlanPCP(firstByte));
                     this.wildcards ^= (1 << 1); // Sync with 0F 1.0 Match
                 }
                 if ((this.dataLayerVirtualLanTCIMask & 0xe000) != 0) {
                     // else if its a vlan pcp mask
                     // extract the vlan pcp
                     super.setDataLayerVirtualLanPriorityCodePoint(getVlanPCP(firstByte));
-                } else {
                     this.wildcards ^= (1 << 20);
                 }
                 this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_WITH_MASK;
                     this.wildcards ^= (1 << 20);
                 }
                 this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_WITH_MASK;
@@ -864,6 +862,8 @@ public class V6Match extends OFMatch implements Cloneable {
                 super.setDataLayerVirtualLan(getVlanID(firstByte, secondByte));
                 this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_ONLY;
                 this.match_len += 6;
                 super.setDataLayerVirtualLan(getVlanID(firstByte, secondByte));
                 this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_ONLY;
                 this.match_len += 6;
+                this.wildcards ^= (1 << 1); // Sync with 0F 1.0 Match
+                this.wildcards ^= (1 << 20);
             }
         }
     }
             }
         }
     }
@@ -1216,8 +1216,6 @@ public class V6Match extends OFMatch implements Cloneable {
                 // ipv4 dest processing
                 this.wildcards ^= (((1 << 5) - 1) << 14);
             }
                 // ipv4 dest processing
                 this.wildcards ^= (((1 << 5) - 1) << 14);
             }
-        } else {
-            this.wildcards = 0;
         }
     }
 
         }
     }
 
index a751948de7d5a73d22696f66a0bcefb15ca82b53..96f0d80022a5be59ea716d46b2cf8c5e26d20f1b 100644 (file)
@@ -18,9 +18,6 @@ import java.util.List;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Match;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Match;
-import org.openflow.protocol.OFMatch;
-import org.openflow.protocol.action.OFAction;
-
 import org.opendaylight.controller.sal.action.Action;
 import org.opendaylight.controller.sal.action.Flood;
 import org.opendaylight.controller.sal.action.FloodAll;
 import org.opendaylight.controller.sal.action.Action;
 import org.opendaylight.controller.sal.action.Flood;
 import org.opendaylight.controller.sal.action.FloodAll;
@@ -46,6 +43,9 @@ import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.NodeCreator;
 import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.openflow.protocol.OFMatch;
+import org.openflow.protocol.action.OFAction;
+import org.openflow.util.U32;
 
 public class FlowProgrammerServiceTest {
 
 
 public class FlowProgrammerServiceTest {
 
@@ -298,6 +298,16 @@ public class FlowProgrammerServiceTest {
          */
         FlowConverter salToOF = new FlowConverter(aFlow);
         V6Match v6Match = (V6Match) salToOF.getOFMatch();
          */
         FlowConverter salToOF = new FlowConverter(aFlow);
         V6Match v6Match = (V6Match) salToOF.getOFMatch();
+        // need this hardcoding here to make the test pass.
+        // this should not be a problem in actual code.
+        // in the test the sal match is converted to a V6 match.
+        // we lose the wildcard info as the V6 match is used for nicira extensions
+        // and nicira deals with wildcards in a different way.
+        // converting the V6 match back to sal match is not going to preserve the wildcard info.
+        // and we need the wildcard info for reading the vlan pcp now.
+        // when creating a V6Match using the readFrom method
+        // we do convert the nicira extensions format correctly to populate the wildcard info.
+        v6Match.setWildcards(U32.t(Long.valueOf(~OFMatch.OFPFW_DL_VLAN_PCP)));
         List<OFAction> ofActions = salToOF.getOFActions();
 
         /*
         List<OFAction> ofActions = salToOF.getOFActions();
 
         /*
index 7782aa9093762c1041775a6cf0f7bde1d0093e84..abbc43809db820b888827b47bcda908a3a05f2e5 100644 (file)
@@ -17,6 +17,7 @@ import java.util.Arrays;
 import org.junit.Assert;
 import org.junit.Test;
 import org.openflow.protocol.OFMatch;
 import org.junit.Assert;
 import org.junit.Test;
 import org.openflow.protocol.OFMatch;
+import org.openflow.util.U32;
 
 public class V6ExtensionTest {
 
 
 public class V6ExtensionTest {
 
@@ -52,20 +53,18 @@ public class V6ExtensionTest {
         match.fromString("input_port=1");
         match.fromString("dl_dst=20:A0:11:10:00:99");
         match.fromString("dl_src=00:10:08:22:12:75");
         match.fromString("input_port=1");
         match.fromString("dl_dst=20:A0:11:10:00:99");
         match.fromString("dl_src=00:10:08:22:12:75");
-
         match.fromString("ip_src=10.1.1.1");
         match.fromString("ip_dst=1.2.3.4");
         match.fromString("eth_type=0x800");
         match.fromString("dl_vlan=10");
         match.fromString("ip_src=10.1.1.1");
         match.fromString("ip_dst=1.2.3.4");
         match.fromString("eth_type=0x800");
         match.fromString("dl_vlan=10");
-        match.fromString("dl_vpcp=1");
         match.fromString("nw_proto=6");
         match.fromString("nw_tos=100");
         match.fromString("tp_dst=8080");
         match.fromString("tp_src=60");
         match.fromString("nw_proto=6");
         match.fromString("nw_tos=100");
         match.fromString("tp_dst=8080");
         match.fromString("tp_src=60");
+        match.fromString("dl_vpcp=1");
 
         Assert.assertTrue(match.getInputPort() == 1);
         // Assert.assertTrue(match.getIPv6MatchLen()==6);
 
         Assert.assertTrue(match.getInputPort() == 1);
         // Assert.assertTrue(match.getIPv6MatchLen()==6);
-
         ofm.setInputPort((short) 1);
         // V6Match is meant for IPv6, but if using OFMatch, it will be set to
         // IPv4 values, as OF1.0 doesn't support IPv6.
         ofm.setInputPort((short) 1);
         // V6Match is meant for IPv6, but if using OFMatch, it will be set to
         // IPv4 values, as OF1.0 doesn't support IPv6.
@@ -89,6 +88,13 @@ public class V6ExtensionTest {
         ofm.setTransportSource((short) 60);
         ofm.setTransportDestination((short) 8080);
 
         ofm.setTransportSource((short) 60);
         ofm.setTransportDestination((short) 8080);
 
+        // this v6match ctor now looks at the wildcard field to
+        // determine if vlan pcp has been set
+        // so set the wildcards appropriately to reflect that vlan pcp
+        // has been set.
+        int wildcards = OFMatch.OFPFW_ALL;
+        wildcards &= ~OFMatch.OFPFW_DL_VLAN_PCP;
+        ofm.setWildcards(U32.t(Long.valueOf(wildcards)));
         V6Match match3 = new V6Match(ofm);
 
         Assert.assertTrue(match.getInputPort() == match3.getInputPort());
         V6Match match3 = new V6Match(ofm);
 
         Assert.assertTrue(match.getInputPort() == match3.getInputPort());