On Mon, May 22, 2017 at 08:54:56AM -0400, Jeff Layton wrote: > On Mon, 2017-05-22 at 13:21 +0100, Stefan Hajnoczi wrote: > > On Thu, May 18, 2017 at 10:04:24AM -0400, Jeff Layton wrote: > > > On Fri, 2016-10-07 at 11:01 +0100, Stefan Hajnoczi wrote: > > > > @@ -249,6 +302,10 @@ size_t rpc_pton(struct net *net, const char *buf, const size_t buflen, > > > > { > > > > unsigned int i; > > > > > > > > + /* TODO is there a nicer way to distinguish vsock addresses? */ > > > > + if (strncmp(buf, "vsock:", 6) == 0) > > > > + return rpc_pton_vsock(buf, buflen, sap, salen); > > > > + > > > > > > Ick, what if I have a host on the network named "vsock"? I think you'll > > > need to come up with a different way to do this. > > > > There is no collision. This function doesn't do name resolution and no > > valid IPv4/IPv6 address starts with "vsock:". > > > > Doh! Of course... :) > > > I am open to suggestions for a cleaner way of doing it though :). > > Does lsof recognize vsock sockets? How does it format them? lsof only prints a generic socket representation: COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME nc-vsock 20775 stefanha 3u sock 0,9 0t0 1518648 protocol: AF_VSOCK Depending on a program's command-line syntax, addresses are usually written as CID:PORT, or vsock:CID:PORT if the program must differentiate between address types from the string itself. QEMU, qemu-guest-agent, and systemd have syntax for specifying AF_VSOCK sockets. For example: https://github.com/systemd/systemd/blob/master/src/test/test-socket-util.c#L98 If I have time to submit lsof patches I'll propose the following syntax (a combination of how AF_UNIX and AF_INET TCP sockets are formatted): COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME nc-vsock 20775 stefanha 3u vsock 1520136 0t0 1520136 local=2:1234 state=LISTEN type=STREAM nc-vsock 20775 stefanha 4u vsock 1520138 0t0 1520138 local=2:1234 remote=3:51213 state=CONNECTED type=STREAM Stefan
Attachment:
signature.asc
Description: PGP signature