net: in cgoLookupIPCNAME(), let C.getaddrinfo() get a hint about network family #25947
Comments
Seems reasonable, if it doesn't require too much plumbing inside the net package to pass that context down to Somebody is welcome to investigate & propose a CL. /cc @ianlancetaylor |
Hey @albertjin
Could you provide some example to reproduce the issue, please? As far as I can see LookupCNAME (or Resolver.LookupCNAME) does not have any args for network or other info which could be useful. |
Hi @ekalinin For a quick drive, use DialContext to connect a server. dialer := &net.Dialer{}
conn, err := dialer.DialContext(context.Background(), "tcp4", "golang.org:443") We want to dial to a |
@albertjin Thanks! Here's approximate calls stack:
@bradfitz |
We can not change the signature of an exported method, as that would break the Go 1 compatibility guarantee. This would have to be done using a new, unexported, method. Presumably |
Change https://golang.org/cl/120215 mentions this issue: |
Tested by simple: ➜ cat dial-test.go
package main
import "fmt"
import "net"
func main() {
_, err := net.Dial("tcp4", "golang.org:443")
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Done.")
} Results: #
# with fix
#
➜ sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
➜ sudo tcpdump -lvi any "udp port 53"
01:31:23.767699 IP (tos 0x0, ttl 255, id 28637, offset 0, flags [none], proto UDP (17), length 56)
myosx.56516 > router.asus.com.domain: 43089+ A? golang.org. (28)
01:31:23.769347 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 72)
router.asus.com.domain > myosx.56516: 43089 1/0/0 golang.org. A 173.194.222.141 (44)
#
# ➜ go version
# go version go1.10.3 darwin/amd64
#
➜ sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
➜ sudo tcpdump -lvi any "udp port 53"
01:31:58.597495 IP (tos 0x0, ttl 255, id 49249, offset 0, flags [none], proto UDP (17), length 56)
myosx.49561 > router.asus.com.domain: 24596+ A? golang.org. (28)
01:31:58.597852 IP (tos 0x0, ttl 255, id 23053, offset 0, flags [none], proto UDP (17), length 56)
myosx.52472 > router.asus.com.domain: 52093+ AAAA? golang.org. (28)
01:31:58.600122 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 72)
router.asus.com.domain > myosx.49561: 24596 1/0/0 golang.org. A 173.194.222.141 (44)
01:31:58.622543 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 84)
router.asus.com.domain > myosx.52472: 52093 1/0/0 golang.org. AAAA 2a00:1450:4010:c0b::8d (56)
|
I am talking about the following function in
src/net/cgo_unix.go
,Under macOS,
getaddrinfo()
will block for 5 seconds when my router drops all UDP packets of AAAA dns requests. But the requirement is barely about connecting to an IPv4 based server and no AAAA address is needed.Well, I do reconfigure my route to reply all AAAA queries with responses of an empty record set and the problem is solved. A fix of the library internals will be useful anyway.
The text was updated successfully, but these errors were encountered: