Skip to content

Exclude 0.0.0.0 from the list of globally routable addresses #31981

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

Merged
merged 3 commits into from
Mar 9, 2016

Conversation

achanda
Copy link
Contributor

@achanda achanda commented Mar 1, 2016

No description provided.

@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

check(&[203, 2, 113, 0], false, false, false, false, true, false, false, false);
check(&[224, 0, 0, 0], false, false, false, false, true, true, false, false);
check(&[239, 255, 255, 255], false, false, false, false, true, true, false, false);
check(&[255, 255, 255, 255], false, false, false, false, false, false, true, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the extra space added here to all columns?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To align with the first row, which expanded one character. If you want, I can leave this as is.

@alexcrichton
Copy link
Member

Could you also provide the rationale for this? When I was checking properties I unfortunately couldn't find a definition to what it meant to be a "global" IP, so if there's an RFC definition we can probably start stabilizing this as well.

@achanda
Copy link
Contributor Author

achanda commented Mar 1, 2016

Global IP is taken to mean a publicly routable IP address. I did a quick search but could not find a RFC that actually defines that. My understanding is that any IP that is not reserved for a private network [1] or some special use [2] is a global IP. It might be a good idea to change the name of the function to is_public.

[1] https://tools.ietf.org/html/rfc1918
[2] https://tools.ietf.org/html/rfc5735

Also https://docs.python.org/3/library/ipaddress.html

@ollie27
Copy link
Member

ollie27 commented Mar 1, 2016

The entire 0.0.0.0/8 isn't global so we should exclude all of it.

@@ -131,7 +131,7 @@ impl Ipv4Addr {
/// - test addresses used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should update this list too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

@alexcrichton
Copy link
Member

If we're copying python in this respect then we should also at least link to the same docs

@achanda
Copy link
Contributor Author

achanda commented Mar 1, 2016

@alexcrichton I added a reference to the the IANA link. Addressed all other comments.

/// network. This property defined by RFC 5735.
pub fn is_this_network(&self) -> bool {
self.octets()[0] == 0
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public API addition without stability annotation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole file has a

 11 #![unstable(feature = "ip", reason = "extra functionality has not been \
 12                                       scrutinized to the level that it should \
 13                                       be stable",
 14             issue = "27709")]

Isn't that enough?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the stability part is fine then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm we're already a little unsure about including these sorts of funcitons at all, so perhaps this can be left out for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcrichton sorry, do you mean I should remove this function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah let's remove it for now.

@achanda
Copy link
Contributor Author

achanda commented Mar 1, 2016

I might just be bikeshedding, but I'm kind of not sure about the name is_this_network. Open to suggestions here.

check(&[239, 255, 255, 255], false, false, false, false, true, true, false, false);
check(&[255, 255, 255, 255], false, false, false, false, false, false, true, false);
// address unspec loopbk privt linloc global multicast brdcast doc this_net
check(&[0, 0, 0, 0], true, false, false, false, false, false, false, false, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the space before the multicast column misaligns it and all of the following.
Wouldn't it be possible to remove a space before the false in the first two rows and avoid changing the whitespace in the remaining part of the table?

@achanda
Copy link
Contributor Author

achanda commented Mar 2, 2016

@alexcrichton please let me know if this needs more work.

@achanda
Copy link
Contributor Author

achanda commented Mar 8, 2016

@alexcrichton does this look good now?

@alexcrichton
Copy link
Member

@bors: r+ a67fd99

Looks good to me, thanks!

@bors
Copy link
Collaborator

bors commented Mar 9, 2016

⌛ Testing commit a67fd99 with merge d289e1a...

bors added a commit that referenced this pull request Mar 9, 2016
Exclude 0.0.0.0 from the list of globally routable addresses
@bors bors merged commit a67fd99 into rust-lang:master Mar 9, 2016
@achanda achanda deleted the unspecified-ip branch March 9, 2016 07:41
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 this pull request may close these issues.

7 participants