google / gvisor

Application Kernel for Containers
https://gvisor.dev
Apache License 2.0
15.38k stars 1.27k forks source link

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

Open tamird opened 4 years ago

tamird commented 4 years ago

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.

hbhasker commented 4 years ago

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.

tamird commented 4 years ago

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
}
hbhasker commented 4 years ago

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.

tamird commented 3 years ago

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

github-actions[bot] commented 10 months ago

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

tamird commented 10 months ago

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.

github-actions[bot] commented 6 months ago

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

github-actions[bot] commented 3 months ago

This issue has been closed due to lack of activity.

github-actions[bot] commented 3 months ago

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