gvisor icon indicating copy to clipboard operation
gvisor copied to clipboard

tcpip.Address: IPv4 and IPv6 "ANY" are indistinguishable

Open tamird opened this issue 5 years ago • 9 comments

Both IPv4 and IPv6 "ANY" are modeled by the empty string, which means it is impossible to tell from outside of the package tcpip's interfaces if such "ANY" addresses are IPv4 or IPv6.

This is a generalization of #1495.

tamird avatar Jan 13 '20 19:01 tamird

Just to record what was discussed. I believe the long term fix is to make tcpip.FullAddress carry a family similar to sockaddr_in/in6.

hbhasker avatar Jan 13 '20 20:01 hbhasker

That's likely not going to be enough in all cases - you still can't tell if tcpip.Address("") is a v4 or a v6.

I would personally like to see tcpip.Address finally stop being a string and instead be either:

type Address struct {
  data [header.IPv6AddressSize]byte
  v6 bool
}

or

type Address struct {
  data [16]byte
  length uint8
}

tamird avatar Jan 13 '20 20:01 tamird

That will work too. But I think in general a FullAddress should carry the family. That should be an easier fix than changing tcpip.Address.

hbhasker avatar Jan 13 '20 20:01 hbhasker

We should consider switching to https://pkg.go.dev/inet.af/netaddr. We would need a different type to represent unix addresses.

tamird avatar May 01 '21 12:05 tamird

A friendly reminder that this issue had no activity for 120 days.

github-actions[bot] avatar Sep 15 '23 00:09 github-actions[bot]

tcpip.Address is no longer used to represent unix addresses since https://github.com/google/gvisor/commit/8478fe0a277fd2581f8df5560a310daa7277ed15 and has the shape described in https://github.com/google/gvisor/issues/1556#issuecomment-573854879 since https://github.com/google/gvisor/commit/792ebbff8e828248ef3b547f529f077447d46396#diff-5275b0dfd85666a8969324583bfb3ea342831a4c69d8524c3f64326294d4f0e8.

it's possible there's nothing left to do here. @kevinGC if there's a bug tracking moving to netip.Addr then this should be closed in favor of that bug.

tamird avatar Sep 15 '23 18:09 tamird

A friendly reminder that this issue had no activity for 120 days.

github-actions[bot] avatar Jan 14 '24 00:01 github-actions[bot]

This issue has been closed due to lack of activity.

github-actions[bot] avatar Apr 14 '24 00:04 github-actions[bot]

There are TODOs still referencing this issue:

  1. test/syscalls/linux/socket_inet_loopback.cc:198: uncomment V4MappedAny.
  2. pkg/sentry/socket/netstack/netstack.go:685: remove this function.

Search TODO

github-actions[bot] avatar Apr 15 '24 02:04 github-actions[bot]