-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
Hi all,
I'm trying to port x/crypto/ssh/test for aix/ppc64 and I've a problem with the test TestDialUnix.
This test is creating a unix socket and will try to dial/accept before checking which addresses are returned.
The remote address after the accept (ie on the server side) both on Linux and AIX seems to be a unnamed socket (if I correctly understand the principle of unnamed socket which is a socket with no address).
However, on Linux, the result is an address named "@".
On Linux,
This comes from syscall.anyToSockaddr:
(gdb) bt
#0 syscall.anyToSockaddr (rsa=0xc000034c90, ~r1=..., ~r2=...) at /home/chigotc/go/goroot/src/syscall/syscall_linux.go:450
#1 0x000000000048a2ee in syscall.Accept4 (fd=3, flags=526336, nfd=, sa=..., err=...) at /home/chigotc/go/goroot/src/syscall/syscall_linux.go:548
#2 0x000000000049a0bf in internal/poll.accept (s=3, ~r1=, ~r2=..., ~r3=..., ~r4=...) at /home/chigotc/go/goroot/src/internal/poll/sock_cloexec.go:17
#3 0x00000000004996d6 in internal/poll.(*FD).Accept (fd=0xc0000bc000, ~r0=, ~r1=..., ~r2=..., ~r3=...) at /home/chigotc/go/goroot/src/internal/poll/fd_unix.go:377
#4 0x00000000004c9782 in net.(*netFD).accept (fd=0xc0000bc000, netfd=, err=...) at /home/chigotc/go/goroot/src/net/fd_unix.go:238
#5 0x00000000004e1102 in net.(*UnixListener).accept (ln=0xc000093350, ~r0=, ~r1=...) at /home/chigotc/go/goroot/src/net/unixsock_posix.go:162
#6 0x00000000004dfcb8 in net.(*UnixListener).Accept (l=0xc000093350, ~r0=..., ~r1=...) at /home/chigotc/go/goroot/src/net/unixsock.go:260
#7 0x00000000004eae3f in main.testDial.func1 (l=..., x=..., testData=...) at /home/chigotc/go/goprogs/dialunnamed.go:37
(gdb) p *rsa
$5 = {Addr = {Family = 1, Data = '\000' <repeats 13 times>}, Pad = '\000' <repeats 95 times>
In Linux's anyToSockaddr, if the first character of the path is '\0', this one is being transformed into "@".
Therefore, the final sockaddr looks like:
(gdb) p *sa
$8 = {Name = 0x61a2c0 "@", raw = {Family = 0, Path = '\000' <repeats 107 times>}}
Looking at the comment, this transformation is made for abstract unix sockets, but it seems to also impact unnamed sockets.
On aix/ppc64, we also have rsa with an empty data.
However, without any changes the final sockaddr will have an empty Name:
(gdb) p *sa
$2 = {Name = 0x0 "", raw = {Len = 0 '\000', Family = 0 '\000', Path = '\000' <repeats 1022 times>}}
The test will therefore fail as it want explicitly the address to be "@".
I don't know how BSD Oses are reacting in this case. Is the kernel already returning "@" ? Or is it fixed somewhere in the code ? I didn't find anything.
But more important, is Go expected unnamed socket to be named "@" or "" ?
Note that AIX doesn't support abstract unix socket. But if I'm transforming the "" address to a "@" address, everything seems to work.
Ps: This can be reproduced without ssh package actually. It's just that ssh tests explicitly check that the address returned is "@".