Commit Graph

1062 Commits (8c43fdd4433a90370b14d4f91e000b9f36b194a5)

Author SHA1 Message Date
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
bors[bot] 494d797602 Merge #561
561: Add lint `#[must_use]` for ring buffer functions r=Dirbaio a=luojia65

This pull request adds `#[must_use]` flag on several ring buffer functions that have side-effects.

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:` f65bc8aa79.

Some test cases and functions are altered due to changes of `#[must_use]`.

Co-authored-by: luojia65 <me@luojia.cc>
2021-11-03 21:43:58 +00:00
bors[bot] 9bc46a00fd Merge #556
556: ci: do not run tests on master push r=Dirbaio a=Dirbaio

bors already tests the *result* of merging PRs into master, and then
pushes the *exact same commit* to master on success, so it's guaranteed
to pass CI. No point in running everything again.

This'll make other CI runs faster, since we have so many jobs that we're
always running against the GHA limit of 10 concurrent jobs.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2021-11-03 21:27:07 +00: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
bors[bot] 5185a105c3 Merge #560
560: IEEE802154: getters for security fields r=Dirbaio a=thibautvdv

This adds getters for the security fields of the IEEE802154 frame. Also added a test for it.

`src/wire/ieee802154.rs` also contained a function for calculating the CRC. However, this is not needed and thus I also remove it in this PR.

Co-authored-by: Thibaut Vandervelden <thvdveld@vub.be>
2021-10-26 16:45:55 +00: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 68c6a85a71 ci: do not run tests on master push
bors already tests the *result* of merging PRs into master, and then
pushes the *exact same commit* to master on success, so it's guaranteed
to pass CI. No point in running everything again.

This'll make other CI runs faster, since we have so many jobs that we're
always running against the GHA limit of 10 concurrent jobs.
2021-10-21 01:53:56 +02:00
bors[bot] 221eaf90f1 Merge #469
469: Add IEEE 802.15.4/6LoWPAN support r=Dirbaio a=thibautvdv

This adds the IEEE 802.15.4 frame representation.
Still a work in progress and interested to know what you think about this.

I really would like to add 6LowPAN as well, however I'm not sure where to put this in smoltcp, since 6LowPAN is kind of weird.

Co-authored-by: Thibaut Vandervelden <thvdveld@vub.be>
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2021-10-20 23:46:48 +00:00
Dario Nieuwenhuis 9990249336 Fix build when setting medium-ieee802154 but not proto-sixlowpan. 2021-10-21 01:42:18 +02:00
Dario Nieuwenhuis 0d664c14b4 Add medium-ieee802154 to CI.
Not adding to `defmt` because it doesn't build yet.
2021-10-21 01:38:19 +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 3b8a0781e5 example/6lowpan: expand readme, do not use monitor interface.
Using a raw socket on `monitor0` causes weird results: packets we receive
include FCS, packets we send are parsed as if they didn't have FCS, except
by wireshark which always expects a FCS??

Turns out the sane way is to use raw sockets on normal `wpanX` interfaces,
in which case all packets we send/receive are without FCS.
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
Dario Nieuwenhuis d66944c4ac Fix wrong matrix bot path 2021-10-20 15:35:32 +02:00
Dario Nieuwenhuis 831ac323cc Merge pull request #554 from smoltcp-rs/matrix-bot
Add matrix bot
2021-10-20 15:33:22 +02:00
Dario Nieuwenhuis daef41bb1c Add matrix bot 2021-10-20 15:25:04 +02:00
bors[bot] a1a48b5f36 Merge #553
553: Fixed typo r=Dirbaio a=mkb2091



Co-authored-by: mkb2091 <mkb2191@protonmail.com>
2021-10-20 00:14:15 +00:00
mkb2091 b3f93117d2 Fixed typo 2021-10-19 22:45:26 +01:00
bors[bot] 3e9ccf53e1 Merge #552
552: tcp: Reply with RST to ACKs with invalid ackno in SYN_SENT. r=Dirbaio a=Dirbaio

Should fix aramperes/onetun#17.

`@aramperes` could you check if this fixes the issue? Thank you!

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2021-10-19 02:05:22 +00: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