Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cidr_to_range function #168
base: master
Are you sure you want to change the base?
Add cidr_to_range function #168
Changes from all commits
5537255
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sincerely hope no one calls this with a
/8
...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure that's much worse than the standard
/64
IPv6 address range…There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, IPv4 /8 is
2**24
while IPv6 /64 is2**64
. Every IPv4 address is 32 bits.32 bits * 2**24 = 67 MB
(assuming optimal storage, which it isn't). For IPv6 it's128 bits * 2**64 = 256 EiB
. If my math is correct, you really don't want to do this for IPv6.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this can be slow and memory consuming for huge IPv6 networks like a /64 (or larger). Why would you want this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, depending on the subnet size it might take some time.
I know at least one person that uses https://github.com/Yelp/puppet-netstdlib and I require those functions as well. Yelp abandoned the module and I had the impression it's a good idea to add them to extlib. I thought for a hand full of short functions it doesnt make much sense to maintain a whole module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this used for? eespecially in the case of IPv6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, not sure why you would want to enumerate every address of a subnet (you're definitely not doing this for most IPv6 networks), but I think it would be more useful to have a function that gets one of the addresses in a subnet as I mentioned here: #165 (comment)
You could have a loop around such a function if you really wanted to do something with every address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would make sense if we returned lazy structures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only really true for IPv4, not IPv6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I can follow. I tested this locally and also wrote a test that passes for IPv6. This works for IPv4 and IPv6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Popping the last address isn't really needed AFAIK because IPv6 doesn't have a broadcast address. I think the same is true for shifting due to a network address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first address in an IPv6 subnet is reserved as the subnet router anycast address: https://tools.ietf.org/html/rfc4291#section-2.6.1
But the last address in a subnet is usable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always like to use example IP ranges. In https://community.theforeman.org/t/using-ips-and-domains-in-tests-documentation/16600 I keep a list of references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed this is not correct for IPv6, the last address
fe80::5054:ff:fe47:4a37
is usable.