smoltcp-rs / smoltcp

a smol tcp/ip stack
BSD Zero Clause License
3.75k stars 421 forks source link

Wrong total length field in the first IPv4 fragment header on outgoing #791

Closed equation314 closed 1 year ago

equation314 commented 1 year ago

It seems to be introduced by https://github.com/smoltcp-rs/smoltcp/commit/3a9d017354acde5c139496243dffec4e4fb05fdf which removes ref before mut repr:

https://github.com/smoltcp-rs/smoltcp/blob/3a9d017354acde5c139496243dffec4e4fb05fdf/src/iface/interface/mod.rs#L1802-L1808

This causes later changes to repr.payload_len to not change ip_repr.payload_len, which is used as the total length in the IP header in emit_ip:

https://github.com/smoltcp-rs/smoltcp/blob/3a9d017354acde5c139496243dffec4e4fb05fdf/src/iface/interface/mod.rs#L1842-L1848

Before https://github.com/smoltcp-rs/smoltcp/commit/3a9d017354acde5c139496243dffec4e4fb05fdf (https://github.com/smoltcp-rs/smoltcp/commit/98deb41ee531498c7117d87b34b28b18c63366c4):

截屏2023-06-05 12 34 56

After https://github.com/smoltcp-rs/smoltcp/commit/3a9d017354acde5c139496243dffec4e4fb05fdf:

截屏2023-06-05 12 40 22