You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The subnet() function may loop through 2 ^ N elements, where N <= 128.
The subnet function may be invoked for a IPv6 network such as 2600:1f1c:1b3:8f00::/56, count = None and prefix length /120. It calculates the max number of subnets:
If the network address is /0 and the prefix length is 128, then max_subnets = 2 ^ 128 // 2 ^ 0, which is 2 ^ 128. If the count argument is set to 0, this will cause unbounded CPU usage and memory allocation, netaddr.subnet never returns.
The text was updated successfully, but these errors were encountered:
Hey @sebastien-rosset, thank you for the report. It seems to be me that this is behaving as expected – the generator yields the subnets that are actually requested.
If the count argument is set to 0, this will cause unbounded CPU usage and memory allocation, netaddr.subnet never returns
I failed to reproduce this. subnet() returns immediately, it returns a generator. The generator then can be iterated (the memory use will remain constant unless the client code stores the results somewhere) or discarded after however many iterations the client code desires. See below:
The subnet() function may loop through 2 ^ N elements, where N <= 128.
The
subnet
function may be invoked for a IPv6 network such as2600:1f1c:1b3:8f00::/56
, count = None and prefix length/120
. It calculates the max number of subnets:If the network address is /0 and the prefix length is 128, then max_subnets = 2 ^ 128 // 2 ^ 0, which is 2 ^ 128. If the count argument is set to 0, this will cause unbounded CPU usage and memory allocation, netaddr.subnet never returns.
The text was updated successfully, but these errors were encountered: