ksocket doesn't support AF_UNIX
ksocket_socket() doesn't accept AF_UNIX and AF_NCA domains. I removed the check for AF_UNIX and wrote a simple echo client which speaks with user space server. It seems to work fine so I wonder, why AF_UNIX wasn't supported? Is there a known problem or just lack of testing?
Updated by Stepan Zastupov about 11 years ago
- File ksocket.patch ksocket.patch added
- File echo_server.c echo_server.c added
- Status changed from New to Feedback
I attached the patch and a user-space echo server for testing. I have no kernel example but it works fine from my experience.
Updated by Rich Lowe about 11 years ago
Perhaps Dan has some memory of why this is?
Does a change such as this require any extra protection in the face of zones? (to prevent someone in the context of zone A communicating with a socket in zone B?). A wild guess based on the choice of disallowed sockets.
Updated by Stepan Zastupov almost 11 years ago
AF_UNIX support is implemented in socktpi.c of sockfs module and socktpi has some issues:
- socktpi doesn't use much of sockfs infrastructure like upcalls/downcalls which are capable of calling ksocket callbacks. Therefore, ksocket callbacks won't be ever called with AF_UNIX.
- socktpi can work in different modes (SOV_STREAM, SOV_SOCKSTREAM, SOV_SOCKBSD, etc...). Syscalls use SOV_SOCKBSD while ksocket uses SOV_DEFAULT (which is basically SOV_STREAM). So when socktpi works in SOV_STREAM mode it passes most of the calls directly to STREAMS. STREAMS assumes that the upper layer takes care of some ioctls (like FIONBIO). The problem is that socktpi doesn't handle FIONBIO for SOV_STREAM either. So basically, you can't turn socktpi ksocket to non-blocking mode.
- Message headers (of sendmsg()) are ignored for SOV_STREAM.
Probably the best solution would be to rewrite AF_UNIX using sockfs infrastructure but it's quite a lot of work. So the patch only removes check for AF_UNIX and adds workaround for the lack of the support for ksocket callbacks. ksocket_spoll() uses poll() infrastructure which is quite hairy, it allocates poll data structures on every call and it's overall ugly but it solves the problem. Feel free to propose a better solution without rewriting socktpi :)
Updated by Gordon Ross almost 11 years ago
- Status changed from Feedback to Resolved
changeset: 13477:3d8bcfed4059 tag: tip user: Stepan Zastupov <email@example.com> date: Sun Oct 02 23:44:03 2011 +0400 description: 1056 ksocket doesn't support AF_UNIX Reviewed by: Gordon Ross <firstname.lastname@example.org> Reviewed by: Garrett D'Amore <email@example.com> Approved by: Eric Schrock <firstname.lastname@example.org>