[Bug 1564077] Re: ipaddr.IPv4Network object miscalculates network addresses
Scott Kitterman
ubuntu at kitterman.com
Wed Nov 23 14:17:39 UTC 2016
Note: ipaddr is no longer developed separately upstream. It was the
basis for the ipaddress module included in python3.3 and later. It
would be useful to see if this issue is present there as well and if it
is, forwarding it python upstream.
--
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to python-ipaddr in Ubuntu.
https://bugs.launchpad.net/bugs/1564077
Title:
ipaddr.IPv4Network object miscalculates network addresses
Status in python-ipaddr package in Ubuntu:
Confirmed
Bug description:
When using the IPv4Network.Supernet() call, the resulting address is
calculated incorrectly. Instead of presenting the all-zeros address in
the host part, the first bit of the host part is kept as it was,
causing an incorrect address to be displayed. This only appears to be
a display issue, the network objects behave as they should (at least
for the equality operator).
The following python program can be used to see the issue.
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
This program takes two addresses and attempts to find the network in
common, using the Supernet call to locate it. However, below is the
output of the program.
$ 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
Note how the program correctly shows the /32 addresses, but when
getting the supernet for the second address, it mistakenly shows
10.53.45.255/31 when the correct value should have been
10.53.45.254/31. The same happens in all the stages, and is very
obvious when doing the computation on a broadcast address. Finally,
the address is constructed with the wrong network address.
As for system data, here goes all the data indicated in the submission
instructions:
$ lsb_release -rd
Description: Ubuntu 14.04.4 LTS
Release: 14.04
$ apt-cache policy python-ipaddr
python-ipaddr:
Installed: 2.1.10-1
Candidate: 2.1.10-1
Version table:
*** 2.1.10-1 0
500 http://ar.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
100 /var/lib/dpkg/status
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: python-ipaddr 2.1.10-1
ProcVersionSignature: Ubuntu 3.19.0-51.58~14.04.1-generic 3.19.8-ckt13
Uname: Linux 3.19.0-51-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.19
Architecture: amd64
CurrentDesktop: XFCE
Date: Wed Mar 30 17:17:20 2016
EcryptfsInUse: Yes
InstallationDate: Installed on 2016-02-29 (29 days ago)
InstallationMedia: Xubuntu 14.04.3 LTS "Trusty Tahr" - Beta amd64 (20150805)
PackageArchitecture: all
SourcePackage: python-ipaddr
UpgradeStatus: No upgrade log present (probably fresh install)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-ipaddr/+bug/1564077/+subscriptions
More information about the Ubuntu-openstack-bugs
mailing list