Skip to content

Commit c9b29f3

Browse files
committed
Issue noxrepo#142: Correct overlap checking for flow mods
1 parent 3d8eac7 commit c9b29f3

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Diff for: pox/openflow/libopenflow_01.py

+39
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,45 @@ def append (f, formatter=str):
15041504
outstr += append('tp_dst')
15051505
return outstr
15061506

1507+
def check_overlap(self, other):
1508+
1509+
def overlap_fail(mine, other):
1510+
return (mine is not None and other is not None) and (mine != other)
1511+
1512+
def overlap_fail_nw(self_nw, other_nw):
1513+
self_addr = self_nw[0]
1514+
self_netbits = self_nw[1]
1515+
1516+
other_addr = other_nw[0]
1517+
other_netbits = other_nw[1]
1518+
1519+
if self_addr is not None and other_addr is not None:
1520+
netmask_bits = 32 - min(self_netbits, other_netbits)
1521+
self_msbs = (self_addr.toUnsigned() >> netmask_bits)
1522+
other_msbs = (other_addr.toUnsigned() >> netmask_bits)
1523+
1524+
if self_msbs != other_msbs:
1525+
return True
1526+
return False
1527+
1528+
# regular fields
1529+
if overlap_fail(self.in_port, other.in_port): return False
1530+
if overlap_fail(self.dl_vlan, other.dl_vlan): return False
1531+
if overlap_fail(self.dl_src, other.dl_src): return False
1532+
if overlap_fail(self.dl_dst, other.dl_dst): return False
1533+
if overlap_fail(self.dl_type, other.dl_type): return False
1534+
if overlap_fail(self.nw_proto, other.nw_proto): return False
1535+
if overlap_fail(self.tp_src, other.tp_src): return False
1536+
if overlap_fail(self.tp_dst, other.tp_dst): return False
1537+
if overlap_fail(self.dl_vlan_pcp, other.dl_vlan_pcp): return False
1538+
if overlap_fail(self.nw_tos, other.nw_tos): return False
1539+
1540+
1541+
if overlap_fail_nw(self.get_nw_dst(), other.get_nw_dst()):
1542+
return False
1543+
if overlap_fail_nw(self.get_nw_src(), other.get_nw_src()):
1544+
return False
1545+
return True
15071546

15081547
class ofp_action_generic (ofp_action_base):
15091548
_MIN_LENGTH = 8

0 commit comments

Comments
 (0)