Skip to content
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

Zero prefix considered invalid for IPv6 #38

Open
ioprev opened this issue May 27, 2014 · 12 comments
Open

Zero prefix considered invalid for IPv6 #38

ioprev opened this issue May 27, 2014 · 12 comments

Comments

@ioprev
Copy link

ioprev commented May 27, 2014

When trying to create an IPAddress object for the IPv6 address ::/0 the following error occur:
ArgumentError: Prefix must be in range 1..128, got: 0

This is a result of a check done at line 217 of ipaddress/prefix.rb file.

The address ::/0 is a special case of an IPv6 address and should be considered a valid IPv6 address representation. See: http://en.wikipedia.org/wiki/IPv6_address#Default_route

@crosson
Copy link

crosson commented May 27, 2014

That is a valid route entry. Is it a valid ip address? In the case of ipv4 it isn't.

@crosson
Copy link

crosson commented May 27, 2014

Huh. On the flip side Prefix32 does not appear to be consistent Prefix128 since it does allow the 0.

@bluemonk
Copy link
Collaborator

Good point.
I think I will enable the /0 on Prefix128 since I could not find anything on the RFC's that says otherwise.
Also, it's handy to be able to deal with these special addresses - despite the fact that they're not valid in the sense that they can't be assigned to an interface.

@ioprev
Copy link
Author

ioprev commented Jun 27, 2014

Sure, its pretty useful when handling route addresses. Thank you.

@msimkins
Copy link

msimkins commented Jul 4, 2014

As an address it would be ::/128 - and that is defined as the 'Unspecified Address'

@ioprev
Copy link
Author

ioprev commented Jul 5, 2014

That's correct. ::/128 is indeed the unspecified address. The ::/0 address is used as the default unicast route address. See section 2.11 of RFC 5156.

@msimkins
Copy link

msimkins commented Jul 5, 2014

I agree with the statement, but is is an 'Address', as it cannot be assigned to / configured on an interface.

It probably makes no difference, and maybe should be included for completeness.

@jjmanzer
Copy link

I would like to poke this bug and get some attention to it (if it has not been fixed already). I have a Cisco config snippit like this....

1090   ip route 0.0.0.0/0 10.30.131.254
1091   ipv6 route 0::/0 xxxx:xxxx:xx:x::1

Now I understand how that looks weird but when a big vendor uses /0 on an IP (4 or 6) one might as well consider it a standard. Can we get this fixed?

@francisluong
Copy link
Contributor

@jjmanzer: I can take a look at this. Can you help me understand more about what the use case is for supporting this? There are operations that IPAddress does that will make no sense whatsoever on a 0 address... e.g. hosts, broadcast, etc...

What are the functions we are interested in? netmask?

@bluemonk
Copy link
Collaborator

Sorry, my bad. I said I would have taken care of it but it completely
slipped my mind. I'll give it a spin this weekend. @jjmanzer would you mind
writing a couple of tests just to make sure the bug fix meets your needs?
That'll be extremely helpful.

@francisluong I'll need your precious help to review my rusty ruby before
we release :)
On Jun 28, 2016 17:14, "Francis Luong (Franco)" [email protected]
wrote:

@jjmanzer https://github.com/jjmanzer: I can take a look at this. Can
you help me understand more about what the use case is for supporting this?
There are operations that IPAddress does that will make no sense whatsoever
on a 0 address... e.g. hosts, broadcast, etc...

What are the functions we are interested in? netmask?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#38 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAFW7SmmqxFoqE4CJGisDPdyj2dsmDWrks5qQToygaJpZM4B-i-B
.

@francisluong
Copy link
Contributor

@bluemonk I'm in!

@jjmanzer
Copy link

jjmanzer commented Jun 28, 2016

So a quick reason on why you would see this use case is that 0.0.0.0/0 and 0::/0 are used to say 'match every possible route'. You would not see this kind of IP bound to a network interface but instead see it elsewhere in a device's running config somewhere near the routing directives.

So not every call to the ipaddress gem is for an actual host IP, sometimes it is for less common things like this.

For example, we could have a filter that allows any route that is /32 only.
ip prefix-list TEST seq 10 permit 0.0.0.0/0 ge 32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants