diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-10-29 21:14:36 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-10-29 21:14:36 +0000 |
commit | 38352c1de305a60c9591d37e57d616570100b03e (patch) | |
tree | 3d4ed7af1aa630797f6884e8a1523f2ee02aa016 | |
parent | 322b3f8d1e275eae3154d28f56b1c0644d9fcabc (diff) | |
parent | b9f18fe2f1ad0c8547e2bd66d1cd3bbbddfbddda (diff) |
Merge release-20201019.0-102-gb9f18fe2f (automated)
-rw-r--r-- | pkg/tcpip/transport/tcp/endpoint.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go index 127c19b00..8f5e3a42d 100644 --- a/pkg/tcpip/transport/tcp/endpoint.go +++ b/pkg/tcpip/transport/tcp/endpoint.go @@ -2690,14 +2690,16 @@ func (e *endpoint) bindLocked(addr tcpip.FullAddress) (err *tcpip.Error) { return err } - // Expand netProtos to include v4 and v6 if the caller is binding to a - // wildcard (empty) address, and this is an IPv6 endpoint with v6only - // set to false. netProtos := []tcpip.NetworkProtocolNumber{netProto} - if netProto == header.IPv6ProtocolNumber && !e.v6only && addr.Addr == "" { - netProtos = []tcpip.NetworkProtocolNumber{ - header.IPv6ProtocolNumber, - header.IPv4ProtocolNumber, + + // Expand netProtos to include v4 and v6 under dual-stack if the caller is + // binding to a wildcard (empty) address, and this is an IPv6 endpoint with + // v6only set to false. + if netProto == header.IPv6ProtocolNumber { + stackHasV4 := e.stack.CheckNetworkProtocol(header.IPv4ProtocolNumber) + alsoBindToV4 := !e.v6only && addr.Addr == "" && stackHasV4 + if alsoBindToV4 { + netProtos = append(netProtos, header.IPv4ProtocolNumber) } } |