Commit Graph

837 Commits (master)

Author SHA1 Message Date
Emil Fresk 089443674b Support defmt version 0.3 with new MSRV 2021-11-16 08:32:27 +01:00
Emil Fresk 8a8d2cc6ef Expose `self.sockets` in `Interface` via iterators
This is needed to not loose access to methods on sockets, e.g. iterating
over them and closing or checking which ports are being used.
2021-11-14 13:58:23 +01:00
Thibaut Vandervelden a9925b5957 Add fuzz tests for 6LoWPAN_IPHC and 6LoWPAN_UDP
Adding fuzz tests for 6LoWPAN_IPHC and 6LoWPAN_UDP.
Some bugs were found.

Ran for 10 minutes.
2021-11-05 10:05:12 +01:00
Thibaut Vandervelden 76f1b81182 Add fuzzing for IEEE802.15.4
Because IEEE802.15.4 uses a lot of compression in its frame, fuzzing it
is maybe a good idea. Adding this fuzz target showed that some frame
methods were panicking. `check_len` now checks if accessors will panic
or not.

I ran the fuzzer for about 15 minutes and nothing showed up.
2021-11-04 12:01:03 +01:00
Dario Nieuwenhuis eda4af4e68 Fix clippys 2021-11-03 23:38:23 +01:00
Dario Nieuwenhuis a6b3b64c78 socket/set: remove reference counting.
It is never used in practice, so it's not worth the complexity
and the extra RAM usage.
2021-11-03 23:32:32 +01:00
Dario Nieuwenhuis 8c43fdd443 Remove braces that were previously needed to workaround SocketRef borrow issues. 2021-11-03 23:32:32 +01:00
Dario Nieuwenhuis f8cc1eacbe socket: remove SocketRef.
The intent was to run custom code after the user is done modifying the socket,
for example to update a (not yet existing) port->socket map in SocketSet. However
this wouldn't work, since the SocketRef would have to borrow the SocketSet at
the same time as the Socket to be able to notify the SocketSet.

I believe such indexing can be achieved by setting a "dirty" bit *before* giving
the socket to the user, then on poll() reindexing all dirty sockets. This could
even be faster: if user gets a socket multiple times between polls, it'd be reindexed
only once.
2021-11-03 23:32:32 +01:00
Dario Nieuwenhuis c08dd8dcf6 iface: own the SocketSet instead of borrowing it 2021-11-03 23:32:32 +01:00
Dario Nieuwenhuis b1d6104a74 socket/dhcpv4: return owned Config in Event. 2021-11-03 23:25:53 +01:00
bors[bot] 214a13bca6 Merge #564
564: arp: flush neighbor cache after IP update r=Dirbaio a=deantvv

Related to #543

Co-authored-by: Dean Li <deantvv@gmail.com>
2021-11-03 22:19:19 +00:00
bors[bot] 9d0372454a Merge #562
562: fuzz: DHCP header parser r=Dirbaio a=alexandrasandulescu

