Commit graph

415 commits

Author SHA1 Message Date
Mikko Rantanen
040d88dda1
Remove leading :: from paths in doc examples 2019-10-20 21:13:47 +03:00
Tyler Mandry
019b5b5f96
Rollup merge of #64728 - messense:udp-peer-addr, r=dtolnay
Stabilize UdpSocket::peer_addr

Fixes #59127
2019-10-05 21:54:49 -07:00
Lzu Tao
6c1b447f2e Remove unneeded fn main blocks from docs 2019-10-01 11:55:46 +00:00
messense
1de6f74ca4
Update src/libstd/net/udp.rs
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-09-26 09:14:45 +08:00
messense
f1835bc517 Stabilize UdpSocket::peer_addr 2019-09-24 15:10:18 +08:00
Salim Nasser
f5b1b1cdf9 VxWorks ignores the SO_SNDTIMEO socket option (this is long-standing
behavior), so skip the following tests:

net::tcp::tests::timeouts
net::udp::tests::timeouts
2019-08-22 15:26:52 -07:00
Martin Indra
48b6069eaf
Fix typo in src/libstd/net/udp.rs doc comment
Affect is usually used as a verb, effect as a verb.
2019-07-18 21:03:56 +02:00
bors
8b40a188ce Auto merge of #60145 - little-dude:ip2, r=alexcrichton
std::net: Ipv4Addr and Ipv6Addr improvements

Picking this up again from my previous PR: https://github.com/rust-lang/rust/pull/56050
Related to: https://github.com/rust-lang/rust/issues/27709
Fixes: https://github.com/rust-lang/rust/issues/57558

- add `add Ipv4Addr::is_reserved()`
  - [X] implementation
  - [X] tests
- add `Ipv6Addr::is_unicast_link_local_strict()` and update `Ipv6Addr::is_unicast_link_local()` documentation
  - [X] implementation
  - [X] test
- add `Ipv4Addr::is_benchmarking()`
  - [X] implementation
  - [X] test
- add `Ipv4Addr::is_ietf_protocol_assignment()`
  - [X] implementation
  - [X] test
- add `Ipv4Addr::is_shared()`
  - [X] implementation
  - [x] test
- fix `Ipv4Addr:is_global()`
  - [X] implementation
  - [x] test
- [X] refactor the tests for IP properties. This makes the tests more verbose, but using macros have two advantages:
    - it will now be easier to add tests for all the new methods
    - we get clear error messages when a test is failing. For instance:

```
---- net::ip::tests::ip_properties stdout ----
thread '<unnamed>' panicked at 'assertion failed: !ip!("fec0::").is_global()', src/libstd/net/ip.rs:2036:9

```

Whereas previously it was something like

```
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
   left: `true`,
  right: `false`', libstd/net/ip.rs:1948:13
```

-----------------------

# Ongoing discussions:

## Should `Ipv4Addr::is_global()` return `true` or `false` for reserved addresses?

