Unix-domain sockets - abstract addresses

Michael Procter (lkml@procter-collective.org.uk)
Thu, 8 Aug 2002 17:15:24 +0100


I have been trying to use unix domain datagram sockets in an application,
but have found what appears to be an inconsistency between the kernel and
the manpage unix(7).

I have a server, which creates a socket, binds it to an address and then
does a recvfrom(). When it gets a packet, it tries to respond with
sendto(), supplying the address information from the recvfrom() call.

All this works fine when the client binds it's socket to an address in the
filesystem before issuing the connect(). But I don't want another
filesystem entity, so I am trying to use an address in the abstract
namespace.

Abstract addresses work fine when the client calls bind() with an address
length of 2, and also if it sets the socket option SO_PASSCRED before
connect(). But if the client does neither and simply calls connect(),
the server gets an invalid 'from' address (address family usually zero,
but I have seen 0x0BA5, 0x7FA8, 0x1FA8 and others).

According to the man page 'unix(7)':
When a socket is connected and it doesn't already have a local address a
unique address in the abstract namespace will be generated automatically.

So, the question is: which is right? The man page, or af_unix.c?

I have been doing my tests on 2.4.9-34 (RedHat 7.2), but looking at 2.4.19
from kernel.org, the results should be the same.

Regards,

Michael Procter
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/