[Bug 1564077] Re: ipaddr.IPv4Network object miscalculates network addresses
Ernesto Alvarez
ernesto.alvarez at gmail.com
Wed Mar 30 20:52:06 UTC 2016
Looks like the issue can be worked around by calling Supernet() with
prefixlen_diff=0 at the end of the computation. I have the impression
that blanking the host part and shifting the network mask are done in
the wrong order, but I haven't seen the code.
New program:
from sys import argv
import ipaddr
ip1 = ipaddr.IPv4Network(argv[1])
ip2 = ipaddr.IPv4Network(argv[2])
print "Testing ", str(ip1), str(ip2)
while ip1 != ip2:
print ip1,ip2
ip1 = ip1.Supernet()
ip2 = ip2.Supernet()
print "Ending ", ip2
print "Fixed ending ", ip2.Supernet(prefixlen_diff=0)
Results:
$ python ipaddr-bug-test.py 10.53.45.24 10.53.45.255
Testing 10.53.45.24/32 10.53.45.255/32
10.53.45.24/32 10.53.45.255/32
10.53.45.24/31 10.53.45.255/31
10.53.45.24/30 10.53.45.254/30
10.53.45.24/29 10.53.45.252/29
10.53.45.24/28 10.53.45.248/28
10.53.45.16/27 10.53.45.240/27
10.53.45.0/26 10.53.45.224/26
10.53.45.0/25 10.53.45.192/25
Ending 10.53.45.128/24
Fixed ending 10.53.45.0/24
--
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to python-ipaddr in Ubuntu.
https://bugs.launchpad.net/bugs/1564077
Title:
ipaddr.IPv4Network object miscalculates network addresses
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-ipaddr/+bug/1564077/+subscriptions
More information about the Ubuntu-server-bugs
mailing list