IPv6 Zone ID Comparison

We are noticing a failing assert in the stdlib when using Socket::recv_from. Due to the interface being a link-local address, the OS may insert a zone index which in some cases will cause mismatches. I'm wondering if it would be a good idea to implement more functionality for make such comparisons easier such as:

  • compare_ignore_zone checks for equality while ignoring the zone
  • get_zone_id which is self explanatory
  • others useful interfaces
---- net::udp::tests::socket_smoke_test_ip4 stdout ----
thread 'net::udp::tests::socket_smoke_test_ip4' panicked at std/src/net/udp/tests.rs:49:9:
assertion `left == right` failed
  left: [::1%1]:19681
 right: [::1]:19681
2 Likes

Seems a bit annoying that it can be either a number or an "implementation defined string" (network interface name in practice).

How does the latter representation work in struct sockaddr_in6? It seems according to the man page to just support the numeric scope id (which appears to be the same thing).

But regardless, once the exact semantics are figured out rust should support this (and at the very least not panic on the OS setting this field).

The socket_smoke_test_ip4 test is weird. it has ip4 in its name, but actually tests both IPv4 and IPv6.

How is that different from SocketAddrV6::scope_id?

How does the latter representation work in struct sockaddr_in6?

I assume interface names will be resolved to the equivalent numeric id, which is then stored in the socket addr.