Ema has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/356611 )

Change subject: Fix IPPrefix value comparisons with different packed paddings
......................................................................


Fix IPPrefix value comparisons with different packed paddings

self.prefix is optionally padded up to the maximum length, so
this needs to be taken into account when comparing.

Change-Id: I7c7a7f052b1ab370ec797850e8b1a0090b93ece4
---
M pybal/bgp/ip.py
1 file changed, 6 insertions(+), 1 deletion(-)

Approvals:
  Ema: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pybal/bgp/ip.py b/pybal/bgp/ip.py
index a9f207e..0d78475 100644
--- a/pybal/bgp/ip.py
+++ b/pybal/bgp/ip.py
@@ -90,7 +90,9 @@
 
     def __eq__(self, other):
         # FIXME: masked ips
-        return isinstance(other, IPPrefix) and self.prefixlen == 
other.prefixlen and self.prefix == other.prefix
+        return (isinstance(other, IPPrefix)
+            and self.prefixlen == other.prefixlen
+            and self.packed(pad=True) == other.packed(pad=True))
 
     def __ne__(self, other):
         return not self.__eq__(other)
@@ -118,6 +120,9 @@
     def _packedMaxLen(self):
         return (self.addressfamily == AFI_INET6 and 16 or 4)
 
+    def _packedMinLen(self):
+        return -(-self.prefixlen // 8)
+
     def ipToInt(self):
         return reduce(lambda x, y: x * 256 + y, map(ord, self.prefix))
 

-- 
To view, visit https://gerrit.wikimedia.org/r/356611
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7c7a7f052b1ab370ec797850e8b1a0090b93ece4
Gerrit-PatchSet: 5
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Mark Bergsma <m...@wikimedia.org>
Gerrit-Reviewer: Ema <e...@wikimedia.org>
Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@wikimedia.org>
Gerrit-Reviewer: Volans <rcocci...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to