Hi. This fuzz target tests the [DHCPRepr](https://docs.rs/smoltcp/0.7.5/smoltcp/wire/struct.DhcpRepr.html) `parse` and `emit` functions ([context](https://github.com/smoltcp-rs/smoltcp/issues/305#issuecomment-530327153)).
The fuzz target requires a small change in the `DHCPOption` parser because the option type `OPT_DOMAIN_NAME_SERVER ` requires the payload representing the DNS server list to have a length multiple of 4. Otherwise the `chunks` call places the remainder in the last chunk (length < 4). This panics when the last chunk is parsed into an `IPv4Address`. Do you have a better suggestion for handling this situation?

I ran the fuzzer for a couple of days but it didn't find any crash yet. To increase the chances, I used the oss-fuzz seed corpora of `dnsmasq` DHCP fuzzer and `systemd` DHCP server fuzzer.
Please share if you have suggestions on how to improve coverage.

Co-authored-by: Alexandra Sandulescu <aesa@google.com>
2021-11-03 22:11:56 +00:00
bors[bot] 2c304b4e8b Merge #563
563: Print log to stdout in test r=Dirbaio a=deantvv

Use simple [trick](https://github.com/rust-lang/log/issues/106) to allow print log to stdout in test

Co-authored-by: Dean Li <deantvv@gmail.com>
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2021-11-03 22:02:06 +00:00
Dario Nieuwenhuis 565da5ab33 Remove manual `log::set_logger` from tests.
No longer needed since `net_debug!` and `net_trace!` now call `println!` directly
when testing!
2021-11-03 23:00:26 +01:00
Dean Li 1ce91fc206 arp: flush neighbor cache after IP update
Related to #543
2021-10-31 11:42:18 +08:00
Dean Li 40a4a7dd2e show log in testing 2021-10-30 23:51:23 +08:00
Alexandra Sandulescu d14d238422 fuzz: DHCP header parser 2021-10-28 10:37:57 +02:00
luojia65 c111bee3b6 Code format using `cargo fmt` 2021-10-27 16:35:05 +08:00
luojia65 a714def8d0 Add lint `#[must_use]` for ring buffer functions.
This lint is in stable Rust now: https://github.com/rust-lang/rust/issues/43302.
These changes are noted according to code comment from @whitequark.
Some test cases and functions are altered due to changes of #[must_use].
2021-10-27 16:26:57 +08:00
Thibaut Vandervelden e9ec0aefa8 ieee802154: add getters for security features 2021-10-26 16:58:45 +02:00
Thibaut Vandervelden 6a08f958b2 ieee802154: remove unused CRC 2021-10-26 16:16:24 +02:00
Dario Nieuwenhuis 8922895a8b Fix some comments. 2021-10-21 01:31:15 +02:00
Thibaut Vandervelden 19d9cd46ca ieee802154: log when we drop a frame 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden be14fbb2a6 ieee802154: update documentation 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden ce9145dd62 ieee802154: Correct filtering of PAN id 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 91d73273d8 ieee802154: ignore frames with types other than Data 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden ecc45dbeef Remove IpRepr::Sixlowpan 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 4b9d39706c Set flags to zero, because buffer could be reused. 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden bff2330309 Remove some more todos 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 061fcf880f Defmt for RawHardwareAddress 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 6e63433ab3 Set HardwareAddress behind feature flag
When there is no medium in the feature flags, then there is no
HardwareAddress.
2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 80ba5a2e2d Send ICMP unreachable when no UDP socket is found 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden b068a856e5 Use `net_debug` and drop instead of `todo!` 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 1154390307 Use one PAN ID for source and destination
Also check for the correct destination PAN id when receiving a frame (as
discussed). Linux does this as well.
However, hardware implementations also can drop those packets.
2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis 36a0e9b2f3 phy: Use right protocol on RawSocket based on the medium. 2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis 7c35a061a4 ieee80154: process packets without the FCS.
We assume the FCS is checked by lower layers or by hardware.

- Makes it consistent with Ethernet mediums, where we don't handle the FCS either.
- Linux ieee802154 raw sockets send/receive packets without the FCS.
2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis c9712939fb 6lowpan: do not fill neighbor cache from random packets
Equivalent of 6210612be047ee706ac729015cdbc2581e6ae9a3 for 6lowpan
2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis a0b9fb6ebc ipv6: fix Solicited Node address calculation 2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis 3269ce6124 wire: remove HardwareAddress::BROADCAST 2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis b4764e4973 Add RawHardwareAddress, use it in wire ndisc.
This avoids wire needing to know what medium we're on.
2021-10-21 01:25:13 +02:00
Thibaut Vandervelden fb2d0029d8 Add support for 802.15.4 and 6LoWPAN 2021-10-21 01:25:12 +02:00
mkb2091 b3f93117d2 Fixed typo 2021-10-19 22:45:26 +01:00
Dario Nieuwenhuis 3baa13372c tcp: Reply with RST to ACKs with invalid ackno in SYN_SENT.
Should fix aramperes/onetun#17
2021-10-19 03:38:44 +02:00
Marc-André Lureau aa10b5250a wire: add From<Address> for ::std::net::IpAddr
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-19 02:27:49 +02:00
Dario Nieuwenhuis 48debf7db8 dhcp: add "ignore NAKs" option.
This workarounds a known broken Vodafone Fiber router which replies
with both NAK and ACK:

![screenshot-2021-10-19_01-18-41](https://user-images.githubusercontent.com/1247578/137819133-a8f9ab28-8bc5-4cca-9c91-2eac15d88070.png)
2021-10-19 01:17:28 +02:00
Dario Nieuwenhuis bcf6211fbe socket/dhcp: add nak tests 2021-10-15 01:02:31 +02:00
Dario Nieuwenhuis a43a6772c9 socket/dhcp: add retransmission/timeout tests 2021-10-15 00:43:21 +02:00
Dario Nieuwenhuis 6768d89165 socket/dhcp: add renew test 2021-10-14 23:33:25 +02:00
Dario Nieuwenhuis 94541ae827 socket/dhcp: add basic test 2021-10-14 23:19:30 +02:00
Dario Nieuwenhuis 3b7100c501 socket/dhcp: log incoming reprs as well as outgoing. 2021-10-14 19:41:10 +02:00