summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorblacksheeep <christopher.scherb@stud.unibas.ch>2013-04-08 15:17:35 +0200
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-04-09 07:10:48 +0900
commit1e9c9c38f495dd212bc8483e068df46a8e641df7 (patch)
tree2bee7a751b6244bdb9c35b74fba9a21b57fd50c6
parent7a4a384fb7f51cf5f54c7fd05e69fa82346f13e9 (diff)
nx: match_tuple() function now handles nw src/dst
match_tuple() function now handles nw src/dst correctly. FIX: match_tuple function now handles the nw src/dst masks correctly. If the mask is not valid, because there is no NX, it will be ignored. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/nx_match.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 5749c36f..6c514e66 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -337,15 +337,15 @@ class ClsRule(object):
if self.flow.nw_proto != 0:
wildcards &= ~ofproto_v1_0.OFPFW_NW_PROTO
- if self.flow.nw_src != 0:
+ if self.wc.nw_src_mask != 0 and "01" not in bin(self.wc.nw_src_mask):
wildcards &= ~ofproto_v1_0.OFPFW_NW_SRC_MASK
- # maximum size of 32 to prevent changes on other bits
- wildcards |= (self.wc.nw_src_mask % 32) << 8
+ maskbits = (bin(self.wc.nw_src_mask).count("0") - 1)
+ wildcards |= (maskbits << ofproto_v1_0.OFPFW_NW_SRC_SHIFT)
- if self.flow.nw_dst != 0:
+ if self.wc.nw_dst_mask != 0 and "01" not in bin(self.wc.nw_dst_mask):
wildcards &= ~ofproto_v1_0.OFPFW_NW_DST_MASK
- # maximum size of 32 to prevent changes on other bits
- wildcards |= (self.wc.nw_dst_mask % 32) << 14
+ maskbits = (bin(self.wc.nw_dst_mask).count("0") - 1)
+ wildcards |= (maskbits << ofproto_v1_0.OFPFW_NW_DST_SHIFT)
if self.flow.tp_src != 0:
wildcards &= ~ofproto_v1_0.OFPFW_TP_SRC
@@ -353,8 +353,6 @@ class ClsRule(object):
if self.flow.tp_dst != 0:
wildcards &= ~ofproto_v1_0.OFPFW_TP_DST
- #FIXME: add support for arp, icmp, etc
-
return (wildcards, self.flow.in_port, self.flow.dl_src,
self.flow.dl_dst, self.flow.dl_vlan, self.flow.dl_vlan_pcp,
self.flow.dl_type, self.flow.nw_tos & IP_DSCP_MASK,