Don't iterate through addresses in netaddr.IPNetwork
Currently, to_primitive tries to iterate through all addresses in the
network, because the type doesn't have a special handling that would
short curcuit it, but also has __iter__. This may be detrimental to
performance, up to the point of node crash due to memory exhaustion if
the passed network range is too large (think of 0.0.0.0/0 or even
2001::/64). This behavior also makes it impossible to restore the
original data format (CIDR).
This patch short curcuits the iteration by handling the IPNetwork type
as a special case, same as we do for IPAddress.
Change-Id: I6aecd2d057d282a655ff9e4918c164253142b188
Closes-Bug: #1698355
(cherry picked from commit 38ac21b523f23f802557d94b527821bc84deaa16)
(cherry picked from commit be828c35d84f8f10b07f11aa8bbf195a44e730f8)
Reviewed: https:/ /review. openstack. org/508386 /git.openstack. org/cgit/ openstack/ oslo.serializat ion/commit/ ?id=e85a6706ae8 a0e607e87028110 170daa5043f237
Committed: https:/
Submitter: Jenkins
Branch: stable/newton
commit e85a6706ae8a0e6 07e87028110170d aa5043f237
Author: Ihar Hrachyshka <email address hidden>
Date: Fri Jun 16 11:43:21 2017 -0700
Don't iterate through addresses in netaddr.IPNetwork
Currently, to_primitive tries to iterate through all addresses in the
network, because the type doesn't have a special handling that would
short curcuit it, but also has __iter__. This may be detrimental to
performance, up to the point of node crash due to memory exhaustion if
the passed network range is too large (think of 0.0.0.0/0 or even
2001::/64). This behavior also makes it impossible to restore the
original data format (CIDR).
This patch short curcuits the iteration by handling the IPNetwork type
as a special case, same as we do for IPAddress.
Change-Id: I6aecd2d057d282 a655ff9e4918c16 4253142b188 02557d94b527821 bc84deaa16) 0b07f11aa8bbf19 5a44e730f8)
Closes-Bug: #1698355
(cherry picked from commit 38ac21b523f23f8
(cherry picked from commit be828c35d84f8f1