Skip to content
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

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

Closed
samueljero opened this issue Jan 10, 2024 · 1 comment · Fixed by #895

Comments

@samueljero
Copy link

In particular, given an interface with only the IPv6 localhost address, it is not possible to send packets to one's self. If sending ICMP packets, smoltcp panics:

(this is version 0.11, but master has the same bug)

panicked at smoltcp-0.11.0/src/iface/interface/mod.rs:882:14:
called `Option::unwrap()` on a `None` value

This appears to result from a bug in #864, where localhost addresses are never considered for sending packets:

// Loopback addresses and multicast address can not be in the candidate source address
// list. Except when the destination multicast address has a link-local scope, then the
// source address can also be link-local multicast.
if src_addr.is_loopback() || src_addr.is_multicast() {
return false;
}

Presumably this should have an exception for when the destination address is localhost.

Note that this only effects unbound sockets, as the IPv6 source address selection algorithm is not run for bound sockets.

@thvdveld
Copy link
Contributor

Thank you for reporting this! The loopback address should be in the candidate list of source addresses. I think line 45 should be src_addr.unspecified() instead of src_addr.is_loopback(), as line 45 covers the following in RFC6724:

In any case, multicast addresses and the unspecified address MUST NOT
be included in a candidate set.

I'll fix this and add more tests for the source address selection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants