Skip to content

fix: don't panic if no suitable IPv6 src_addr is found #895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

thvdveld
Copy link
Contributor

Prevent panic when no suitable source address is found. If no suitable address is found, the loopback address is used instead. The function can still panic when the destination address is unspecified.

More tests are added:

  • Tests when the interface has no addresses. The loopback address is used as source address.
  • Tests when the interface only has a link-local address. The link-local address is used as source address, unless the destination address is the loopback address. In this case, the loopback address is used as source address.

This should fix #894 .

@thvdveld thvdveld marked this pull request as draft January 11, 2024 13:07
Prevent panic when no suitable source address is found. If no suitable
address is found, the loopback address is used instead. The function can
still panic when the destination address is unspecified.

More tests are added:
- Tests when the interface has no addresses. The loopback address is
  used as source address.
- Tests when the interface only has a link-local address. The link-local
  address is used as source address, unless the destination address is
  the loopback address. In this case, the loopback address is used as
  source address.
@thvdveld thvdveld force-pushed the fix-ipv6-src-addr-selection branch from 2a66627 to d26a313 Compare January 11, 2024 13:25
@thvdveld thvdveld changed the title change(ipv6): don't panic if no suitable src_addr fix: don't panic if no suitable IPv6 src_addr is found Jan 11, 2024
Copy link

codecov bot commented Jan 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d185a37) 79.82% compared to head (d26a313) 79.92%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #895      +/-   ##
==========================================
+ Coverage   79.82%   79.92%   +0.09%     
==========================================
  Files          80       80              
  Lines       28053    28224     +171     
==========================================
+ Hits        22394    22557     +163     
- Misses       5659     5667       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thvdveld thvdveld marked this pull request as ready for review January 11, 2024 13:31
@thvdveld thvdveld added this pull request to the merge queue Jan 17, 2024
Merged via the queue into smoltcp-rs:main with commit 9bd836b Jan 17, 2024
@thvdveld thvdveld deleted the fix-ipv6-src-addr-selection branch January 17, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Bug in IPv6 source address selection (#864) prevents sending packets to localhost to localhost
1 participant