Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/smoltcp-rs/smoltcp into fix…
Browse files Browse the repository at this point in the history
…/mismatching-src-ip
  • Loading branch information
MathiasKoch committed Sep 24, 2024
2 parents 8d6bdde + a2b92ed commit 1c89f9e
Show file tree
Hide file tree
Showing 40 changed files with 993 additions and 675 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
coverage:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install `cargo llvm-cov`
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run Coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
env:
RUSTUP_TOOLCHAIN: nightly
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install cargo-fuzz
run: cargo install cargo-fuzz
- name: Fuzz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rustfmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Check fmt
run: cargo fmt -- --check
31 changes: 12 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,43 @@ jobs:
check-msrv:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run Checks MSRV
run: ./ci.sh check msrv

test-msrv:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run Tests MSRV
run: ./ci.sh test msrv

clippy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run Clippy
run: ./ci.sh clippy

test-stable:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run Tests stable
run: ./ci.sh test stable

test-nightly:
runs-on: ubuntu-22.04
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run Tests nightly
run: ./ci.sh test nightly

#check-stable:
#runs-on: ubuntu-22.04
#steps:
#- uses: actions/checkout@v2
#- name: Run Tests
#run: ./ci.sh check stable

#check-nightly:
#runs-on: ubuntu-22.04
#continue-on-error: true
#steps:
#- uses: actions/checkout@v2
#- name: Run Tests
#run: ./ci.sh check nightly
test-build-16bit:
runs-on: ubuntu-22.04
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Build for target with 16 bit pointer
run: ./ci.sh build_16bit
16 changes: 10 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ license = "0BSD"
# ensure that the correct features are enabled.
autoexamples = false

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }

[dependencies]
managed = { version = "0.8", default-features = false, features = ["map"] }
byteorder = { version = "1.0", default-features = false }
Expand Down Expand Up @@ -47,7 +50,6 @@ defmt = ["dep:defmt", "heapless/defmt-03"]

"proto-ipv4" = []
"proto-ipv4-fragmentation" = ["proto-ipv4", "_proto-fragmentation"]
"proto-igmp" = ["proto-ipv4"]
"proto-dhcpv4" = ["proto-ipv4"]
"proto-ipv6" = []
"proto-ipv6-hbh" = ["proto-ipv6"]
Expand All @@ -61,6 +63,8 @@ defmt = ["dep:defmt", "heapless/defmt-03"]
"proto-ipsec-ah" = []
"proto-ipsec-esp" = []

"multicast" = []

"socket" = []
"socket-raw" = ["socket"]
"socket-udp" = ["socket"]
Expand Down Expand Up @@ -93,10 +97,10 @@ default = [
"std", "log", # needed for `cargo test --no-default-features --features default` :/
"medium-ethernet", "medium-ip", "medium-ieee802154",
"phy-raw_socket", "phy-tuntap_interface",
"proto-ipv4", "proto-igmp", "proto-dhcpv4", "proto-ipv6", "proto-dns",
"proto-ipv4", "proto-dhcpv4", "proto-ipv6", "proto-dns",
"proto-ipv4-fragmentation", "proto-sixlowpan-fragmentation",
"socket-raw", "socket-icmp", "socket-udp", "socket-tcp", "socket-dhcpv4", "socket-dns", "socket-mdns",
"packetmeta-id", "async"
"packetmeta-id", "async", "multicast"
]

