* In the case of ARP_SPA, ARP_TPA and IPV6_FLABEL a masked match should be
  used unless the mask is all ones.

  Previously a non-masked matched was used in the case were the mask was
  zero, leading to the value being unmasked, whereas in should be completely
  masked out.

* An un-masked IPV6_FLABEL should internally use a mask of UINT32_MAX

Signed-off-by: Simon Horman <[email protected]>

---

v2: Set flabel in set_ipv6_flabel().
    v1 incorrectly set it in set_ipv6_dst_masked()

v3: Remove call to ft_set() in set_ipv6_flabel() as it is called in
    set_ipv6_flabel_masked()
---
 ryu/ofproto/ofproto_v1_2_parser.py | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_2_parser.py 
b/ryu/ofproto/ofproto_v1_2_parser.py
index d584f7d..06a71e4 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -1587,17 +1587,17 @@ class OFPMatch(object):
             self.append_field(ofproto_v1_2.OXM_OF_ARP_OP, self.flow.arp_op)
 
         if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_ARP_SPA):
-            if self.wc.arp_spa_mask:
-                header = ofproto_v1_2.OXM_OF_ARP_SPA_W
-            else:
+            if self.wc.arp_spa_mask == UINT32_MAX:
                 header = ofproto_v1_2.OXM_OF_ARP_SPA
+            else:
+                header = ofproto_v1_2.OXM_OF_ARP_SPA_W
             self.append_field(header, self.flow.arp_spa, self.wc.arp_spa_mask)
 
         if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_ARP_TPA):
-            if self.wc.arp_tpa_mask:
-                header = ofproto_v1_2.OXM_OF_ARP_TPA_W
-            else:
+            if self.wc.arp_tpa_mask == UINT32_MAX:
                 header = ofproto_v1_2.OXM_OF_ARP_TPA
+            else:
+                header = ofproto_v1_2.OXM_OF_ARP_TPA_W
             self.append_field(header, self.flow.arp_tpa, self.wc.arp_tpa_mask)
 
         if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_ARP_SHA):
@@ -1631,10 +1631,10 @@ class OFPMatch(object):
                               self.wc.ipv6_dst_mask)
 
         if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_IPV6_FLABEL):
-            if self.wc.ipv6_flabel_mask:
-                header = ofproto_v1_2.OXM_OF_IPV6_FLABEL_W
-            else:
+            if self.wc.ipv6_flabel_mask == UINT32_MAX:
                 header = ofproto_v1_2.OXM_OF_IPV6_FLABEL
+            else:
+                header = ofproto_v1_2.OXM_OF_IPV6_FLABEL_W
             self.append_field(header, self.flow.ipv6_flabel,
                               self.wc.ipv6_flabel_mask)
 
@@ -1858,8 +1858,7 @@ class OFPMatch(object):
         self.flow.ipv6_dst = [x & y for (x, y) in itertools.izip(dst, mask)]
 
     def set_ipv6_flabel(self, flabel):
-        self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_IPV6_FLABEL)
-        self.flow.ipv6_flabel = flabel
+        self.set_ipv6_flabel_masked(flabel, UINT32_MAX)
 
     def set_ipv6_flabel_masked(self, flabel, mask):
         self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_IPV6_FLABEL)
-- 
1.7.10.2.484.gcd07cc5


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to