Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sockets don't work through mount #90

Closed
DUOLabs333 opened this issue Nov 1, 2023 · 11 comments
Closed

Sockets don't work through mount #90

DUOLabs333 opened this issue Nov 1, 2023 · 11 comments

Comments

@DUOLabs333
Copy link
Contributor

DUOLabs333 commented Nov 1, 2023

Create socket with nc -lkU test.sock, then mount server on directory and try to connect to it with mount/test.sock --- you get Connection refused.

This is on the same computer.

@willscott
Copy link
Owner

willscott commented Nov 1, 2023

https://superuser.com/questions/1608873/does-a-unix-domain-socket-in-an-nfs-exported-fs-magically-work-across-hosts

I don't know if there's a way to communicate the internal kernel state about how the socket is supposed to work through the nfs protocol

@DUOLabs333
Copy link
Contributor Author

DUOLabs333 commented Nov 2, 2023

Interestingly, if I try to start nc using the socket in the mount (so, nc -lU mount/test.sock instead of nc -lU test.sock), I get [ERROR] call to 0x11ae70 failed: Operation not supported. If the file already exists, Remove is called.

@DUOLabs333
Copy link
Contributor Author

It's probably because onMknod has no support.

@willscott
Copy link
Owner

good catch. it should be reasonable straight forward to add that - i think the trick will be that the underlying billy fs interface also doesn't expose anything around this, so we'll need to add another optional interface for handlers to implement if they want to expose that on their filesystem implementation.

@DUOLabs333
Copy link
Contributor Author

Yes --- we could just copy the syscall argument list --- path, mode, device number.

@willscott
Copy link
Owner

Do you have a sense of what the underlying system call should be when Mknod for a socket is sent over NFS?

  • the rfc indicates that Mknod can take a file type of NF3SOCK indicating creation of a socket. When that is requested, the only passed data is the sattr3 pipe_attributes; - which does not include a major or minor number.

@willscott
Copy link
Owner

I think i have a sketch of the expected backing behavior - working through it in https://github.com/willscott/go-nfs/tree/feat/mknod and will PR once ready.

The rfc is pretty thin on details on the expected semantics of a created socket in particular, but this may be close enough

@willscott
Copy link
Owner

the branch has a first pass at what seems like plausible for this code, and the osnfs example supporting mknod operations.

if you can point me to concrete repro steps for things not working ("on ubuntu, make an nfs mount, run these lines, get error") i'll be able to get to fixing potential bugs in here faster

@DUOLabs333
Copy link
Contributor Author

DUOLabs333 commented Nov 4, 2023

Sorry, didn't see this till now: interestingly, you can't create just "hanging" sockets, but it looks like you figured something out.

There are two reproducers: one, create a mount exposing a local directory --- mount 127.0.0.1:dir mount. Run nc -lkU dir/test.sock. Try to do nc mount/test.sock. You should get a "Connection refused". However, this does not seem possible to solve.

Another reproducer: Do nc -lkU mount/test.sock. Then try to do nc mount/test.sock. You should get a Remove call and an "Operation not permitted". This is something that should be fixable.

@willscott
Copy link
Owner

Updated the branch linked above. I was able to create a socket and a fifo over the mount locally at least.

can you see if that gives you better behavior?

@DUOLabs333
Copy link
Contributor Author

It does seem to work now --- the second reproducer now leads to the expected behavior (I can connect and send messages back and forth). #91 is still an issue though, so sockets wasn't the issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants