Fix IPv6 OXMHeader Mask issue for multi-layer 20/71420/2
authorD Arunprakash <d.arunprakash@ericsson.com>
Thu, 26 Apr 2018 13:22:36 +0000 (18:52 +0530)
committerD Arunprakash <d.arunprakash@ericsson.com>
Thu, 26 Apr 2018 15:34:01 +0000 (21:04 +0530)
When programming an OVS flow to set an ipv6_src/dest as
an action field (i.e., set_field:2001::1->ipv6_src), the
current implementation is not checking the Mask and is
including the Mask (even for a full ipv6 address) in the
OXM header. Because of this, switch is rejecting the flow
with the following error.

"decode error: OFPBAC_BAD_SET_MASK. OXM header 0:32768:26:1:32
includes mask but masked OXMs are not allowed here"

This patch addresses this issue by checking the prefix and
including the prefix only if applicable.

Ref: https://git.opendaylight.org/gerrit/#/c/57694/

Change-Id: I75323601289712d98a67e1a3439f7bd41f88cba0
Signed-off-by: D Arunprakash <d.arunprakash@ericsson.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv6MatchCase.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorTest.java

index d86d2e227d26afb811ab65743ca4c2ded77784ae..c692a6166241eab97a82fbd8d7ab15bcc8c5664f 100644 (file)
@@ -64,7 +64,7 @@ public class SalToOfIpv6MatchCase extends ConvertorCase<Ipv6Match, List<MatchEnt
 
             Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
             Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
-            final Integer prefix = IpConversionUtil.extractIpv6Prefix(ipv6Prefix);
+            final Integer prefix = IpConversionUtil.hasIpv6Prefix(ipv6Prefix);
             boolean hasMask = false;
             if (null != prefix) {
                 ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
@@ -85,7 +85,7 @@ public class SalToOfIpv6MatchCase extends ConvertorCase<Ipv6Match, List<MatchEnt
 
             Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
             Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
-            final Integer prefix = IpConversionUtil.extractIpv6Prefix(ipv6Prefix);
+            final Integer prefix = IpConversionUtil.hasIpv6Prefix(ipv6Prefix);
             boolean hasMask = false;
             if (null != prefix) {
                 ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
index e29730b32b8a7649f5173c033d9e3bbfb4f3dd6d..726d4d31b6505e2d9d417cfee6f0a8e43c4033df 100644 (file)
@@ -573,11 +573,11 @@ public class MatchConvertorTest {
         /* Due to conversion ambiguities, we always get "has mask" because
          * an ip with no mask and prefix with /128 (or 32 in v4) cannot
          * be distinguished */
-        checkEntryHeader(entry, Ipv6Src.class, true);
+        checkEntryHeader(entry, Ipv6Src.class, false);
         Assert.assertEquals("Wrong ipv6 src", "::1",
                 ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());
         entry = entries.get(1);
-        checkEntryHeader(entry, Ipv6Dst.class, true);
+        checkEntryHeader(entry, Ipv6Dst.class, false);
         Assert.assertEquals("Wrong ipv6 dst", "::2",
                 ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());
         entry = entries.get(2);