NFS: add AF_VSOCK support to NFS client
Subsystems (9)
Stefan Hajnoczi
maintainerv2 cover NFS: add AF_VSOCK support to NFS client
This patch series enables AF_VSOCK address family support in the NFS client. You can also get the commits from the vsock-nfs branch at
https://github.com/stefanha/linux.git.
The AF_VSOCK address family provides dgram and stream socket communication between virtual machines and hypervisors. VMware VMCI and virtio (for KVM) transports are available, see net/vmw_vsock.
The goal of this work is sharing files between virtual machines and hypervisors. AF_VSOCK is well-suited to this because it requires no configuration inside the virtual machine, making it simple to manage and reliable.
Why NFS over AF_VSOCK?
----------------------
It is unusual to add a new NFS transport, only TCP, RDMA, and UDP are currently supported. Here is the rationale for adding AF_VSOCK.
Sharing files with a virtual machine can be configured manually:
1. Add a dedicated network card to the virtual machine. It will be used for NFS traffic.
2. Configure a local subnet and assign IP addresses to the virtual machine and hypervisor
3. Configure an NFS export on the hypervisor and start the NFS server
4. Mount the export inside the virtual machine
Automating these steps poses a problem: modifying network configuration inside the virtual machine is invasive. It's hard to add a network interface to an arbitrary running system in an automated fashion, considering the network management tools, firewall rules, IP address usage, etc.
Furthermore, the user may disrupt file sharing by accident when they add firewall rules, restart networking, etc because the NFS network interface is visible alongside the network interfaces managed by the user.
AF_VSOCK is a zero-configuration network transport that avoids these problems. Adding it to a virtual machine is non-invasive. It also avoids accidental misconfiguration by the user. This is why "guest agents" and other services in various hypervisors (KVM, Xen, VMware, VirtualBox) do not use regular network interfaces.
This is why AF_VSOCK is appropriate for providing shared files as a hypervisor service.
The approach in this series
---------------------------AF_VSOCK stream sockets can be used for NFSv4.1 much in the same way as TCP. RFC 1831 record fragments divide messages since SOCK_STREAM semantics are present. The backchannel shares the connection just like the default TCP configuration.
Addresses are <Context ID, Port Number> pairs. These patches use "vsock:<cid>" string representation to distinguish AF_VSOCK addresses from IPv4 and IPv6 numeric addresses.
The following example mounts /export from the hypervisor (CID 2) inside the virtual machine (CID 3):
# /sbin/mount.nfs 2:/export /mnt -o clientaddr=3,proto=vsock
Please see the nfs-utils patch series I have just sent to [email protected] for the necessary patches.
Status
------
The virtio-vsock transport was merged in Linux 4.8 and the vhost-vsock-pci device is available in QEMU git master. This means the underlying AF_VSOCK transport for KVM is now available upstream.
I have begun work on nfsd support in the kernel and nfs-utils. This is not complete yet and will be sent as separate patch series.
Stefan Hajnoczi (10):
SUNRPC: add AF_VSOCK support to addr.[ch]
SUNRPC: rename "TCP" record parser to "stream" parser
SUNRPC: abstract tcp_read_sock() in record fragment parser
SUNRPC: extract xs_stream_reset_state()
VSOCK: add tcp_read_sock()-like vsock_read_sock() function
SUNRPC: add AF_VSOCK support to xprtsock.c
SUNRPC: drop unnecessary svc_bc_tcp_create() helper
SUNRPC: add AF_VSOCK support to svc_xprt.c
SUNRPC: add AF_VSOCK backchannel support
NFS: add AF_VSOCK support to NFS client
drivers/vhost/vsock.c | 1 + fs/nfs/client.c | 2 + fs/nfs/super.c | 11 +- include/linux/sunrpc/addr.h | 44 ++ include/linux/sunrpc/svc_xprt.h | 12 + include/linux/sunrpc/xprt.h | 1 + include/linux/sunrpc/xprtsock.h | 36 +- include/linux/virtio_vsock.h | 4 + include/net/af_vsock.h | 5 + include/trace/events/sunrpc.h | 28 +- net/sunrpc/Kconfig | 10 + net/sunrpc/addr.c | 57 +++ net/sunrpc/svc_xprt.c | 18 + net/sunrpc/svcsock.c | 48 ++- net/sunrpc/xprtsock.c | 703 +++++++++++++++++++++++++------- net/vmw_vsock/af_vsock.c | 16 + net/vmw_vsock/virtio_transport.c | 1 + net/vmw_vsock/virtio_transport_common.c | 66 +++ net/vmw_vsock/vmci_transport.c | 8 + 19 files changed, 880 insertions(+), 191 deletions(-)
Signature · 1 line
2.7.4
Stefan Hajnoczi
maintainerPATCH v2 1/10 SUNRPC: add AF_VSOCK support to addr.[ch]
AF_VSOCK addresses are a Context ID (CID) and port number tuple. The CID is a unique address, similar to a IP address on a local subnet.
Extend the addr.h functions to handle AF_VSOCK addresses.
---
v2:
* Replace CONFIG_VSOCKETS with CONFIG_SUNRPC_XPRT_VSOCK to prevent build failures when SUNRPC=y and VSOCKETS=m. Built-in code cannot link against code in a module.
--- include/linux/sunrpc/addr.h | 44 ++++++++++++++++++++++++++++++++++ net/sunrpc/Kconfig | 10 ++++++++ net/sunrpc/addr.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+)
include/linux/sunrpc/addr.h +44 -0
@@ -10,6 +10,7 @@#include <linux/socket.h> #include <linux/in.h> #include <linux/in6.h> +#include <linux/vm_sockets.h> #include <net/ipv6.h> size_t rpc_ntop (const struct sockaddr *,char *,const size_t );
@@ -26,6 +27,8 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)return ntohs (((struct sockaddr_in *)sap)->sin_port);case AF_INET6 :return ntohs (((struct sockaddr_in6 *)sap)->sin6_port); +case AF_VSOCK : +return ((struct sockaddr_vm *)sap)->svm_port; }return 0 ; }
@@ -40,6 +43,9 @@ static inline void rpc_set_port(struct sockaddr *sap,case AF_INET6 : ((struct sockaddr_in6 *)sap)->sin6_port =htons (port);break ; +case AF_VSOCK : + ((struct sockaddr_vm *)sap)->svm_port = port; +break ; } }
@@ -106,6 +112,40 @@ static inline bool __rpc_copy_addr6(struct sockaddr *dst, }#endif /* !(IS_ENABLED(CONFIG_IPV6) */ +#if IS_ENABLED (CONFIG_VSOCKETS ) +static inline bool rpc_cmp_vsock_addr (const struct sockaddr *sap1, +const struct sockaddr *sap2) +{ +const struct sockaddr_vm *svm1 = (const struct sockaddr_vm *)sap1; +const struct sockaddr_vm *svm2 = (const struct sockaddr_vm *)sap2; + +return svm1->svm_cid == svm2->svm_cid; +} + +static inline bool __rpc_copy_vsock_addr (struct sockaddr *dst, +const struct sockaddr *src) +{ +const struct sockaddr_vm *ssvm = (const struct sockaddr_vm *)src; +struct sockaddr_vm *dsvm = (struct sockaddr_vm *)dst; + + dsvm->svm_family = ssvm->svm_family; + dsvm->svm_cid = ssvm->svm_cid; +return true; +} +#else /* !(IS_ENABLED(CONFIG_VSOCKETS) */ +static inline bool rpc_cmp_vsock_addr (const struct sockaddr *sap1, +const struct sockaddr *sap2) +{ +return false; +} + +static inline bool __rpc_copy_vsock_addr (struct sockaddr *dst, +const struct sockaddr *src) +{ +return false; +} +#endif /* !(IS_ENABLED(CONFIG_VSOCKETS) */ +/** * rpc_cmp_addr - compare the address portion of two sockaddrs. * @sap1: first sockaddr
@@ -125,6 +165,8 @@ static inline bool rpc_cmp_addr(const struct sockaddr *sap1,return rpc_cmp_addr4 (sap1, sap2);case AF_INET6 :return rpc_cmp_addr6 (sap1, sap2); +case AF_VSOCK : +return rpc_cmp_vsock_addr (sap1, sap2); } }return false;
@@ -161,6 +203,8 @@ static inline bool rpc_copy_addr(struct sockaddr *dst,return __rpc_copy_addr4 (dst, src);case AF_INET6 :return __rpc_copy_addr6 (dst, src); +case AF_VSOCK : +return __rpc_copy_vsock_addr (dst, src); }return false; }
net/sunrpc/Kconfig +10 -0
@@ -61,3 +61,13 @@ config SUNRPC_XPRT_RDMA If unsure, or you know there is no RDMA capability on your hardware platform, say N. + +config SUNRPC_XPRT_VSOCK + bool "RPC-over-AF_VSOCK transport" + depends on SUNRPC && VSOCKETS && !(SUNRPC=y && VSOCKETS=m) + default SUNRPC && VSOCKETS + help + This option allows the NFS client and server to use the AF_VSOCK + transport to communicate between virtual machines and the host. + + If unsure, say Y.
net/sunrpc/addr.c +57 -0
92 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v2 01/10] SUNRPC: add AF_VSOCK support to addr.[ch]
Hi Stefan-
Quoted 6 lines · Stefan Hajnoczi
AF_VSOCKaddresses are a Context ID (CID) and port number tuple. The CID is a unique address, similar to a IP address on a local subnet.Extend the
addr.hfunctions to handleAF_VSOCKaddresses.
I'm wondering if there's a specification for how to construct the universal address form of an AF_VSOCK address. This would be needed for populating an fs_locations response, or for updating the NFS server's local rpcbind service.
A traditional NFS server employs IP-address based access control. How does that work with the new address family? Do you expect changes to mountd or exportfs?
Is there a standard that defines the "vsock" netid? A new netid requires at least an IANA action. Is there a document that describes how RPC works with a VSOCK transport?
This work appears to define two separate things: a new address family, and a new transport type. Wouldn't it be cleaner to dispense with the "proto=vsock" piece, and just support TCP over AF_VSOCK (just as it works for AF_INET and AF_INET6) ?
At Connectathon, we discussed what happens when a guest is live-migrated to another host with a vsock-enabled NFSD. Essentially, the server at the known-local address would change identities and its content could be completely different. For instance, the file handles would all change, including the file handle of the export's root directory. Clients don't tolerate that especially well.
Can't a Docker-based or kvm-based guest simply mount one of the host's local file systems directly? What would be the value of inserting NFS into that picture?
Quoted 229 lines
Signed-off-by Stefan Hajnoczi <[email protected]>---
v2:
* ReplaceCONFIG_VSOCKETSwithCONFIG_SUNRPC_XPRT_VSOCKto prevent build failures when SUNRPC=y and VSOCKETS=m. Built-in code cannot link against code in a module.---
include/linux/sunrpc/addr.h | 44 ++++++++++++++++++++++++++++++++++ net/sunrpc/Kconfig | 10 ++++++++ net/sunrpc/addr.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+)include/linux/sunrpc/addr.h +44
-0@@ -10,6 +10,7 @@#include <linux/socket.h> #include <linux/in.h> #include <linux/in6.h> +#include <linux/vm_sockets.h> #include <net/ipv6.h> size_t rpc_ntop (const struct sockaddr *,char *,const size_t );@@ -26,6 +27,8 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)return ntohs (((struct sockaddr_in *)sap)->sin_port);case AF_INET6 :return ntohs (((struct sockaddr_in6 *)sap)->sin6_port); +case AF_VSOCK : +return ((struct sockaddr_vm *)sap)->svm_port; }return 0 ; }@@ -40,6 +43,9 @@ static inline void rpc_set_port(struct sockaddr *sap,case AF_INET6 : ((struct sockaddr_in6 *)sap)->sin6_port =htons (port);break ; +case AF_VSOCK : + ((struct sockaddr_vm *)sap)->svm_port = port; +break ; } }@@ -106,6 +112,40 @@ static inline bool __rpc_copy_addr6(struct sockaddr *dst, }#endif /* !(IS_ENABLED(CONFIG_IPV6) */ +#if IS_ENABLED (CONFIG_VSOCKETS ) +static inline bool rpc_cmp_vsock_addr (const struct sockaddr *sap1, +const struct sockaddr *sap2) +{ +const struct sockaddr_vm *svm1 = (const struct sockaddr_vm *)sap1; +const struct sockaddr_vm *svm2 = (const struct sockaddr_vm *)sap2; + +return svm1->svm_cid == svm2->svm_cid; +} + +static inline bool __rpc_copy_vsock_addr (struct sockaddr *dst, +const struct sockaddr *src) +{ +const struct sockaddr_vm *ssvm = (const struct sockaddr_vm *)src; +struct sockaddr_vm *dsvm = (struct sockaddr_vm *)dst; + + dsvm->svm_family = ssvm->svm_family; + dsvm->svm_cid = ssvm->svm_cid; +return true; +} +#else /* !(IS_ENABLED(CONFIG_VSOCKETS) */ +static inline bool rpc_cmp_vsock_addr (const struct sockaddr *sap1, +const struct sockaddr *sap2) +{ +return false; +} + +static inline bool __rpc_copy_vsock_addr (struct sockaddr *dst, +const struct sockaddr *src) +{ +return false; +} +#endif /* !(IS_ENABLED(CONFIG_VSOCKETS) */ +/** * rpc_cmp_addr - compare the address portion of two sockaddrs. * @sap1: first sockaddr @@ -125,6 +165,8 @@ static inline bool rpc_cmp_addr(const struct sockaddr *sap1,return rpc_cmp_addr4 (sap1, sap2);case AF_INET6 :return rpc_cmp_addr6 (sap1, sap2); +case AF_VSOCK : +return rpc_cmp_vsock_addr (sap1, sap2); } }return false;@@ -161,6 +203,8 @@ static inline bool rpc_copy_addr(struct sockaddr *dst,return __rpc_copy_addr4 (dst, src);case AF_INET6 :return __rpc_copy_addr6 (dst, src); +case AF_VSOCK : +return __rpc_copy_vsock_addr (dst, src); }return false; }net/sunrpc/Kconfig +10
-0@@ -61,3 +61,13 @@ config SUNRPC_XPRT_RDMA If unsure, or you know there is no RDMA capability on your hardware platform, say N. + +config SUNRPC_XPRT_VSOCK + bool "RPC-over-AF_VSOCK transport" + depends on SUNRPC && VSOCKETS && !(SUNRPC=y && VSOCKETS=m) + default SUNRPC && VSOCKETS + help + This option allows the NFS client and server to use the AF_VSOCK + transport to communicate between virtual machines and the host. + + If unsure, say Y.net/sunrpc/addr.c +57
-0@@ -16,11 +16,14 @@* RFC 4291, Section 2.2 for details on IPv6 presentation formats. */ +/* TODO register netid and uaddr with IANA? (See RFC 5665 5.1/5.2) */ +#include <net/ipv6.h> #include <linux/sunrpc/addr.h> #include <linux/sunrpc/msg_prot.h> #include <linux/slab.h> #include <linux/export.h> +#include <linux/vm_sockets.h> #if IS_ENABLED (CONFIG_IPV6 )@@ -108,6 +111,26 @@ static size_t rpc_ntop6(const struct sockaddr *sap,#endif /* !IS_ENABLED(CONFIG_IPV6) */ +#ifdef CONFIG_SUNRPC_XPRT_VSOCK + +static size_t rpc_ntop_vsock (const struct sockaddr *sap, +char *buf,const size_t buflen) +{ +const struct sockaddr_vm *svm = (struct sockaddr_vm *)sap; + +return snprintf (buf, buflen,"%u" , svm->svm_cid); +} + +#else /* !CONFIG_SUNRPC_XPRT_VSOCK */ + +static size_t rpc_ntop_vsock (const struct sockaddr *sap, +char *buf,const size_t buflen) +{ +return 0 ; +} + +#endif /* !CONFIG_SUNRPC_XPRT_VSOCK */ +static int rpc_ntop4 (const struct sockaddr *sap,char *buf,const size_t buflen) {@@ -132,6 +155,8 @@ size_t rpc_ntop(const struct sockaddr *sap, char *buf, const size_t buflen)return rpc_ntop4 (sap, buf, buflen);case AF_INET6 :return rpc_ntop6 (sap, buf, buflen); +case AF_VSOCK : +return rpc_ntop_vsock (sap, buf, buflen); }return 0 ;@@ -229,6 +254,34 @@ static size_t rpc_pton6(struct net *net, const char *buf, const size_t buflen, }#endif +#ifdef CONFIG_SUNRPC_XPRT_VSOCK +static size_t rpc_pton_vsock (const char *buf,const size_t buflen, +struct sockaddr *sap,const size_t salen) +{ +const size_t prefix_len =strlen ("vsock:" ); +struct sockaddr_vm *svm = (struct sockaddr_vm *)sap; +unsigned int cid; + +if (strncmp (buf,"vsock:" , prefix_len) !=0 || + salen <sizeof (struct sockaddr_vm )) +return 0 ; + +if (kstrtouint (buf + prefix_len,10 , &cid) !=0 ) +return 0 ; + +memset (svm,0 ,sizeof (struct sockaddr_vm )); + svm->svm_family =AF_VSOCK ; + svm->svm_cid = cid; +return sizeof (struct sockaddr_vm ); +} +#else +static size_t rpc_pton_vsock (const char *buf,const size_t buflen, +struct sockaddr *sap,const size_t salen) +{ +return 0 ; +} +#endif +/** * rpc_pton - Construct a sockaddr in @sap * @net: applicable network namespace @@ -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); +for (i =0 ; i < buflen; i++)if (buf[i] ==':' )return rpc_pton6 (net, buf, buflen, sap, salen);Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Chuck Lever
Stefan Hajnoczi
maintainerRe: [PATCH v2 01/10] SUNRPC: add AF_VSOCK support to addr.[ch]
Quoted 6 lines · Chuck Lever
Quoted 6 lines · Stefan Hajnoczi
AF_VSOCKaddresses are a Context ID (CID) and port number tuple. The CID is a unique address, similar to a IP address on a local subnet.Extend the
addr.hfunctions to handleAF_VSOCKaddresses.
Thanks for your reply. A lot of these areas are covered in the presentation I gave at Connectathon 2016. Here is the link in case you're interested:
http://vmsplice.net/~stefan/stefanha-connectathon-2016.pdf
Replies to your questions below:
Quoted 4 lines
I'm wondering if there's a specification for how to construct the universal address form of an
AF_VSOCKaddress. This would be needed for populating anfs_locationsresponse, or for updating the NFS server's local rpcbind service.
The uaddr format I'm proposing is "vsock:cid.port". Both cid and port are unsigned 32-bit integers. The netid I'm proposing is "vsock".
Quoted 3 lines
A traditional NFS server employs IP-address based access control. How does that work with the new address family? Do you expect changes to mountd or exportfs?
Yes, the /etc/exports syntax I'm proposing is:
/srv/vm001 vsock:5(rw)
This allows CID 5 to access /srv/vm001. The CID is equivalent to an IP address.
This patch series only addresses the NFS client side but I will be sending nfsd and nfs-utils rpc.mountd patches once I've completed the work.
The way it works so far is that /proc/net/rpc/auth.unix.ip is extended to support not just IP but also vsock addresses. So the cache is separated by network address family (IP or vsock).
Quoted 3 lines
Is there a standard that defines the "vsock" netid? A new netid requires at least an IANA action. Is there a document that describes how RPC works with a VSOCK transport?
I haven't submitted a request to IANA yet. The RPC is the same as TCP (it uses the same Recording Marking to delimit boundaries in the stream).
Quoted 4 lines
This work appears to define two separate things: a new address family, and a new transport type. Wouldn't it be cleaner to dispense with the "proto=vsock" piece, and just support TCP over
AF_VSOCK(just as it works forAF_INETandAF_INET6) ?
Can you explain how this would simplify things? I don't think much of the code is transport-specific (the stream parsing is already shared with TCP). Most of the code is to add the new address family. AF_VSOCK already offers TCP-like semantics natively so no extra protocol is used on top.
Quoted 7 lines
At Connectathon, we discussed what happens when a guest is live-migrated to another host with a vsock-enabled NFSD. Essentially, the server at the known-local address would change identities and its content could be completely different. For instance, the file handles would all change, including the file handle of the export's root directory. Clients don't tolerate that especially well.
This issue remains. I looked into checkpoint-resume style TCP_REPAIR to allow existing connections to persist across migration but I hope a simpler approach can be taken.
Let's forget about AF_VSOCK, the problem is that an NFS client loses connectivity to the old server and must connect to the new server. We want to keep all state (open files, etc). Are configurations like that possible with Linux nfsd?
Quoted 3 lines
Can't a Docker-based or kvm-based guest simply mount one of the host's local file systems directly? What would be the value of inserting NFS into that picture?
The host cannot access a file system currently mounted by the guest and vice versa. NFS allows sharing of a file system between the host and one or more guests.
Re: [PATCH v2 01/10] SUNRPC: add AF_VSOCK support to addr.[ch]
Quoted 58 lines · Stefan Hajnoczi
Quoted 6 lines · Chuck Lever
Quoted 6 lines · Stefan Hajnoczi
AF_VSOCKaddresses are a Context ID (CID) and port number tuple. The CID is a unique address, similar to a IP address on a local subnet.Extend the
addr.hfunctions to handleAF_VSOCKaddresses.Thanks for your reply. A lot of these areas are covered in the presentation I gave at Connectathon 2016. Here is the link in case you're interested:
http://vmsplice.net/~stefan/stefanha-connectathon-2016.pdfReplies to your questions below:
Quoted 4 lines
I'm wondering if there's a specification for how to construct the universal address form of an
AF_VSOCKaddress. This would be needed for populating anfs_locationsresponse, or for updating the NFS server's local rpcbind service.The uaddr format I'm proposing is "vsock:cid.port". Both cid and port are unsigned 32-bit integers. The netid I'm proposing is "vsock".
Quoted 3 lines
A traditional NFS server employs IP-address based access control. How does that work with the new address family? Do you expect changes to mountd or exportfs?
Yes, the
/etc/exportssyntax I'm proposing is:
/srv/vm001vsock:5(rw)This allows CID 5 to access
/srv/vm001. The CID is equivalent to an IP address.This patch series only addresses the NFS client side but I will be sending nfsd and nfs-utils rpc.mountd patches once I've completed the work.
The way it works so far is that
/proc/net/rpc/auth.unix.ipis extended to support not just IP but also vsock addresses. So the cache is separated by network address family (IP or vsock).Quoted 3 lines
Is there a standard that defines the "vsock" netid? A new netid requires at least an IANA action. Is there a document that describes how RPC works with a VSOCK transport?
I haven't submitted a request to IANA yet. The RPC is the same as TCP (it uses the same Recording Marking to delimit boundaries in the stream).
Quoted 4 lines
This work appears to define two separate things: a new address family, and a new transport type. Wouldn't it be cleaner to dispense with the "proto=vsock" piece, and just support TCP over
AF_VSOCK(just as it works forAF_INETandAF_INET6) ?
Quoted 5 lines
Can you explain how this would simplify things? I don't think much of the code is transport-specific (the stream parsing is already shared with TCP). Most of the code is to add the new address family.
AF_VSOCKalready offers TCP-like semantics natively so no extra protocol is used on top.
If this really is just TCP on a new address family, then "tcpv" is more in line with previous work, and you can get away with just an IANA action for a new netid, since RPC-over-TCP is already specified.
Quoted 8 lines
Quoted 7 lines
At Connectathon, we discussed what happens when a guest is live-migrated to another host with a vsock-enabled NFSD. Essentially, the server at the known-local address would change identities and its content could be completely different. For instance, the file handles would all change, including the file handle of the export's root directory. Clients don't tolerate that especially well.
Quoted 8 lines
This issue remains. I looked into checkpoint-resume style
TCP_REPAIRto allow existing connections to persist across migration but I hope a simpler approach can be taken.Let's forget about
AF_VSOCK, the problem is that an NFS client loses connectivity to the old server and must connect to the new server. We want to keep all state (open files, etc). Are configurations like that possible with Linux nfsd?
You have two problems:
- OPEN and LOCK state would appear to vanish on the server. To recover
this state you would need an NFS server restart and grace period on the destination host to allow the client to use reclaiming OPENs.
- The FSID and filehandles would be different.
You could mandate fixed well-known filehandles and FSIDs, just as you are doing with the vsock addresses.
Or, implement NFSv4 migration in the Linux NFS server. Migrate the data and the VM at the same time, then the filehandles and state can come along for the ride, and no grace period is needed.
--
Chuck Lever
Re: [PATCH v2 01/10] SUNRPC: add AF_VSOCK support to addr.[ch]
In reply to Stefan HajnocziQuoted 216 lines · Stefan Hajnoczi
AF_VSOCKaddresses are a Context ID (CID) and port number tuple. The CID is a unique address, similar to a IP address on a local subnet.Extend the
addr.hfunctions to handleAF_VSOCKaddresses.Signed-off-by Stefan Hajnoczi <[email protected]>---
v2:
* ReplaceCONFIG_VSOCKETSwithCONFIG_SUNRPC_XPRT_VSOCKto prevent build failures when SUNRPC=y and VSOCKETS=m. Built-in code cannot link against code in a module.--- include/linux/sunrpc/addr.h | 44 ++++++++++++++++++++++++++++++++++ net/sunrpc/Kconfig | 10 ++++++++ net/sunrpc/addr.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+)include/linux/sunrpc/addr.h +44
-0@@ -10,6 +10,7 @@#include <linux/socket.h> #include <linux/in.h> #include <linux/in6.h> +#include <linux/vm_sockets.h> #include <net/ipv6.h> size_t rpc_ntop (const struct sockaddr *,char *,const size_t );@@ -26,6 +27,8 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)return ntohs (((struct sockaddr_in *)sap)->sin_port);case AF_INET6 :return ntohs (((struct sockaddr_in6 *)sap)->sin6_port); +case AF_VSOCK : +return ((struct sockaddr_vm *)sap)->svm_port; }return 0 ; }@@ -40,6 +43,9 @@ static inline void rpc_set_port(struct sockaddr *sap,case AF_INET6 : ((struct sockaddr_in6 *)sap)->sin6_port =htons (port);break ; +case AF_VSOCK : + ((struct sockaddr_vm *)sap)->svm_port = port; +break ; } }@@ -106,6 +112,40 @@ static inline bool __rpc_copy_addr6(struct sockaddr *dst, }#endif /* !(IS_ENABLED(CONFIG_IPV6) */ +#if IS_ENABLED (CONFIG_VSOCKETS ) +static inline bool rpc_cmp_vsock_addr (const struct sockaddr *sap1, +const struct sockaddr *sap2) +{ +const struct sockaddr_vm *svm1 = (const struct sockaddr_vm *)sap1; +const struct sockaddr_vm *svm2 = (const struct sockaddr_vm *)sap2; + +return svm1->svm_cid == svm2->svm_cid; +} + +static inline bool __rpc_copy_vsock_addr (struct sockaddr *dst, +const struct sockaddr *src) +{ +const struct sockaddr_vm *ssvm = (const struct sockaddr_vm *)src; +struct sockaddr_vm *dsvm = (struct sockaddr_vm *)dst; + + dsvm->svm_family = ssvm->svm_family; + dsvm->svm_cid = ssvm->svm_cid; +return true; +} +#else /* !(IS_ENABLED(CONFIG_VSOCKETS) */ +static inline bool rpc_cmp_vsock_addr (const struct sockaddr *sap1, +const struct sockaddr *sap2) +{ +return false; +} + +static inline bool __rpc_copy_vsock_addr (struct sockaddr *dst, +const struct sockaddr *src) +{ +return false; +} +#endif /* !(IS_ENABLED(CONFIG_VSOCKETS) */ +/** * rpc_cmp_addr - compare the address portion of two sockaddrs. * @sap1: first sockaddr @@ -125,6 +165,8 @@ static inline bool rpc_cmp_addr(const struct sockaddr *sap1,return rpc_cmp_addr4 (sap1, sap2);case AF_INET6 :return rpc_cmp_addr6 (sap1, sap2); +case AF_VSOCK : +return rpc_cmp_vsock_addr (sap1, sap2); } }return false;@@ -161,6 +203,8 @@ static inline bool rpc_copy_addr(struct sockaddr *dst,return __rpc_copy_addr4 (dst, src);case AF_INET6 :return __rpc_copy_addr6 (dst, src); +case AF_VSOCK : +return __rpc_copy_vsock_addr (dst, src); }return false; }net/sunrpc/Kconfig +10
-0@@ -61,3 +61,13 @@ config SUNRPC_XPRT_RDMA If unsure, or you know there is no RDMA capability on your hardware platform, say N. + +config SUNRPC_XPRT_VSOCK + bool "RPC-over-AF_VSOCK transport" + depends on SUNRPC && VSOCKETS && !(SUNRPC=y && VSOCKETS=m) + default SUNRPC && VSOCKETS + help + This option allows the NFS client and server to use the AF_VSOCK + transport to communicate between virtual machines and the host. + + If unsure, say Y.net/sunrpc/addr.c +53
-0@@ -16,11 +16,14 @@* RFC 4291, Section 2.2 for details on IPv6 presentation formats. */ +/* TODO register netid and uaddr with IANA? (See RFC 5665 5.1/5.2) */ +#include <net/ipv6.h> #include <linux/sunrpc/addr.h> #include <linux/sunrpc/msg_prot.h> #include <linux/slab.h> #include <linux/export.h> +#include <linux/vm_sockets.h> #if IS_ENABLED (CONFIG_IPV6 )@@ -108,6 +111,26 @@ static size_t rpc_ntop6(const struct sockaddr *sap,#endif /* !IS_ENABLED(CONFIG_IPV6) */ +#ifdef CONFIG_SUNRPC_XPRT_VSOCK + +static size_t rpc_ntop_vsock (const struct sockaddr *sap, +char *buf,const size_t buflen) +{ +const struct sockaddr_vm *svm = (struct sockaddr_vm *)sap; + +return snprintf (buf, buflen,"%u" , svm->svm_cid); +} + +#else /* !CONFIG_SUNRPC_XPRT_VSOCK */ + +static size_t rpc_ntop_vsock (const struct sockaddr *sap, +char *buf,const size_t buflen) +{ +return 0 ; +} + +#endif /* !CONFIG_SUNRPC_XPRT_VSOCK */ +static int rpc_ntop4 (const struct sockaddr *sap,char *buf,const size_t buflen) {@@ -132,6 +155,8 @@ size_t rpc_ntop(const struct sockaddr *sap, char *buf, const size_t buflen)return rpc_ntop4 (sap, buf, buflen);case AF_INET6 :return rpc_ntop6 (sap, buf, buflen); +case AF_VSOCK : +return rpc_ntop_vsock (sap, buf, buflen); }return 0 ;@@ -229,6 +254,34 @@ static size_t rpc_pton6(struct net *net, const char *buf, const size_t buflen, }#endif +#ifdef CONFIG_SUNRPC_XPRT_VSOCK +static size_t rpc_pton_vsock (const char *buf,const size_t buflen, +struct sockaddr *sap,const size_t salen) +{ +const size_t prefix_len =strlen ("vsock:" ); +struct sockaddr_vm *svm = (struct sockaddr_vm *)sap; +unsigned int cid; + +if (strncmp (buf,"vsock:" , prefix_len) !=0 || + salen <sizeof (struct sockaddr_vm )) +return 0 ; + +if (kstrtouint (buf + prefix_len,10 , &cid) !=0 ) +return 0 ; + +memset (svm,0 ,sizeof (struct sockaddr_vm )); + svm->svm_family =AF_VSOCK ; + svm->svm_cid = cid; +return sizeof (struct sockaddr_vm ); +} +#else +static size_t rpc_pton_vsock (const char *buf,const size_t buflen, +struct sockaddr *sap,const size_t salen) +{ +return 0 ; +} +#endif +/** * rpc_pton - Construct a sockaddr in @sap * @net: applicable network namespace
net/sunrpc/addr.c size_t rpc_pton(struct net *net, const char *buf, const size_t buflen, · line 308
Quoted 7 lines
net/sunrpc/addr.c +4
-0@@ -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.
Quoted 3 lines
net/sunrpc/addr.c +0
-0for (i =0 ; i < buflen; i++)if (buf[i] ==':' )return rpc_pton6 (net, buf, buflen, sap, salen);
Signature · 1 line
Jeff Layton <[email protected]>
Stefan Hajnoczi
maintainerRe: [PATCH v2 01/10] SUNRPC: add AF_VSOCK support to addr.[ch]
Quoted 5 lines · Jeff Layton
Quoted 4 lines · Stefan Hajnoczi
net/sunrpc/addr.c +0
-0@@ -249,6 +302,10 @@ size_t rpc_pton(struct net *net, const char *buf, const size_t buflen, {unsigned int i;
Quoted 7 lines
net/sunrpc/addr.c size_t rpc_pton(struct net *net, const char *buf, const size_t buflen, · line 308
Quoted 4 lines
net/sunrpc/addr.c +4
-0+/* 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:".
I am open to suggestions for a cleaner way of doing it though :).
Stefan
Re: [PATCH v2 01/10] SUNRPC: add AF_VSOCK support to addr.[ch]
Quoted 14 lines · Stefan Hajnoczi
Quoted 5 lines · Jeff Layton
Quoted 4 lines · Stefan Hajnoczi
net/sunrpc/addr.c +0
-0@@ -249,6 +302,10 @@ size_t rpc_pton(struct net *net, const char *buf, const size_t buflen, {unsigned int i;Quoted 7 lines
net/sunrpc/addr.c size_t rpc_pton(struct net *net, const char *buf, const size_t buflen, · line 308
Quoted 4 lines
net/sunrpc/addr.c +4
-0+/* 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.
Quoted 3 lines
There is no collision. This function doesn't do name resolution and no valid IPv4/IPv6 address starts with "vsock:".
Doh! Of course... :)
Quoted 1 line
I am open to suggestions for a cleaner way of doing it though :).
Does lsof recognize vsock sockets? How does it format them?
Signature · 1 line
Jeff Layton <[email protected]>
Stefan Hajnoczi
maintainerRe: [PATCH v2 01/10] SUNRPC: add AF_VSOCK support to addr.[ch]
Quoted 19 lines · Jeff Layton
Quoted 14 lines · Stefan Hajnoczi
Quoted 5 lines · Jeff Layton
Quoted 4 lines · Stefan Hajnoczi
net/sunrpc/addr.c +0
-0@@ -249,6 +302,10 @@ size_t rpc_pton(struct net *net, const char *buf, const size_t buflen, {unsigned int i;Quoted 7 lines
net/sunrpc/addr.c size_t rpc_pton(struct net *net, const char *buf, const size_t buflen, · line 308
Quoted 4 lines
net/sunrpc/addr.c +4
-0+/* 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.
Quoted 3 lines
There is no collision. This function doesn't do name resolution and no valid IPv4/IPv6 address starts with "vsock:".
Quoted 5 lines
Doh! Of course... :)
Quoted 1 line
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
Stefan Hajnoczi
maintainerPATCH v2 2/10 SUNRPC: rename "TCP" record parser to "stream" parser
In reply to Stefan HajnocziThe TCP record parser is really a RFC 1831 record fragment parser. There is nothing TCP protocol-specific about parsing record fragments. The parser can be reused for any SOCK_STREAM socket.
This patch renames functions and fields but xs_stream_data_ready() still calls tcp_read_sock(). This is addressed in the next patch.
--- include/linux/sunrpc/xprtsock.h | 31 ++--- include/trace/events/sunrpc.h | 28 ++--- net/sunrpc/xprtsock.c | 264 ++++++++++++++++++++-------------------- 3 files changed, 162 insertions(+), 161 deletions(-)
include/linux/sunrpc/xprtsock.h +16 -15
@@ -27,17 +27,18 @@ struct sock_xprt {struct sock * inet;/* -* State of TCP reply receive +* State of SOCK_STREAM reply receive */ -__be32 tcp_fraghdr, - tcp_xid, - tcp_calldir; +__be32 stream_fraghdr, + stream_xid, + stream_calldir; -u32 tcp_offset, - tcp_reclen; +u32 stream_offset, + stream_reclen; + +unsigned long stream_copied, + stream_flags; -unsigned long tcp_copied, - tcp_flags;/* * Connection of transports
@@ -67,17 +68,17 @@ struct sock_xprt {/* * TCP receive state flags */ -#define TCP_RCV_LAST_FRAG (1UL << 0) -#define TCP_RCV_COPY_FRAGHDR (1UL << 1) -#define TCP_RCV_COPY_XID (1UL << 2) -#define TCP_RCV_COPY_DATA (1UL << 3) -#define TCP_RCV_READ_CALLDIR (1UL << 4) -#define TCP_RCV_COPY_CALLDIR (1UL << 5) +#define STREAM_RCV_LAST_FRAG (1UL << 0) +#define STREAM_RCV_COPY_FRAGHDR (1UL << 1) +#define STREAM_RCV_COPY_XID (1UL << 2) +#define STREAM_RCV_COPY_DATA (1UL << 3) +#define STREAM_RCV_READ_CALLDIR (1UL << 4) +#define STREAM_RCV_COPY_CALLDIR (1UL << 5)/* * TCP RPC flags */ -#define TCP_RPC_REPLY (1UL << 6) +#define STREAM_RPC_REPLY (1UL << 6)#define XPRT_SOCK_CONNECTING 1U#define XPRT_SOCK_DATA_READY (2)
include/trace/events/sunrpc.h +14 -14
@@ -400,15 +400,15 @@ TRACE_EVENT(xs_tcp_data_ready,#define rpc_show_sock_xprt_flags (flags) \ __print_flags(flags, "|", \ - { TCP_RCV_LAST_FRAG, "TCP_RCV_LAST_FRAG" }, \ - { TCP_RCV_COPY_FRAGHDR, "TCP_RCV_COPY_FRAGHDR" }, \ - { TCP_RCV_COPY_XID, "TCP_RCV_COPY_XID" }, \ - { TCP_RCV_COPY_DATA, "TCP_RCV_COPY_DATA" }, \ - { TCP_RCV_READ_CALLDIR, "TCP_RCV_READ_CALLDIR" }, \ - { TCP_RCV_COPY_CALLDIR, "TCP_RCV_COPY_CALLDIR" }, \ - { TCP_RPC_REPLY, "TCP_RPC_REPLY" }) - -TRACE_EVENT(xs_tcp_data_recv, + { STREAM_RCV_LAST_FRAG, "STREAM_RCV_LAST_FRAG" }, \ + { STREAM_RCV_COPY_FRAGHDR, "STREAM_RCV_COPY_FRAGHDR" }, \ + { STREAM_RCV_COPY_XID, "STREAM_RCV_COPY_XID" }, \ + { STREAM_RCV_COPY_DATA, "STREAM_RCV_COPY_DATA" }, \ + { STREAM_RCV_READ_CALLDIR, "STREAM_RCV_READ_CALLDIR" }, \ + { STREAM_RCV_COPY_CALLDIR, "STREAM_RCV_COPY_CALLDIR" }, \ + { STREAM_RPC_REPLY, "STREAM_RPC_REPLY" }) + +TRACE_EVENT(xs_stream_data_recv, TP_PROTO(struct sock_xprt *xs), TP_ARGS(xs),
@@ -426,11 +426,11 @@ TRACE_EVENT(xs_tcp_data_recv,TP_fast_assign ( __assign_str(addr, xs->xprt.address_strings[RPC_DISPLAY_ADDR]);__assign_str (port, xs->xprt.address_strings[RPC_DISPLAY_PORT ]); - __entry->xid = xs->tcp_xid; - __entry->flags = xs->tcp_flags; - __entry->copied = xs->tcp_copied; - __entry->reclen = xs->tcp_reclen; - __entry->offset = xs->tcp_offset; + __entry->xid = xs->stream_xid; + __entry->flags = xs->stream_flags; + __entry->copied = xs->stream_copied; + __entry->reclen = xs->stream_reclen; + __entry->offset = xs->stream_offset; ), TP_printk("peer=[%s]:%s xid=0x%x flags=%s copied=%lu reclen=%u offset=%lu",
net/sunrpc/xprtsock.c +132 -132
488 lines not on this page · raw message
Signature · 1 line
2.7.4
Stefan Hajnoczi
maintainerPATCH v2 3/10 SUNRPC: abstract tcp_read_sock() in record fragment parser
In reply to Stefan HajnocziUse a function pointer to abstract tcp_read_sock()-like functions. For TCP this function will be tcp_read_sock(). For AF_VSOCK it will be vsock_read_sock().
--- include/linux/sunrpc/xprtsock.h | 5 +++++ net/sunrpc/xprtsock.c | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)
include/linux/sunrpc/xprtsock.h +5 -0
@@ -9,6 +9,8 @@#ifdef __KERNEL__ +#include <net/tcp.h> /* for sk_read_actor_t */ +int init_socket_xprt (void );void cleanup_socket_xprt (void );
@@ -39,6 +41,9 @@ struct sock_xprt {unsigned long stream_copied, stream_flags; +int (*stream_read_sock)(struct sock *, +read_descriptor_t *, +sk_read_actor_t );/* * Connection of transports
net/sunrpc/xprtsock.c +8 -6
@@ -1493,7 +1493,7 @@ static int xs_stream_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,return len - desc.count; } -static void xs_tcp_data_receive (struct sock_xprt *transport) +static void xs_stream_data_receive (struct sock_xprt *transport) {struct rpc_xprt *xprt = &transport->xprt;struct sock *sk;
@@ -1509,10 +1509,11 @@ static void xs_tcp_data_receive(struct sock_xprt *transport)if (sk ==NULL ) goto out; -/* We use rd_desc to pass struct xprt to xs_tcp_data_recv */ +/* We use rd_desc to pass struct xprt to xs_stream_data_recv */ for (;;) {lock_sock (sk); - read =tcp_read_sock (sk, &rd_desc, xs_stream_data_recv); + read = transport->stream_read_sock (sk, &rd_desc, + xs_stream_data_recv);if (read <=0 ) {clear_bit (XPRT_SOCK_DATA_READY , &transport->sock_state);release_sock (sk);
@@ -1529,11 +1530,11 @@ out:trace_xs_tcp_data_ready (xprt, read, total); } -static void xs_tcp_data_receive_workfn (struct work_struct *work) +static void xs_stream_data_receive_workfn (struct work_struct *work) {struct sock_xprt *transport = container_of(work, struct sock_xprt, recv_worker); -xs_tcp_data_receive (transport); +xs_stream_data_receive (transport); }/**
@@ -1569,6 +1570,7 @@ static void xs_tcp_state_change(struct sock *sk) transport->stream_copied =0 ; transport->stream_flags =STREAM_RCV_COPY_FRAGHDR |STREAM_RCV_COPY_XID ; + transport->stream_read_sock = tcp_read_sock; xprt->connect_cookie++;clear_bit (XPRT_SOCK_CONNECTING , &transport->sock_state);xprt_clear_connecting (xprt);
@@ -2995,7 +2997,7 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) xprt->max_reconnect_timeout = xprt->timeout->to_maxval; -INIT_WORK (&transport->recv_worker, xs_tcp_data_receive_workfn); +INIT_WORK (&transport->recv_worker, xs_stream_data_receive_workfn);INIT_DELAYED_WORK (&transport->connect_worker, xs_tcp_setup_socket);switch (addr->sa_family) {
Signature · 1 line
2.7.4
Stefan Hajnoczi
maintainerPATCH v2 4/10 SUNRPC: extract xs_stream_reset_state()
In reply to Stefan HajnocziExtract a function to reset the record fragment parser.
--- net/sunrpc/xprtsock.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-)
net/sunrpc/xprtsock.c +23 -8
@@ -1538,6 +1538,28 @@ static void xs_stream_data_receive_workfn(struct work_struct *work) }/** +* xs_stream_reset_state - reset SOCK_STREAM record parser +* @transport: socket transport +* @read_sock: tcp_read_sock()-like function +* +*/ +static void xs_stream_reset_state (struct rpc_xprt *xprt, +int (*read_sock)(struct sock *, +read_descriptor_t *, +sk_read_actor_t )) +{ +struct sock_xprt *transport =container_of (xprt, + struct sock_xprt, xprt); + + transport->stream_offset =0 ; + transport->stream_reclen =0 ; + transport->stream_copied =0 ; + transport->stream_flags = +STREAM_RCV_COPY_FRAGHDR |STREAM_RCV_COPY_XID ; + transport->stream_read_sock = read_sock; +} + +/** * xs_tcp_state_change - callback to handle TCP socket state changes * @sk: socket whose state has changed *
@@ -1563,14 +1585,7 @@ static void xs_tcp_state_change(struct sock *sk)case TCP_ESTABLISHED :spin_lock (&xprt->transport_lock);if (!xprt_test_and_set_connected (xprt)) { - -/* Reset stream record info */ - transport->stream_offset =0 ; - transport->stream_reclen =0 ; - transport->stream_copied =0 ; - transport->stream_flags = -STREAM_RCV_COPY_FRAGHDR |STREAM_RCV_COPY_XID ; - transport->stream_read_sock = tcp_read_sock; +xs_stream_reset_state (xprt, tcp_read_sock); xprt->connect_cookie++;clear_bit (XPRT_SOCK_CONNECTING , &transport->sock_state);xprt_clear_connecting (xprt);
Signature · 1 line
2.7.4
Stefan Hajnoczi
maintainerPATCH v2 5/10 VSOCK: add tcp_read_sock()-like vsock_read_sock() function
In reply to Stefan HajnocziThe tcp_read_sock() interface dequeues skbs and gives them to the caller's callback function for processing. This interface can avoid data copies since the caller accesses the skb instead of using its own receive buffer.
This patch implements vsock_read_sock() for AF_VSOCK SOCK_STREAM sockets. The implementation is only for virtio-vsock at this time, not for the VMware VMCI transport. It is not zero-copy yet because the virtio-vsock receive queue does not consist of skbs.
The tcp_read_sock()-like interface is needed for AF_VSOCK sunrpc support.
--- drivers/vhost/vsock.c | 1 + include/linux/virtio_vsock.h | 4 ++ include/net/af_vsock.h | 5 +++ net/vmw_vsock/af_vsock.c | 16 ++++++++ net/vmw_vsock/virtio_transport.c | 1 + net/vmw_vsock/virtio_transport_common.c | 66 +++++++++++++++++++++++++++++++++ net/vmw_vsock/vmci_transport.c | 8 ++++ 7 files changed, 101 insertions(+)
drivers/vhost/vsock.c +1 -0
@@ -677,6 +677,7 @@ static struct virtio_transport vhost_transport = { .stream_rcvhiwat = virtio_transport_stream_rcvhiwat, .stream_is_active = virtio_transport_stream_is_active, .stream_allow = virtio_transport_stream_allow, + .stream_read_sock = virtio_transport_stream_read_sock, .notify_poll_in = virtio_transport_notify_poll_in, .notify_poll_out = virtio_transport_notify_poll_out,
include/linux/virtio_vsock.h +4 -0
@@ -5,6 +5,7 @@#include <linux/socket.h> #include <net/sock.h> #include <net/af_vsock.h> +#include <net/tcp.h> /* for sk_read_actor_t */ #define VIRTIO_VSOCK_DEFAULT_MIN_BUF_SIZE 128#define VIRTIO_VSOCK_DEFAULT_BUF_SIZE (1024 * 256)
@@ -123,6 +124,9 @@ int virtio_transport_notify_send_post_enqueue(struct vsock_sock *vsk,u64 virtio_transport_stream_rcvhiwat (struct vsock_sock *vsk);bool virtio_transport_stream_is_active (struct vsock_sock *vsk);bool virtio_transport_stream_allow (u32 cid,u32 port); +int virtio_transport_stream_read_sock (struct vsock_sock *vsk, +read_descriptor_t *desc, +sk_read_actor_t recv_actor);int virtio_transport_dgram_bind (struct vsock_sock *vsk,struct sockaddr_vm *addr);bool virtio_transport_dgram_allow (u32 cid,u32 port);
include/net/af_vsock.h +5 -0
@@ -19,6 +19,7 @@#include <linux/kernel.h> #include <linux/workqueue.h> #include <linux/vm_sockets.h> +#include <net/tcp.h> /* for sk_read_actor_t */ #include "vsock_addr.h"
@@ -73,6 +74,8 @@ struct vsock_sock {void *trans; }; +int vsock_read_sock (struct sock *sk,read_descriptor_t *desc, +sk_read_actor_t recv_actor);s64 vsock_stream_has_data (struct vsock_sock *vsk);s64 vsock_stream_has_space (struct vsock_sock *vsk);void vsock_pending_work (struct work_struct *work);
@@ -122,6 +125,8 @@ struct vsock_transport {u64 (*stream_rcvhiwat)(struct vsock_sock *);bool (*stream_is_active)(struct vsock_sock *);bool (*stream_allow)(u32 cid,u32 port); +int (*stream_read_sock)(struct vsock_sock *,read_descriptor_t *desc, +sk_read_actor_t recv_actor);/* Notification. */ int (*notify_poll_in)(struct vsock_sock *,size_t ,bool *);
net/vmw_vsock/af_vsock.c +16 -0
@@ -705,6 +705,22 @@ static void vsock_sk_destruct(struct sock *sk)put_cred (vsk->owner); } +/* See documentation for tcp_read_sock() */ +int vsock_read_sock (struct sock *sk,read_descriptor_t *desc, +sk_read_actor_t recv_actor) +{ +struct vsock_sock *vsp =vsock_sk (sk); + +if (sk->sk_type !=SOCK_STREAM ) +return -EOPNOTSUPP ; + +if (sk->sk_state !=SS_CONNECTED && sk->sk_state !=SS_DISCONNECTING ) +return -ENOTCONN ; + +return transport->stream_read_sock (vsp, desc, recv_actor); +} +EXPORT_SYMBOL (vsock_read_sock); +static int vsock_queue_rcv_skb (struct sock *sk,struct sk_buff *skb) {int err;
net/vmw_vsock/virtio_transport.c +1 -0
@@ -432,6 +432,7 @@ static struct virtio_transport virtio_transport = { .stream_rcvhiwat = virtio_transport_stream_rcvhiwat, .stream_is_active = virtio_transport_stream_is_active, .stream_allow = virtio_transport_stream_allow, + .stream_read_sock = virtio_transport_stream_read_sock, .notify_poll_in = virtio_transport_notify_poll_in, .notify_poll_out = virtio_transport_notify_poll_out,
net/vmw_vsock/virtio_transport_common.c +66 -0
72 lines not on this page · raw message
net/vmw_vsock/vmci_transport.c +8 -0
@@ -654,6 +654,13 @@ static bool vmci_transport_stream_allow(u32 cid, u32 port)return true; } +static int vmci_transport_stream_read_sock (struct vsock_sock *vsk, +read_descriptor_t *desc, +sk_read_actor_t recv_actor) +{ +return -EOPNOTSUPP ;/* not yet implemented */ +} +/* This is invoked as part of a tasklet that's scheduled when the VMCI * interrupt fires. This is run in bottom-half context but it defers most of * its work to the packet handling work queue.
@@ -2069,6 +2076,7 @@ static const struct vsock_transport vmci_transport = { .stream_rcvhiwat = vmci_transport_stream_rcvhiwat, .stream_is_active = vmci_transport_stream_is_active, .stream_allow = vmci_transport_stream_allow, + .stream_read_sock = vmci_transport_stream_read_sock, .notify_poll_in = vmci_transport_notify_poll_in, .notify_poll_out = vmci_transport_notify_poll_out, .notify_recv_init = vmci_transport_notify_recv_init,
Signature · 1 line
2.7.4
Stefan Hajnoczi
maintainerPATCH v2 6/10 SUNRPC: add AF_VSOCK support to xprtsock.c
In reply to Stefan Hajnoczi--- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/xprtsock.c | 385 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 381 insertions(+), 5 deletions(-)
include/linux/sunrpc/xprt.h +1 -0
@@ -165,6 +165,7 @@ enum xprt_transports {XPRT_TRANSPORT_RDMA =256 ,XPRT_TRANSPORT_BC_RDMA =XPRT_TRANSPORT_RDMA |XPRT_TRANSPORT_BC ,XPRT_TRANSPORT_LOCAL =257 , + XPRT_TRANSPORT_VSOCK = 258, }; struct rpc_xprt {
net/sunrpc/xprtsock.c +380 -5
468 lines not on this page · raw message
Signature · 1 line
2.7.4
Stefan Hajnoczi
maintainerPATCH v2 7/10 SUNRPC: drop unnecessary svc_bc_tcp_create() helper
In reply to Stefan Hajnoczisvc_bc_tcp_create() is a helper function that simply calls svc_bc_create_socket() with an added IPPROTO_TCP argument.
svc_bc_create_socket() then checks that the protocol argument is indeed IPPROTO_TCP.
This isn't necessary since svc_bc_tcp_create() is the only svc_bc_create_socket() caller. The next patch adds a second caller for AF_VSOCK where IPPROTO_TCP will not be used.
Scrap this scheme and just call svc_bc_create_socket() directly.
--- net/sunrpc/svcsock.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
net/sunrpc/svcsock.c +3 -18
@@ -70,7 +70,7 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *, int, struct net *, struct sockaddr *, int, int);#if defined(CONFIG_SUNRPC_BACKCHANNEL ) -static struct svc_xprt *svc_bc_create_socket (struct svc_serv *,int , +static struct svc_xprt *svc_bc_create_socket (struct svc_serv *,struct net *,struct sockaddr *,int ,int );static void svc_bc_sock_free (struct svc_xprt *xprt);
@@ -1180,25 +1180,17 @@ static struct svc_xprt *svc_tcp_create(struct svc_serv *serv, }#if defined(CONFIG_SUNRPC_BACKCHANNEL ) -static struct svc_xprt *svc_bc_create_socket (struct svc_serv *,int , +static struct svc_xprt *svc_bc_create_socket (struct svc_serv *,struct net *,struct sockaddr *,int ,int );static void svc_bc_sock_free (struct svc_xprt *xprt); -static struct svc_xprt *svc_bc_tcp_create (struct svc_serv *serv, -struct net *net, -struct sockaddr *sa,int salen, -int flags) -{ -return svc_bc_create_socket (serv,IPPROTO_TCP , net, sa, salen, flags); -} -static void svc_bc_tcp_sock_detach (struct svc_xprt *xprt) { }static struct svc_xprt_ops svc_tcp_bc_ops = { - .xpo_create = svc_bc_tcp_create, + .xpo_create = svc_bc_create_socket, .xpo_detach = svc_bc_tcp_sock_detach, .xpo_free = svc_bc_sock_free, .xpo_prep_reply_hdr = svc_tcp_prep_reply_hdr,
@@ -1581,7 +1573,6 @@ static void svc_sock_free(struct svc_xprt *xprt)* Create a back channel svc_xprt which shares the fore channel socket. */ static struct svc_xprt *svc_bc_create_socket (struct svc_serv *serv, -int protocol,struct net *net,struct sockaddr *sin,int len,int flags)
@@ -1589,12 +1580,6 @@ static struct svc_xprt *svc_bc_create_socket(struct svc_serv *serv,struct svc_sock *svsk;struct svc_xprt *xprt; -if (protocol !=IPPROTO_TCP ) { -printk (KERN_WARNING "svc: only TCP sockets" -" supported on shared back channel\n" ); -return ERR_PTR (-EINVAL ); - } - svsk =kzalloc (sizeof (*svsk),GFP_KERNEL );if (!svsk)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.7.4
Stefan Hajnoczi
maintainerPATCH v2 8/10 SUNRPC: add AF_VSOCK support to svc_xprt.c
In reply to Stefan HajnocziAllow creation of AF_VSOCK service xprts. This is needed for the "vsock-bc" backchannel.
--- include/linux/sunrpc/svc_xprt.h | 12 ++++++++++++ net/sunrpc/svc_xprt.c | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+)
include/linux/sunrpc/svc_xprt.h +12 -0
@@ -8,6 +8,7 @@#define SUNRPC_SVC_XPRT_H #include <linux/sunrpc/svc.h> +#include <linux/vm_sockets.h> struct module ;
@@ -153,12 +154,15 @@ static inline unsigned short svc_addr_port(const struct sockaddr *sa) {const struct sockaddr_in *sin = (const struct sockaddr_in *)sa;const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sa; +const struct sockaddr_vm *svm = (const struct sockaddr_vm *)sa;switch (sa->sa_family) {case AF_INET :return ntohs (sin->sin_port);case AF_INET6 :return ntohs (sin6->sin6_port); +case AF_VSOCK : +return svm->svm_port; }return 0 ;
@@ -171,6 +175,8 @@ static inline size_t svc_addr_len(const struct sockaddr *sa)return sizeof (struct sockaddr_in );case AF_INET6 :return sizeof (struct sockaddr_in6 ); +case AF_VSOCK : +return sizeof (struct sockaddr_vm ); }BUG (); }
@@ -190,6 +196,7 @@ static inline char *__svc_print_addr(const struct sockaddr *addr, {const struct sockaddr_in *sin = (const struct sockaddr_in *)addr;const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)addr; +const struct sockaddr_vm *svm = (const struct sockaddr_vm *)addr;switch (addr->sa_family) {case AF_INET :
@@ -203,6 +210,11 @@ static inline char *__svc_print_addr(const struct sockaddr *addr, ntohs(sin6->sin6_port));break ; +case AF_VSOCK : +snprintf (buf, len,"%u, port=%u" , + svm->svm_cid, svm->svm_port); +break ; +default :snprintf (buf, len,"unknown address type: %d" , addr->sa_family);break ;
net/sunrpc/svc_xprt.c +18 -0
@@ -10,6 +10,7 @@#include <linux/kthread.h> #include <linux/slab.h> #include <net/sock.h> +#include <net/af_vsock.h> #include <linux/sunrpc/addr.h> #include <linux/sunrpc/stats.h> #include <linux/sunrpc/svc_xprt.h>
@@ -195,6 +196,13 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl, .sin6_port = htons(port), };#endif +#ifdef CONFIG_SUNRPC_XPRT_VSOCK +struct sockaddr_vm svm = { + .svm_family =AF_VSOCK , + .svm_cid =VMADDR_CID_ANY , + .svm_port = port, + }; +#endif struct sockaddr *sap;size_t len;
@@ -209,6 +217,12 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl, len =sizeof (sin6);break ;#endif +#ifdef CONFIG_SUNRPC_XPRT_VSOCK +case AF_VSOCK : + sap = (struct sockaddr *)&svm; + len =sizeof (svm); +break ; +#endif default :return ERR_PTR (-EAFNOSUPPORT ); }
@@ -595,6 +609,10 @@ int svc_port_is_privileged(struct sockaddr *sin)case AF_INET6 :return ntohs (((struct sockaddr_in6 *)sin)->sin6_port) <PROT_SOCK ; +case AF_VSOCK : +return ((struct sockaddr_vm *)sin)->svm_port <= +LAST_RESERVED_PORT ; +default :return 0 ; }
Signature · 1 line
2.7.4
Stefan Hajnoczi
maintainerPATCH v2 9/10 SUNRPC: add AF_VSOCK backchannel support
In reply to Stefan Hajnoczi--- net/sunrpc/svcsock.c | 27 +++++++++++++++++++++++++++ net/sunrpc/xprtsock.c | 25 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+)
net/sunrpc/svcsock.c +27 -0
@@ -1204,14 +1204,41 @@ static struct svc_xprt_class svc_tcp_bc_class = { .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP, }; +#ifdef CONFIG_SUNRPC_XPRT_VSOCK +static void svc_bc_vsock_sock_detach (struct svc_xprt *xprt) +{ +} + +static struct svc_xprt_ops svc_vsock_bc_ops = { + .xpo_create = svc_bc_create_socket, + .xpo_detach = svc_bc_vsock_sock_detach, + .xpo_free = svc_bc_sock_free, + .xpo_prep_reply_hdr = svc_tcp_prep_reply_hdr, + .xpo_secure_port = svc_sock_secure_port, +}; + +static struct svc_xprt_class svc_vsock_bc_class = { + .xcl_name ="vsock-bc" , + .xcl_owner =THIS_MODULE , + .xcl_ops = &svc_vsock_bc_ops, + .xcl_max_payload =RPCSVC_MAXPAYLOAD , +}; +#endif /* CONFIG_SUNRPC_XPRT_VSOCK */ +static void svc_init_bc_xprt_sock (void ) {svc_reg_xprt_class (&svc_tcp_bc_class); +#ifdef CONFIG_SUNRPC_XPRT_VSOCK +svc_reg_xprt_class (&svc_vsock_bc_class); +#endif }static void svc_cleanup_bc_xprt_sock (void ) {svc_unreg_xprt_class (&svc_tcp_bc_class); +#ifdef CONFIG_SUNRPC_XPRT_VSOCK +svc_unreg_xprt_class (&svc_vsock_bc_class); +#endif }#else /* CONFIG_SUNRPC_BACKCHANNEL */ static void svc_init_bc_xprt_sock (void )
net/sunrpc/xprtsock.c +25 -0
@@ -1416,6 +1416,24 @@ static size_t xs_tcp_bc_maxpayload(struct rpc_xprt *xprt) {return PAGE_SIZE ; } + +#ifdef CONFIG_SUNRPC_XPRT_VSOCK +static int xs_vsock_bc_up (struct svc_serv *serv,struct net *net) +{ +int ret; + + ret =svc_create_xprt (serv,"vsock-bc" , net,AF_VSOCK ,0 , +SVC_SOCK_ANONYMOUS ); +if (ret <0 ) +return ret; +return 0 ; +} + +static size_t xs_vsock_bc_maxpayload (struct rpc_xprt *xprt) +{ +return PAGE_SIZE ; +} +#endif /* !CONFIG_SUNRPC_XPRT_VSOCK */ #else static inline int _xs_stream_read_data (struct rpc_xprt *xprt,struct xdr_skb_reader *desc)
@@ -3424,6 +3442,13 @@ static struct rpc_xprt_ops xs_vsock_ops = { .close = xs_tcp_shutdown, .destroy = xs_destroy, .print_stats = xs_vsock_print_stats, +#ifdef CONFIG_SUNRPC_BACKCHANNEL + .bc_setup = xprt_setup_bc, + .bc_up = xs_vsock_bc_up, + .bc_maxpayload = xs_vsock_bc_maxpayload, + .bc_free_rqst = xprt_free_bc_rqst, + .bc_destroy = xprt_destroy_bc, +#endif }; static const struct rpc_timeout xs_vsock_default_timeout = {
Signature · 1 line
2.7.4
Stefan Hajnoczi
maintainerPATCH v2 10/10 NFS: add AF_VSOCK support to NFS client
In reply to Stefan HajnocziThis patch adds AF_VSOCK to the NFS client. Mounts can now use the "vsock" proto option and pass "vsock:<cid>" address strings, which are interpreted by sunrpc for xprt creation.
--- fs/nfs/client.c | 2 ++ fs/nfs/super.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
fs/nfs/client.c +2 -0
@@ -35,6 +35,7 @@#include <linux/vfs.h> #include <linux/inet.h> #include <linux/in6.h> +#include <linux/vm_sockets.h> #include <linux/slab.h> #include <linux/idr.h> #include <net/ipv6.h>
@@ -434,6 +435,7 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto,switch (proto) {case XPRT_TRANSPORT_TCP :case XPRT_TRANSPORT_RDMA : +case XPRT_TRANSPORT_VSOCK :if (retrans ==NFS_UNSPEC_RETRANS ) to->to_retries =NFS_DEF_TCP_RETRANS ;if (timeo ==NFS_UNSPEC_TIMEO || to->to_retries ==0 )
fs/nfs/super.c +10 -1
@@ -191,7 +191,7 @@ static const match_table_t nfs_mount_option_tokens = {enum { Opt_xprt_udp, Opt_xprt_udp6, Opt_xprt_tcp, Opt_xprt_tcp6, Opt_xprt_rdma, - Opt_xprt_rdma6, + Opt_xprt_rdma6, Opt_xprt_vsock, Opt_xprt_err };
@@ -203,6 +203,7 @@ static const match_table_t nfs_xprt_protocol_tokens = { { Opt_xprt_tcp6, "tcp6" }, { Opt_xprt_rdma, "rdma" }, { Opt_xprt_rdma6, "rdma6" }, + { Opt_xprt_vsock, "vsock" }, { Opt_xprt_err, NULL } };
@@ -971,6 +972,8 @@ static int nfs_verify_server_address(struct sockaddr *addr)struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr;return !ipv6_addr_any (sa); } +case AF_VSOCK : +return 1 ; }dfprintk (MOUNT ,"NFS: Invalid IP address specified\n" );
@@ -1000,6 +1003,7 @@ static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt)case XPRT_TRANSPORT_UDP :case XPRT_TRANSPORT_TCP :case XPRT_TRANSPORT_RDMA : +case XPRT_TRANSPORT_VSOCK :break ;default : mnt->nfs_server.protocol =XPRT_TRANSPORT_TCP ;
@@ -1481,6 +1485,11 @@ static int nfs_parse_mount_options(char *raw, mnt->nfs_server.protocol =XPRT_TRANSPORT_RDMA ;xprt_load_transport (string);break ; +case Opt_xprt_vsock: + protofamily =AF_VSOCK ; + mnt->flags &= ~NFS_MOUNT_TCP ; + mnt->nfs_server.protocol =XPRT_TRANSPORT_VSOCK ; +break ;default :dfprintk (MOUNT ,"NFS: unrecognized " "transport protocol\n" );
Signature · 1 line
2.7.4
So basically you're creating a new (Red Hat) Linux-only wormhole which bypasses all network security between VM host and guest and needs extra work&thought&tool support (wireshark, valgrind, ...) to handle, trace, debug, monitor and secure?
Ced
Quoted 112 lines · Stefan Hajnoczi
This patch series enables
AF_VSOCKaddress family support in the NFS client. You can also get the commits from the vsock-nfs branch at
https://github.com/stefanha/linux.git.The
AF_VSOCKaddress family provides dgram and stream socket communication between virtual machines and hypervisors. VMware VMCI and virtio (for KVM) transports are available, seenet/vmw_vsock.The goal of this work is sharing files between virtual machines and hypervisors.
AF_VSOCKis well-suited to this because it requires no configuration inside the virtual machine, making it simple to manage and reliable.Why NFS over
AF_VSOCK?
----------------------
It is unusual to add a new NFS transport, only TCP, RDMA, and UDP are currently supported. Here is the rationale for addingAF_VSOCK.Sharing files with a virtual machine can be configured manually:
1. Add a dedicated network card to the virtual machine. It will be used for NFS traffic.
2. Configure a local subnet and assign IP addresses to the virtual machine and hypervisor
3. Configure an NFS export on the hypervisor and start the NFS server
4. Mount the export inside the virtual machineAutomating these steps poses a problem: modifying network configuration inside the virtual machine is invasive. It's hard to add a network interface to an arbitrary running system in an automated fashion, considering the network management tools, firewall rules, IP address usage, etc.
Furthermore, the user may disrupt file sharing by accident when they add firewall rules, restart networking, etc because the NFS network interface is visible alongside the network interfaces managed by the user.
AF_VSOCKis a zero-configuration network transport that avoids these problems. Adding it to a virtual machine is non-invasive. It also avoids accidental misconfiguration by the user. This is why "guest agents" and other services in various hypervisors (KVM, Xen, VMware, VirtualBox) do not use regular network interfaces.This is why
AF_VSOCKis appropriate for providing shared files as a hypervisor service.The approach in this series
---------------------------AF_VSOCKstream sockets can be used for NFSv4.1 much in the same way as TCP. RFC 1831 record fragments divide messages sinceSOCK_STREAMsemantics are present. The backchannel shares the connection just like the default TCP configuration.Addresses are <Context ID, Port Number> pairs. These patches use "vsock:<cid>" string representation to distinguish
AF_VSOCKaddresses from IPv4 and IPv6 numeric addresses.The following example mounts /export from the hypervisor (CID 2) inside the virtual machine (CID 3):
# /sbin/mount.nfs 2:/export /mnt -o clientaddr=3,proto=vsockPlease see the nfs-utils patch series I have just sent to [email protected] for the necessary patches.
Status
------
The virtio-vsock transport was merged in Linux 4.8 and the vhost-vsock-pci device is available in QEMU git master. This means the underlyingAF_VSOCKtransport for KVM is now available upstream.I have begun work on nfsd support in the kernel and nfs-utils. This is not complete yet and will be sent as separate patch series.
Stefan Hajnoczi (10):
SUNRPC: addAF_VSOCKsupport to addr.[ch]
SUNRPC: rename "TCP" record parser to "stream" parser
SUNRPC: abstracttcp_read_sock()in record fragment parser
SUNRPC: extractxs_stream_reset_state()
VSOCK: add tcp_read_sock()-likevsock_read_sock()function
SUNRPC: addAF_VSOCKsupport toxprtsock.c
SUNRPC: drop unnecessarysvc_bc_tcp_create()helper
SUNRPC: addAF_VSOCKsupport tosvc_xprt.c
SUNRPC: addAF_VSOCKbackchannel support
NFS: addAF_VSOCKsupport to NFS clientdrivers/vhost/vsock.c | 1 + fs/nfs/client.c | 2 + fs/nfs/super.c | 11 +- include/linux/sunrpc/addr.h | 44 ++ include/linux/sunrpc/svc_xprt.h | 12 + include/linux/sunrpc/xprt.h | 1 + include/linux/sunrpc/xprtsock.h | 36 +- include/linux/virtio_vsock.h | 4 + include/net/af_vsock.h | 5 + include/trace/events/sunrpc.h | 28 +- net/sunrpc/Kconfig | 10 + net/sunrpc/addr.c | 57 +++ net/sunrpc/svc_xprt.c | 18 + net/sunrpc/svcsock.c | 48 ++- net/sunrpc/xprtsock.c | 703 +++++++++++++++++++++++++------- net/vmw_vsock/af_vsock.c | 16 + net/vmw_vsock/virtio_transport.c | 1 + net/vmw_vsock/virtio_transport_common.c | 66 +++ net/vmw_vsock/vmci_transport.c | 8 + 19 files changed, 880 insertions(+), 191 deletions(-)--
2.7.4--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Cedric Blancher <[email protected]> [https://plus.google.com/u/0/+CedricBlancher/] Institute Pasteur
Stefan Hajnoczi
maintainerQuoted 4 lines · Cedric Blancher
So basically you're creating a new (Red Hat) Linux-only wormhole which bypasses all network security between VM host and guest and needs extra work&thought&tool support (wireshark, valgrind, ...) to handle, trace, debug, monitor and secure?
vsock is not Linux-only and not Red Hat-only. There are two paravirtualized hardware interfaces (VMware VMCI and KVM's virtio-vsock). Drivers for other operating systems exist and can be written for OSes that are not yet supported. The virtio-vsock spec is public.
Regarding bypassing network security, this is a non-routable guest<->host protocol. It is very locked down by design.
You can simply not use the device if you prefer to go inside the guest and configure a traditional NFS TCP/IP setup instead. As mentioned in the cover letter, that is not feasible for cloud providers and other scenarios where reaching inside the guest isn't allowed.
Quoted 7 lines · Stefan Hajnoczi
Quoted 4 lines · Cedric Blancher
So basically you're creating a new (Red Hat) Linux-only wormhole which bypasses all network security between VM host and guest and needs extra work&thought&tool support (wireshark, valgrind, ...) to handle, trace, debug, monitor and secure?
vsock is not Linux-only and not Red Hat-only.
This is clearly Red Hat only. Debian and Ubuntu folks already have rejected this out of security concerns, so why are you pressing this? Where is support for other operating systems, like Windows, FreeBSD or Solaris/Illumos?
Ced
Signature · 3 lines
Cedric Blancher <[email protected]> [https://plus.google.com/u/0/+CedricBlancher/] Institute Pasteur
Stefan Hajnoczi
maintainerQuoted 11 lines · Cedric Blancher
Quoted 7 lines · Stefan Hajnoczi
Quoted 4 lines · Cedric Blancher
So basically you're creating a new (Red Hat) Linux-only wormhole which bypasses all network security between VM host and guest and needs extra work&thought&tool support (wireshark, valgrind, ...) to handle, trace, debug, monitor and secure?
vsock is not Linux-only and not Red Hat-only.
This is clearly Red Hat only. Debian and Ubuntu folks already have rejected this out of security concerns, so why are you pressing this?
Are you aware that Debian ships the vsock.ko and
vmw_vsock_vmci_transport.ko kernel modules?
https://packages.debian.org/jessie/amd64/linux-image-3.16.0-4-amd64/filelist
Do you have a URL regarding virtio-vsock in Debian and Ubuntu? There was no discussion upstream in QEMU or Linux that I can recall.
Stefan