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>
This commit is contained in:
blacksheeep 2013-04-08 15:17:35 +02:00 committed by FUJITA Tomonori
parent 7a4a384fb7
commit 1e9c9c38f4

View File

@ -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,