@@ -1504,6 +1504,45 @@ def append (f, formatter=str):
1504
1504
outstr += append ('tp_dst' )
1505
1505
return outstr
1506
1506
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
1507
1546
1508
1547
class ofp_action_generic (ofp_action_base ):
1509
1548
_MIN_LENGTH = 8
0 commit comments