Reserved addresses are addresses that are matched by `Ipv4Addr::is_reserved()`.
@the8472 [pointed out](https://github.com/rust-lang/rust/pull/60145#issuecomment-485458319) that [RFC 4291](https://tools.ietf.org/html/rfc4291#section-2.4) says IPv6 reserved addresses should be considered global:

```
Future specifications may redefine one or more sub-ranges of the
Global Unicast space for other purposes, but unless and until that
happens, implementations must treat all addresses that do not start
with any of the above-listed prefixes as Global Unicast addresses.
```

We could extrapolate that this should also be the case for IPv4. However, it seems that [IANA considers them non global](https://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml) (see [my comment](https://github.com/rust-lang/rust/pull/60145#issuecomment-485713270))

### Final decision

There seems to be a consensus that reserved addresses have a different meaning for IPv4 and IPv6 ([comment1](https://github.com/rust-lang/rust/pull/60145#issuecomment-485963789) [comment2](https://github.com/rust-lang/rust/pull/60145#issuecomment-485944582), so we can consider that RFC4291 does not apply to IPv4, and that reserved IPv4 addresses are _not_ global.

## Should `Ipv6Addr::is_unicast_site_local()` exist?

@pusateri [noted](https://github.com/rust-lang/rust/pull/60145#issuecomment-485507515) that site-local addresses have been deprecated for a while by [RFC 3879](https://tools.ietf.org/html/rfc3879) and new implementations _must not_ support them. However, since this method is stable, removing does not seem possible. This kind of situation is covered by the RFC which stated that existing implementation _may_ continue supporting site-local addresses.

### Final decision

Let's keep this method. It is stable already, and the RFC explicitly states that existing implementation may remain.

---------

Note: I'll be AFK from April 27th to May 11th. Anyone should feel free to pick this up if the PR hasn't been merged by then. Sorry for dragging that for so long already.
2019-06-01 03:46:13 +00:00
Mazdak Farrokhzad
a34dae3587
Rollup merge of #60511 - taiki-e:libstd-intra-doc, r=Dylan-DPC
Fix intra-doc link resolution failure on re-exporting libstd

Currently, re-exporting libstd items as below will [occur a lot of failures](https://gist.github.com/taiki-e/e33e0e8631ef47f65a74a3b69f456366).
```rust
pub use std::*;
```

Until the underlying issue (#56922) fixed, we can fix that so they don't propagate to downstream crates.

Related: https://github.com/rust-lang/rust/pull/56941 (That PR fixed failures that occur when re-exporting from libcore to libstd.)

r? @QuietMisdreavus
2019-05-20 23:02:59 +02:00
Marcel Hellwig
cc314b066a Remove bitrig support from rust 2019-05-13 11:09:06 +02:00
Taiki Endo
ccb9dac5ed Fix intra-doc link resolution failure on re-exporting libstd 2019-05-04 23:48:57 +09:00
Steven Fackler
bd177f3ea3 Stabilized vectored IO
This renames `std::io::IoVec` to `std::io::IoSlice` and
`std::io::IoVecMut` to `std::io::IoSliceMut`, and stabilizes
`std::io::IoSlice`, `std::io::IoSliceMut`,
`std::io::Read::read_vectored`, and `std::io::Write::write_vectored`.

Closes #58452
2019-04-27 08:34:08 -07:00
Corentin Henry
cddb838043 std::net: tests for Ipv4addr::is_shared() 2019-04-23 12:01:41 +02:00
Corentin Henry
fe718ef07f std::net: add warning in Ipv4addr::is_reserved() documentation
See @the8472 comment's on Github:
https://github.com/rust-lang/rust/pull/60145#issuecomment-485424229

> I don't think is_reserved including ranges marked for future use is
> a good idea since those future uses may be realized at at some point
> and then old software with is_reserved filters may have false
> positives. This is not a hypothetical concern, such issues have been
> encountered before when IANA assigned previously reserved /8 address
> blocks.
2019-04-23 10:41:25 +02:00
Corentin Henry
634dcd00b4 std::net: add warning in Ipv6Addr::is_unicast_site_local() doc
site-local addresses are deprecated, so we should warn users about it.
2019-04-23 10:38:26 +02:00
Corentin Henry
66627777b5 std::net: tests for Ipv4addr::is_reserved()
Also add tests to IpAddr for make sure these addresses are not global
or multicast.
2019-04-22 17:54:27 +02:00
Corentin Henry
a2bead8761 std::net: tests for Ipv4addr::is_ietf_protocol_assignment()
Also add tests to IpAddr to make sure these addresses are not global.
2019-04-22 17:41:43 +02:00
Corentin Henry
9dcfd9f58c std::net: tests for Ipv4addr::is_benchmarking()
also add test to Ipaddr, making sure that these addresses are not
global.
2019-04-22 17:41:37 +02:00
Corentin Henry
40d0127a09 std::net: tests for Ipv6addr::is_unicast_link_local{_strict}() 2019-04-22 17:41:32 +02:00
Corentin Henry
99d9bb640f std::net: fix tests for site-local ipv6 addresses
Ipv6Addr::is_unicast_global() now returns `true` for unicast site
local addresses, since they are deprecated.
2019-04-22 16:03:39 +02:00
Corentin Henry
c302d2c78f std::net: fix Ipv4addr::is_global() tests
Ipv4addr::is_global() previously considered 0/8 was global, but has
now been fixed, so these tests needed to be fixed as well.
2019-04-22 16:03:39 +02:00
Corentin Henry
c34bcc658b std::net: use macros to test ip properties 2019-04-22 16:03:39 +02:00
Corentin Henry
8106320009 std::net: fix documentation markdown 2019-04-22 16:03:39 +02:00
Corentin Henry
9f6a747b32 std::net: fix Ipv4Addr::is_global()
As per @therealbstern's comment[0]:

The implementation of Ipv4::is_global is not complete, according to the
IANA IPv4 Special-Purpose Address Registry.

        - It compares the address to 0.0.0.0, but anything in 0.0.0.0/8
          should not be considered global.
                - 0/8 is not global and is currently forbidden because
                  some systems used to treat it as the local network.
                - The implementation of Ipv4::is_unspecified is correct.
                  0.0.0.0 is the unspecified address.
        - It does not examine 100.64.0.0/10, which is "Shared Address
          Space" and not global.
        - Ditto 192.0.0.0/24 (IETF Protocol Assignments), except for
          192.0.0.9/32 and 192.0.0.10/32, which are carved out as
          globally reachable.
        - 198.18.0.0/15 is for "Benchmarking" and should not be globally
          reachable.
        - 240.0.0.0/4 is reserved and not currently reachable
2019-04-22 16:03:39 +02:00
Corentin Henry
67291cc971 std::net: add Ipv4Addr::is_shared() 2019-04-22 16:03:39 +02:00
Corentin Henry
f87b96773b std::net: add Ipv4Addr::is_ietf_protocol_assignment() 2019-04-22 16:03:39 +02:00
Corentin Henry
de3cf0d5eb std::net: add Ipv4Addr::is_benchmarking() 2019-04-22 16:03:39 +02:00
Corentin Henry
8f679977e0 std::net: add Ipv4Addr::is_reserved() 2019-04-22 16:03:32 +02:00
Corentin Henry
aea687c314 std::net: fix doc markdown in Ipv6Addr::is_unique_local() 2019-04-20 11:19:10 +02:00
Corentin Henry
1f0aa4043b std::net: add Ipv6Addr::is_unicast_link_local_strict()
RFC 4291 is a little unclear about what is a unicast link local address.
According to section 2.4, the entire fe80::/10 range is reserved for
these addresses, but section 2.5.3 defines a stricter format for such
addresses.

After a discussion[0] is has been decided to add a different method for
each definition, so this commit:

  - renames is_unicast_link_local() into is_unicast_link_local_strict()
  - relaxed the check in is_unicast_link_local()

[0]: https://github.com/rust-lang/rust/issues/27709#issuecomment-400370706
2019-04-20 11:19:10 +02:00
Corentin Henry
5aea18411e std::net: improve Ipv6Addr::is_unicast_site_local() doc
- quote the RFC
- add a link to the RFC
- fix markdown
2019-04-20 11:19:10 +02:00
Corentin Henry
02d815f3ce std::net: site-local ipv6 prefixes are global 2019-04-20 11:19:10 +02:00
Mazdak Farrokhzad
379c380a60 libstd: deny(elided_lifetimes_in_paths) 2019-03-31 12:56:51 +02:00
bors
54479c624c Auto merge of #59136 - jethrogb:jb/sgx-std-test, r=sanxiyn
SGX target: fix std unit tests

This fixes some tests and some code in the SGX sys implementation to make the `std` unit test suite pass.

#59009 must be merged first.
2019-03-26 01:48:34 +00:00
Jethro Beekman
f229422cc1 SGX target: fix std unit tests 2019-03-25 11:31:19 -07:00
Linus Unnebäck
7e73cd48c4
Fix test names regarding ip version 2019-03-16 11:13:32 +00:00
Linus Unnebäck
7f7cfaee6a
Add test for UdpSocket peer_addr 2019-03-16 11:13:32 +00:00
Linus Unnebäck
24e3fa079c
Document UdpSocket peer_addr NotConnected error 2019-03-16 11:13:32 +00:00
Linus Unnebäck
bf473e3c15
Mark UdpSocket peer_addr unstable w/ tracking issue 2019-03-16 11:13:32 +00:00
Linus Unnebäck
a7bd36c9e8
Add peer_addr function to UdpSocket 2019-03-16 11:13:32 +00:00
Alex Crichton
6465257e54 std: Delete a by-definition spuriously failing test
This commit deletes the `connect_timeout_unbound` test from the standard
library which, unfortunately, is by definition eventually going to be a
spuriously failing test. There's no way to reserve a port as unbound so
we can rely on ecosystem testing for this feature for now.

Closes #52590
2019-03-08 07:41:19 -08:00
Taiki Endo
93b6d9e086 libstd => 2018 2019-02-28 04:06:15 +09:00
bors
fb162e6944 Auto merge of #58357 - sfackler:vectored-io, r=alexcrichton
Add vectored read and write support

This functionality has lived for a while in the tokio ecosystem, where
it can improve performance by minimizing copies.

r? @alexcrichton
2019-02-26 02:48:13 +00:00
kennytm
e3a8f7db47
Rollup merge of #58553 - scottmcm:more-ihle, r=Centril
Use more impl header lifetime elision

Inspired by seeing explicit lifetimes on these two:

- https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator
- https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not

And a follow-up to https://github.com/rust-lang/rust/pull/54687, that started using IHLE in libcore.

Most of the changes in here fall into two big categories:

- Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`)

- Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`)

I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm).

I also removed two lifetimes that turned out to be completely unused; see https://github.com/rust-lang/rust/issues/41960#issuecomment-464557423
2019-02-20 11:59:10 +08:00
kennytm
ef0aaddf69
Rollup merge of #58551 - ssomers:master, r=oli-obk
Explain a panic in test case net::tcp::tests::double_bind

Those who try to build libstd on the Windows Subsystem for Linux experience a single failing test, where the point of failure is an explicit but anonymous panic, as reported in https://github.com/rust-lang/rust/issues/49367
This commit somewhat explains why and allows diagnosing a little.
2019-02-20 11:59:07 +08:00
kennytm
98a6e720d0
Rollup merge of #58392 - scottmcm:less-shifting-in-net-ip, r=oli-obk
Use less explicit shifting in std::net::ip

Now that we have `{to|from}_be_bytes` the code can be simpler.

(Inspired by PR #57740)
2019-02-20 11:58:26 +08:00
Scott McMurray
3bea2ca49d Use more impl header lifetime elision
There are two big categories of changes in here

- Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`)
- Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`)

I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime.
2019-02-17 19:42:36 -08:00
Stein Somers
01bebdf193 Merge remote-tracking branch 'upstream/master' 2019-02-18 00:31:41 +01:00
Stein Somers
0b9ad6e6fd Explain a panic in test case net::tcp::tests::double_bind 2019-02-18 00:13:31 +01:00
Steven Fackler
31bcec648a Add vectored read and write support
This functionality has lived for a while in the tokio ecosystem, where
it can improve performance by minimizing copies.
2019-02-13 19:40:17 -08:00