Message ID | 20201204170235.84387-4-andraprs@amazon.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | vsock: Add flags field in the vsock address | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 18 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Fri, Dec 04, 2020 at 07:02:34PM +0200, Andra Paraschiv wrote: >The vsock flags can be set during the connect() setup logic, when >initializing the vsock address data structure variable. Then the vsock >transport is assigned, also considering this flags field. > >The vsock transport is also assigned on the (listen) receive path. The >flags field needs to be set considering the use case. > >Set the value of the vsock flags of the remote address to the one >targeted for packets forwarding to the host, if the following conditions >are met: > >* The source CID of the packet is higher than VMADDR_CID_HOST. >* The destination CID of the packet is higher than VMADDR_CID_HOST. > >Changelog > >v1 -> v2 > >* Set the vsock flag on the receive path in the vsock transport > assignment logic. >* Use bitwise operator for the vsock flag setup. >* Use the updated "VMADDR_FLAG_TO_HOST" flag naming. > >Signed-off-by: Andra Paraschiv <andraprs@amazon.com> >--- > net/vmw_vsock/af_vsock.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> > >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index d10916ab45267..83d035eab0b05 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -431,6 +431,18 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) > unsigned int remote_cid = vsk->remote_addr.svm_cid; > int ret; > >+ /* If the packet is coming with the source and destination CIDs higher >+ * than VMADDR_CID_HOST, then a vsock channel where all the packets are >+ * forwarded to the host should be established. Then the host will >+ * need to forward the packets to the guest. >+ * >+ * The flag is set on the (listen) receive path (psk is not NULL). On >+ * the connect path the flag can be set by the user space application. >+ */ >+ if (psk && vsk->local_addr.svm_cid > VMADDR_CID_HOST && >+ vsk->remote_addr.svm_cid > VMADDR_CID_HOST) >+ vsk->remote_addr.svm_flags |= VMADDR_FLAG_TO_HOST; >+ > switch (sk->sk_type) { > case SOCK_DGRAM: > new_transport = transport_dgram; >-- >2.20.1 (Apple Git-117) > > > > >Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005. >
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index d10916ab45267..83d035eab0b05 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -431,6 +431,18 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) unsigned int remote_cid = vsk->remote_addr.svm_cid; int ret; + /* If the packet is coming with the source and destination CIDs higher + * than VMADDR_CID_HOST, then a vsock channel where all the packets are + * forwarded to the host should be established. Then the host will + * need to forward the packets to the guest. + * + * The flag is set on the (listen) receive path (psk is not NULL). On + * the connect path the flag can be set by the user space application. + */ + if (psk && vsk->local_addr.svm_cid > VMADDR_CID_HOST && + vsk->remote_addr.svm_cid > VMADDR_CID_HOST) + vsk->remote_addr.svm_flags |= VMADDR_FLAG_TO_HOST; + switch (sk->sk_type) { case SOCK_DGRAM: new_transport = transport_dgram;
The vsock flags can be set during the connect() setup logic, when initializing the vsock address data structure variable. Then the vsock transport is assigned, also considering this flags field. The vsock transport is also assigned on the (listen) receive path. The flags field needs to be set considering the use case. Set the value of the vsock flags of the remote address to the one targeted for packets forwarding to the host, if the following conditions are met: * The source CID of the packet is higher than VMADDR_CID_HOST. * The destination CID of the packet is higher than VMADDR_CID_HOST. Changelog v1 -> v2 * Set the vsock flag on the receive path in the vsock transport assignment logic. * Use bitwise operator for the vsock flag setup. * Use the updated "VMADDR_FLAG_TO_HOST" flag naming. Signed-off-by: Andra Paraschiv <andraprs@amazon.com> --- net/vmw_vsock/af_vsock.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)