Commit Graph

738 Commits (88256dbdcfc3b284f5533e5aa2969bf5061db22a)

Author SHA1 Message Date
Dario Nieuwenhuis 7782b24427 Fix crash in server example due to returning length bigger than received buffer. 2020-04-16 07:39:11 +00:00
nabijaczleweli 41fe0f828a Fix support table in toplevel doc 2020-04-16 07:18:52 +00:00
Gary Guo 18b728ebba Fix packet buffer panic caused by large payload (#332)
When packet buffer's payload buffer does not have enough contiguous
window left, the ring buffer roll over uses an incorrect size
causing the ring buffer pointer not resetting to the head.

When the payload enqueued is larger than 1/2 of the payload ring
buffer, this bug will cause the slice returned by
`PacketBuffer::enqueue` to not match the requested size, and
trigger `debug_assert` in debug profile or size mismatch panic in
`copy_from_slice` when compiled in release profile.
2020-04-14 10:48:31 +02:00
whitequark 34eed33544 Bump version. 2020-01-21 01:13:27 +00:00
Scott Mabin a4198d3a2a s/recieve/receive/ 2020-01-06 09:43:56 +00:00
jhwgh1968 9fc041b32b CI: check for bench breakages
Closes: #321
Approved by: whitequark
2020-01-04 07:33:50 +08:00
Pierre Krieger 9c5f77dd7e Implement Hash for SocketHandle
Closes: #320
Approved by: whitequark
2019-12-23 03:53:53 +08:00
ficapy d01e23e396 Support different types of ioctl request argument 2019-12-15 06:25:43 +00:00
Matt Kelly b7725a4d6b Update recommended version in README 2019-12-10 01:16:30 +00:00
Scott Mabin 39462d24f4 Add suppor for DHCP maximum message size option. 2019-11-07 04:47:36 +00:00
Scott Mabin d7916c9a92 Add capacity methods to all sockets. 2019-11-05 23:07:12 +00:00
Jeremy Andrews bce8d13c7f replace the use of the deprecated item (#314) 2019-11-02 19:11:08 +00:00
Scott Mabin cd48a2ef12 Revert to prevous ordering of TCP options.
Although ordering is not specified in the spec, some implementations expect
some ordering (unforntunately I have found one that does, and blocks outbound
packets due to 'invalid tcp options').
2019-11-01 22:04:19 +00:00
Scott Mabin 287e4f2814 raw_socket: gracefully handle packet truncation errors 2019-10-08 23:55:48 +00:00
Scott Mabin 0edd7d3a13 dhcpv4:
Instead of configuring the ifaces ip address when a dhcp server offers
and ip, we now use the requested_ip option, based on the offered ip
(yiaddr). The user now only has to configure the iface once the dhcp
transaction has completed (Ack'd).
2019-10-06 22:02:40 +01:00
Ruben De Smet eebd8e431a Add ethernet feature-gate as default.
Disable ethernet-related features and framing based on a feature gate.

Add a no-ethernet option to Travis.

notes:
- allow(unused) is added when not using ethernet feature
- Don't run pretty-print doctest, ethernet is optional.

Closes: #308
Approved by: whitequark
2019-10-04 22:49:54 +08:00
Chris Ballance 0df7e51a9f Only use first 3 DHCP advertised DNS servers.
The OPT_DOMAIN_NAME_SERVER DHCP option field can advertise an unbounded
DNS servers, but we currently use a fixed length array to store these
servers. This commit ensures only the first 3 (highest priority) servers
are used.

Fixes #305.
2019-09-30 17:19:05 +00:00
Richard Meadows 186bc05d77 Allow TCPSockets in a SocketSet without 'static storage lifetime
`TCPSocket` buffers are type `RingBuffer<'a, _>` whilst other
socket types have buffers with type `PacketBuffer<'a, 'b,
_>`.

There is an enum over socket types `pub enum Socket<'a, 'b: 'a>`,
 which is in turn used by `set::Item` and `SocketSet`. The lifetime
 `'b` is not required for `TcpSocket`, but the `Into<Socket>`
 implementation for `TCPSocket` specifies the `'static` lifetime for
 `'b`.

Therefore using `TCPSocket` in a `SocketSet` currently requires the
lifetime `'b` for other sockets to be `'static` which is unnecessarily
restrictive. This patch fixes this.

The lifetime signature of socket specifies `'b: 'a`, that is `'b`
outlives `'a`. Instead of `'static`, this is also satisfied by
`impl<'a> Into<Socket<'a, 'a>> for TcpSocket<'a>` as `'a` "outlives"
`'a` by definition.

The example
[here](https://gist.github.com/richardeoin/b562e79d0d499e00a8bf4944f00594d9)
fails to compile without this patch.

Closes: #304
Approved by: whitequark
2019-08-15 08:31:48 +08:00
Andreas Molzer 8e1fa540c3 Restore Session::finish call in socket ref
Using move semantics allows an Option to keep track of the
initialization state while satisfying the borrow checker. This replaces
the functionality that the 'consumed' flag had before. It also retains
the smaller object size since the Option of a reference can use the
representation of the null pointer, which is an invalid reference, as a
niche for the None variant.

Closes: #301
Approved by: whitequark
2019-07-23 20:13:07 +08:00
whitequark 10e251b0aa Bump log dependency to version 0.4.4. NFC.
Since 0.4.4, log uses #[macro_export(local_inner_macros)], which is
the right thing to do, but it breaks our CI because of a now-unused
\#[macro_use(log)].
2019-07-23 12:10:38 +00:00
whitequark 2902ca00c0 Fix potential unsoundness in SocketRef::into_inner()/drop().
This didn't ever actually cause UB because the drop implementation
should have compiled to a no-op under all conditions; `finish` is
a part of a patchset that never got in. (Even if it didn't, the code
should have been dynamically sound, under all but the most strict
interpretations of Rust's aliasing requirements.)

But it's still a problem, at least because there is a warning for
this potential unsoundness that will become an error in the future.
So everything else aside, we can't use this pattern going forward.

For now, remove the Drop impl, exploiting the fact that `finish`
is a no-op. Going forward this will likely require unsafe code, or
some fundamental change in the way SocketRef is implemented, but
I could not come up with any way to do it. :(
2019-06-22 10:52:39 +00:00
whitequark b5d5023ac6 Bump Rust version requirement to 1.28.
Actually, this is not a new requirement at all; because we do not
check the minimum version on CI, some dependencies on 1.28 have
already sneaked in. In particular, our required version of the crate
managed only works on 1.28+.

This allows us to use:
(1.28)
  - ops::RangeBounds
  - num::NonZero

Some trait bounds were added to make sure everything builds on 1.28.
2019-06-22 09:04:45 +00:00
whitequark 563434997c Fix spurious crash in commit bd3912e5. 2019-06-22 09:04:30 +00:00
whitequark be7750486f Bump log dependency to version 0.4. NFC.
This doesn't affect downstream code because log 0.3.9 is a facade
crate implemented in terms of log 0.4, and so log 0.3 and log 0.4
APIs can be used together.
2019-06-22 08:31:11 +00:00
whitequark 04d1430fc9 Fix unused mut in examples/ping.rs. NFC. 2019-06-22 08:20:41 +00:00
whitequark 0134bb7399 Bump Rust version requirement to 1.27.
This allows us to use:
(1.26)
  - impl Trait
  - autoderef in pattern matching
  - fixed slice patterns
  - inclusive ranges
(1.27)
  - dyn Trait
  - #[must_use] on functions

To prepare for edition change, dyn is added where applicable. Other
edition changes would require bumping the requirement even higher,
and so they are not applied for now.
2019-06-22 08:19:39 +00:00
whitequark 59f76f1868 Fix docstring for SocketRef::into_inner(). NFC. 2019-06-22 07:49:27 +00:00
whitequark f32522bef7 Fix docstrings for TcpSocket::{send,recv}_slice(). NFC. 2019-06-22 07:49:24 +00:00
whitequark de309d744d Travis: turn off notifications.
These are handled via webhooks now.
2019-06-22 07:14:56 +00:00
whitequark 4e77a29c91 Clarify TcpSocket::recv_queue() semantics. NFC. 2019-06-22 07:03:15 +00:00
whitequark efdf3a2fb3 Fix typo in docstring. NFC. 2019-06-22 06:50:58 +00:00
David Wood 67653fbf38 Pad output of `Display` on `Instant`
Zero-pad the milliseconds part of a displayed `Instant` to include
three leading zeros.
Closes: #297
Approved by: whitequark
2019-05-28 06:25:37 +08:00
jhwgh1968 4f4b209103 Add TCP header fuzzer
Closes: #284
Approved by: whitequark
2019-05-19 06:41:07 +08:00
jhwgh1968 1bdf155ead Implement Fuzz Injector
Closes: #284
Approved by: whitequark
2019-05-19 06:41:07 +08:00
Astro 49f638e2d2 Implement DHCPv4 client + example.
Closes: #186
Approved by: whitequark
2019-05-14 00:37:43 +08:00
Astro 69bc2de64c process_ipv4(): stub handled_by_raw_socket in absence of feature="socket-raw"
Closes: #295
Approved by: whitequark
2019-05-09 03:45:07 +08:00
Astro 1276234e98 Partially revert "Suppress ICMP error replies […]", still allow reception by other sockets.
This reverts commit f56666a26722c4f4f962937119d71792b51c396e.

Adds another test case.

Closes: #295
Approved by: whitequark
2019-05-09 03:45:07 +08:00
jhwgh1968 9f2febcaea Allow mutation of data buffer in RxToken
Closes: #294
Approved by: whitequark
2019-05-05 03:48:25 +08:00
Astro a009e0ad9d Suppress ICMP error replies for packets that are accepted by raw sockets.
Closes: #293
Approved by: whitequark
2019-05-01 10:22:52 +08:00
Astro ebf449340b test_icmp_reply_size: fix for ipv4-only case
Closes: #292
Approved by: whitequark
2019-05-01 10:11:50 +08:00
Andreas Molzer 4172ce1301 Implement accessors for the Tracer
This makes the `Tracer` wrapper for a phy device close to a drop-in
replacement for the encapsulated device.

Closes: #289
Approved by: whitequark
2019-04-26 20:30:20 +08:00
Andreas Molzer 8c3bdf907b Allow access to phy-device in ethernet
Adds accessor functions to the device implementing the phy::Device trait
within an ethernet interface. The intent is to allow access to read-only
methods such as gathering of device statistics or other diagnostics
while the interface is running. The interface does not hold any internal
invariants on the device, so that a mutable accessor can be added as
well.

Closes: #289
Approved by: whitequark
2019-04-26 20:30:20 +08:00
Andreas Molzer b27cbad6f4 Fix omission of udp checksum
Allow the control flow to continue when udp parsing encounters an
invalid checksum within an ipv4 packet, instead of returning with an
error. Additionally adds a test to ensure the correct behaviour.

Closes: #280

Closes: #290
Approved by: whitequark
2019-04-26 20:14:01 +08:00
Andreas Molzer c9fbd56977 Remove an unused mut qualifier on a variable
Fixes a denied lint uncovered on a recent nightly compiler version,
apparently through improved analysis. The code in question is only
compiled with the proto-ipv6 feature and older compiler versions did not
detect the unused qualifier, sometime around 2019-04-23.

Closes: #291
Approved by: whitequark
2019-04-26 20:01:48 +08:00
Adam Greig 59f5cbbe64 Fix IPv4 broadcast handling
A regression meant broadcast IPv4 packets were ignored. Restore
handling those packets and also reply to broadcast ICMPv4 echo requests.

Closes #287.

Closes: #288
Approved by: whitequark
2019-04-15 01:57:17 +08:00
Andreas Molzer d9e0c8246c Add ip version specific addr/endpoint converters
Converting from `::std::net::*` types to the ip related library structs
previously required both ip-version features to be enabled. This
introduced dedicated converters from the ip-version specific standard
address and endpoint representations (`IpV4Addr`, `IpV6Addr`,
`SocketAddrV4`, and `SocketAddrV6`) that are enabled without requiring
the other ip-version feature to be selected.

Closes: #286
Approved by: whitequark
2019-04-13 14:31:55 +08:00
Kornel 55d1e9c997 Update Cargo.toml
Add a second category that's specifically for TCP
2019-03-30 19:45:29 +00:00
Chris Branch 8ef6637b0b Implement Any-IP feature
Any-IP is the capability to accept packets locally even when the
destination address is not configured on any interface. This lets
a service bind to an entire subnet of addresses and is particularly
useful in anycast deployments.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4465b469008bc03b98a1b8df4e9ae501b6c69d4b
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ab79ad14a2d51e95f0ac3cef7cd116a57089ba82

This feature is not available for IPv6 as it would be a nop: the current
IPv6 handler doesn't filter packets by the interface's IP address(es).

Closes: #276
Approved by: whitequark
2019-03-19 05:47:29 +08:00
Kai Lüke 49e985a66e Implement peek functions for UDP sockets
This needed a peek function for the packet buffer.

Closes: #278
Approved by: whitequark
2019-02-28 00:58:33 +08:00
Kai Lüke 2ac9c77d18 Document that Packetization Layer Path MTU Discovery in TCP is not supported
PLPMTU should be used if ICMP messages are dropped by the network.

Closes: #277
Approved by: whitequark
2019-02-27 00:29:01 +08:00