# Private features
Expand Down Expand Up @@ -151,11 +155,11 @@ iface-max-sixlowpan-address-context-count-1024 = []
iface-neighbor-cache-count-1 = []
iface-neighbor-cache-count-2 = []
iface-neighbor-cache-count-3 = []
iface-neighbor-cache-count-4 = [] # Default
iface-neighbor-cache-count-4 = []
iface-neighbor-cache-count-5 = []
iface-neighbor-cache-count-6 = []
iface-neighbor-cache-count-7 = []
iface-neighbor-cache-count-8 = []
iface-neighbor-cache-count-8 = [] # Default
iface-neighbor-cache-count-16 = []
iface-neighbor-cache-count-32 = []
iface-neighbor-cache-count-64 = []
Expand Down Expand Up @@ -298,7 +302,7 @@ required-features = ["std", "log", "medium-ethernet", "proto-ipv4", "socket-tcp"

[[example]]
name = "multicast"
required-features = ["std", "medium-ethernet", "medium-ip", "phy-tuntap_interface", "proto-ipv4", "proto-igmp", "socket-udp"]
required-features = ["std", "medium-ethernet", "medium-ip", "phy-tuntap_interface", "proto-ipv4", "multicast", "socket-udp"]

[[example]]
name = "multicast6"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-0BSD.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2016 [email protected]
Copyright (C) smoltcp contributors

Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted.
Expand Down
1 change: 1 addition & 0 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod wire {
sack_permitted: false,
sack_ranges: [None, None, None],
payload: &PAYLOAD_BYTES,
timestamp: None,
};
let mut bytes = vec![0xa5; repr.buffer_len()];

Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static CONFIGS: &[(&str, usize)] = &[
("IFACE_MAX_ADDR_COUNT", 2),
("IFACE_MAX_MULTICAST_GROUP_COUNT", 4),
("IFACE_MAX_SIXLOWPAN_ADDRESS_CONTEXT_COUNT", 4),
("IFACE_NEIGHBOR_CACHE_COUNT", 4),
("IFACE_NEIGHBOR_CACHE_COUNT", 8),
("IFACE_MAX_ROUTE_COUNT", 2),
("FRAGMENTATION_BUFFER_SIZE", 1500),
("ASSEMBLER_MAX_SEGMENT_COUNT", 4),
Expand Down
32 changes: 26 additions & 6 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ FEATURES_TEST=(
"std,medium-ethernet,phy-raw_socket,proto-ipv6,socket-udp,socket-dns"
"std,medium-ethernet,phy-tuntap_interface,proto-ipv6,socket-udp"
"std,medium-ethernet,proto-ipv4,proto-ipv4-fragmentation,socket-raw,socket-dns"
"std,medium-ethernet,proto-ipv4,proto-igmp,socket-raw,socket-dns"
"std,medium-ethernet,proto-ipv4,multicast,socket-raw,socket-dns"
"std,medium-ethernet,proto-ipv4,socket-udp,socket-tcp,socket-dns"
"std,medium-ethernet,proto-ipv4,proto-dhcpv4,socket-udp"
"std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv6,proto-igmp,proto-rpl,socket-udp,socket-dns"
"std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv6,multicast,proto-rpl,socket-udp,socket-dns"
"std,medium-ethernet,proto-ipv6,socket-tcp"
"std,medium-ethernet,medium-ip,proto-ipv4,socket-icmp,socket-tcp"
"std,medium-ip,proto-ipv6,socket-icmp,socket-tcp"
"std,medium-ieee802154,proto-sixlowpan,socket-udp"
"std,medium-ieee802154,proto-sixlowpan,proto-sixlowpan-fragmentation,socket-udp"
"std,medium-ieee802154,proto-rpl,proto-sixlowpan,proto-sixlowpan-fragmentation,socket-udp"
"std,medium-ip,proto-ipv4,proto-ipv6,socket-tcp,socket-udp"
"std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv4,proto-ipv6,proto-igmp,proto-rpl,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv4,proto-ipv6,multicast,proto-rpl,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"std,medium-ieee802154,medium-ip,proto-ipv4,socket-raw"
"std,medium-ethernet,proto-ipv4,proto-ipsec,socket-raw"
)
Expand All @@ -39,9 +39,9 @@ FEATURES_TEST_NIGHTLY=(
)

FEATURES_CHECK=(
"medium-ip,medium-ethernet,medium-ieee802154,proto-ipv6,proto-ipv6,proto-igmp,proto-dhcpv4,proto-ipsec,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"defmt,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,proto-igmp,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"defmt,alloc,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,proto-igmp,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"medium-ip,medium-ethernet,medium-ieee802154,proto-ipv6,proto-ipv6,multicast,proto-dhcpv4,proto-ipsec,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"defmt,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,multicast,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"defmt,alloc,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,multicast,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
)

test() {
Expand All @@ -68,6 +68,12 @@ check() {
for features in ${FEATURES_CHECK[@]}; do
cargo +$version check --no-default-features --features "$features"
done

cargo +$version check --examples

if [[ $version == "nightly" ]]; then
cargo +$version check --benches
fi
}

clippy() {
Expand All @@ -76,6 +82,16 @@ clippy() {
cargo +$MSRV clippy --tests --examples -- -D warnings
}

build_16bit() {
rustup toolchain install nightly
rustup +nightly component add rust-src

TARGET_WITH_16BIT_POINTER=msp430-none-elf
for features in ${FEATURES_CHECK[@]}; do
cargo +nightly build -Z build-std=core,alloc --target $TARGET_WITH_16BIT_POINTER --no-default-features --features=$features
done
}

coverage() {
for features in ${FEATURES_TEST[@]}; do
cargo llvm-cov --no-report --no-default-features --features "$features"
Expand Down Expand Up @@ -115,6 +131,10 @@ if [[ $1 == "clippy" || $1 == "all" ]]; then
clippy
fi

if [[ $1 == "build_16bit" || $1 == "all" ]]; then
build_16bit
fi

if [[ $1 == "coverage" || $1 == "all" ]]; then
coverage
fi
6 changes: 1 addition & 5 deletions examples/multicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ fn main() {

// Join a multicast group to receive mDNS traffic
iface
.join_multicast_group(
&mut device,
Ipv4Address::from_bytes(&MDNS_GROUP),
Instant::now(),
)
.join_multicast_group(Ipv4Address::from_bytes(&MDNS_GROUP))
.unwrap();

loop {
Expand Down
2 changes: 1 addition & 1 deletion examples/multicast6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn main() {

// Join a multicast group
iface
.join_multicast_group(&mut device, Ipv6Address::from_parts(&GROUP), Instant::now())
.join_multicast_group(Ipv6Address::from_parts(&GROUP))
.unwrap();

loop {
Expand Down
2 changes: 1 addition & 1 deletion gen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def feature(name, default, min, max, pow2=None):
feature("iface_max_addr_count", default=2, min=1, max=8)
feature("iface_max_multicast_group_count", default=4, min=1, max=1024, pow2=8)
feature("iface_max_sixlowpan_address_context_count", default=4, min=1, max=1024, pow2=8)
feature("iface_neighbor_cache_count", default=4, min=1, max=1024, pow2=8)
feature("iface_neighbor_cache_count", default=8, min=1, max=1024, pow2=8)
feature("iface_max_route_count", default=2, min=1, max=1024, pow2=8)
feature("fragmentation_buffer_size", default=1500, min=256, max=65536, pow2=True)
feature("assembler_max_segment_count", default=4, min=1, max=32, pow2=4)
Expand Down
12 changes: 9 additions & 3 deletions src/iface/interface/ethernet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ impl InterfaceInner {
EthernetProtocol::Ipv4 => {
let ipv4_packet = check!(Ipv4Packet::new_checked(eth_frame.payload()));

self.process_ipv4(sockets, meta, &ipv4_packet, fragments)
.map(EthernetPacket::Ip)
self.process_ipv4(
sockets,
meta,
eth_frame.src_addr().into(),
&ipv4_packet,
fragments,
)
.map(EthernetPacket::Ip)
}
#[cfg(feature = "proto-ipv6")]
EthernetProtocol::Ipv6 => {
let ipv6_packet = check!(Ipv6Packet::new_checked(eth_frame.payload()));
self.process_ipv6(sockets, meta, &ipv6_packet)
self.process_ipv6(sockets, meta, eth_frame.src_addr().into(), &ipv6_packet)
.map(EthernetPacket::Ip)
}
// Drop all other traffic.
Expand Down
Loading

0 comments on commit 1c89f9e

Please sign in to comment.