Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1607891pxb; Mon, 22 Feb 2021 06:32:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGbBE8d0iAxlWUDnCM4dEZLiXZ1JzWCLvMSmyA9WIJnsDSggijk0nyzZVoJw1zr1iRZXMO X-Received: by 2002:a05:6402:1603:: with SMTP id f3mr5522216edv.76.1614004332486; Mon, 22 Feb 2021 06:32:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614004332; cv=none; d=google.com; s=arc-20160816; b=ylocO3fT70e3FvHfHMe/DP4Ye3WMJrzmS77R4mmyT4hr+4dgaYdkehZdzch4DDXbCx oHtmLtcl4ZqpeRtX9O3jPtmG26h4kYnizLlnFTLx6b8uWxi+EPBqREuR6qCayWt/FXQc k2s4yWRtnKtDeSpb83xvP+pDe9acr5+LwsO2RjqnRse62BnEi2JjE266sTpj7YjX29g5 pYyD+h8PJIEyZ1g1L5mmLkN0VmMPSlT3DvJM8RjoWaNEgXLgmrNja6pvahl0CzE/maYk 13hrOIYN3PmF0R8ZvTJe4FX1tyDYXFRrzinF5xg1Zws0yRngV/CAq+0oN8BZ3Vf5p0sQ u2Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wzyVHac7bUd3mCc3EMe28wAe65P5w8DpSyWYPCo7GCg=; b=EvY3VABVJFurE6TrvNSc+/TmgHk5C+J+mSwn65KZUxY0hXg6eEG1zgN5oQLof8lZu5 mjSTQ0j4wlcav4uYFSbOsPwgpL2TREiY7DuxeZHyONLrfGy1gS/ODtI1tBVuFAjabqXH eFKBZJWcs00VtcRFEKbal6pndW+CmNfrhs6QemSULuBEHmt1vnPpJiEdTMsYL9oMnKJs t9Ftb1k3zqdTo0101+SFmxHwSOY6nj2Q3k7/KR7RN6cnp+jHohawsbpuUuSO9isaDlh6 L978JXEe+TuQqioz1loyRn8+G1mza8jYrmOCrXXgiSqvGoTYQdEIpLaxc/Hf1hMUI0M7 Luew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ufwt8AOK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t5si11519324edw.123.2021.02.22.06.31.49; Mon, 22 Feb 2021 06:32:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ufwt8AOK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232031AbhBVObV (ORCPT + 99 others); Mon, 22 Feb 2021 09:31:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34731 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbhBVOYs (ORCPT ); Mon, 22 Feb 2021 09:24:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614003798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wzyVHac7bUd3mCc3EMe28wAe65P5w8DpSyWYPCo7GCg=; b=Ufwt8AOKkjGXgfx1+UeSGsqEtFW+jTR72eHMVManz2hFQ0RVfjJ9h7GNqTCSRYvayjczfw 3q+2WfF/am1iVmLCTI/zEwTvSbm3u9jY+kLaa5jYSV6H0uF0vUnk5rctuPe81KXTuVr73M UVkUykRsn/X3Q/aK2bIWZHIQ1Gcg4v4= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-jfo_04oLNLKlqFumETQ5Tw-1; Mon, 22 Feb 2021 09:23:16 -0500 X-MC-Unique: jfo_04oLNLKlqFumETQ5Tw-1 Received: by mail-wr1-f71.google.com with SMTP id d7so6117901wri.23 for ; Mon, 22 Feb 2021 06:23:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wzyVHac7bUd3mCc3EMe28wAe65P5w8DpSyWYPCo7GCg=; b=qOwvFWubD89kpv4jhTtAqUSYq/SEVRg9QijUU02a6bSZOigSLb/y6K7A1vLLpyHayW nCHcjpUSSI+iXtm2Q+givg3x73Reow+2n2XCyuwtNERKJb39NYN36RY9Ngz3qlhYwkHb ftAxU4HE/25Aq2FJK2gJz7CdRbuNM7ix+dy9j6YKq6x1nJGEmlKYJfITDoLPhJgB2iQC XLCv54om5B/GyYR09QxALx7GOryVCcpRBvWZhdwt9beqomcPalj88z3WJMo2dNgt3x+D D+S1Xki8FyA4mmAgk1SZjNgXm5YhBCZZzWPNMvh5T8e2W2ZEU+WtWHU+URBUA0NAijea UyEg== X-Gm-Message-State: AOAM531dJ4nNW5pa17thM4O4E4pedE41sOO10KyZwx/Htem2g5hm0awz TBqDmYF+a2wZn51mvAiAOXtLCdmKPvsnuulPozu/8pvo9Zci5rLd1S+y8DI5bQUIPnPbuZhAt8d E886RSKXJvouvRX/9K4OrVC2c X-Received: by 2002:a1c:23c2:: with SMTP id j185mr20392826wmj.96.1614003795017; Mon, 22 Feb 2021 06:23:15 -0800 (PST) X-Received: by 2002:a1c:23c2:: with SMTP id j185mr20392806wmj.96.1614003794853; Mon, 22 Feb 2021 06:23:14 -0800 (PST) Received: from steredhat (host-79-34-249-199.business.telecomitalia.it. [79.34.249.199]) by smtp.gmail.com with ESMTPSA id o10sm22488407wrx.5.2021.02.22.06.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Feb 2021 06:23:14 -0800 (PST) Date: Mon, 22 Feb 2021 15:23:11 +0100 From: Stefano Garzarella To: Arseny Krasnov Cc: Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Jorgen Hansen , Andra Paraschiv , Norbert Slusarek , Colin Ian King , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stsp2@yandex.ru, oxffffaa@gmail.com Subject: Re: [RFC PATCH v5 00/19] virtio/vsock: introduce SOCK_SEQPACKET support Message-ID: <20210222142311.gekdd7gsm33wglos@steredhat> References: <20210218053347.1066159-1-arseny.krasnov@kaspersky.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210218053347.1066159-1-arseny.krasnov@kaspersky.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arseny, On Thu, Feb 18, 2021 at 08:33:44AM +0300, Arseny Krasnov wrote: > This patchset impelements support of SOCK_SEQPACKET for virtio >transport. > As SOCK_SEQPACKET guarantees to save record boundaries, so to >do it, two new packet operations were added: first for start of record > and second to mark end of record(SEQ_BEGIN and SEQ_END later). Also, >both operations carries metadata - to maintain boundaries and payload >integrity. Metadata is introduced by adding special header with two >fields - message count and message length: > > struct virtio_vsock_seq_hdr { > __le32 msg_cnt; > __le32 msg_len; > } __attribute__((packed)); > > This header is transmitted as payload of SEQ_BEGIN and SEQ_END >packets(buffer of second virtio descriptor in chain) in the same way as >data transmitted in RW packets. Payload was chosen as buffer for this >header to avoid touching first virtio buffer which carries header of >packet, because someone could check that size of this buffer is equal >to size of packet header. To send record, packet with start marker is >sent first(it's header contains length of record and counter), then >counter is incremented and all data is sent as usual 'RW' packets and >finally SEQ_END is sent(it also carries counter of message, which is >counter of SEQ_BEGIN + 1), also after sedning SEQ_END counter is >incremented again. On receiver's side, length of record is known from >packet with start record marker. To check that no packets were dropped >by transport, counters of two sequential SEQ_BEGIN and SEQ_END are >checked(counter of SEQ_END must be bigger that counter of SEQ_BEGIN by >1) and length of data between two markers is compared to length in >SEQ_BEGIN header. > Now as packets of one socket are not reordered neither on >vsock nor on vhost transport layers, such markers allows to restore >original record on receiver's side. If user's buffer is smaller that >record length, when all out of size data is dropped. > Maximum length of datagram is not limited as in stream socket, >because same credit logic is used. Difference with stream socket is >that user is not woken up until whole record is received or error >occurred. Implementation also supports 'MSG_EOR' and 'MSG_TRUNC' flags. > Tests also implemented. I reviewed the first part (af_vsock.c changes), tomorrow I'll review the rest. That part looks great to me, only found a few minor issues. In the meantime, however, I'm getting a doubt, especially with regard to other transports besides virtio. Should we hide the begin/end marker sending in the transport? I mean, should the transport just provide a seqpacket_enqueue() callbacl? Inside it then the transport will send the markers. This is because some transports might not need to send markers. But thinking about it more, they could actually implement stubs for that calls, if they don't need to send markers. So I think for now it's fine since it allows us to reuse a lot of code, unless someone has some objection. Thanks, Stefano