Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2939302pxv; Sun, 4 Jul 2021 02:56:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrWdTN53NQ7HByEWLDkkFlnvxr8xJedEw57/3v9Q22kzlsNCKjUteVh00YBQbA64+R9IaX X-Received: by 2002:a92:b745:: with SMTP id c5mr6056553ilm.230.1625392562183; Sun, 04 Jul 2021 02:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625392562; cv=none; d=google.com; s=arc-20160816; b=n8X95GvyuplPXFVIB4Ihwfbk1bYl2MFArQfmudcltCxw9MugdE2qltienF5lwAF89l lfl0UsrRQ+X/OyS9sT/Ie9RMNhDvkkixqo8Bn38YtO0kMtvVwAcyx68GK9WP0LKx+Og6 g+CcCDSu3JRrk139unHLKc1H8sbvL/jplEEgE750bP8VT7SGgMUJb7bipKNQxzNQ9z/5 bJpJrBzIUE+o2fwnlCRKsr4kTHZDpPHcneemSUC+XoD/6CeyR9DWTHeQ3K6E/Q3DBBsM EZeMHRV4c7EBwlP6GFJ/P2qUej7LD8AZH3HHbxqTzbeFv+FETuO1AAm75EW5IecOGf1k Bcfw== 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=VYPXgNYdb3c09oXqHPIxazq2MDtMHdph5d1ic1D1Bi8=; b=AAALKYX1UYBKhe5QsT3LwzhVvsxaSwtoLqzfW+1lpBSHUyTZ8WMl4P3rtQNxmCk+33 PBSLiUWs/dX69IXsxs1HwxJ2PM03NQaqjljP53zdrLN8f2FVpdTFcDYMUs6rXYKsEWIS LQMTpEoFpqE/FLWCfsXOKgKVDIlUGfDi1T9+VBwLpsoxODg+fsqFFz16MYUhG3Z+gvfN DncTfzMTkagwUHZs6piN679TInga58oyNOfXjIuMhKzfljK2uur9mfp5KItEi2nNpad5 RrA7IuKKlv6Z971iRfiden6/fslDld22tXhaRSiqd9SkWjJHJzRyWpjjhosLvqmONd+/ tpYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ATVwuldP; 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 t12si12038805ilu.22.2021.07.04.02.55.50; Sun, 04 Jul 2021 02:56:02 -0700 (PDT) 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=ATVwuldP; 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 S229575AbhGDJ5O (ORCPT + 99 others); Sun, 4 Jul 2021 05:57:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55838 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbhGDJ5M (ORCPT ); Sun, 4 Jul 2021 05:57:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625392477; 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=VYPXgNYdb3c09oXqHPIxazq2MDtMHdph5d1ic1D1Bi8=; b=ATVwuldPS04IsUXhohH6jFKqf4ZS14D78gSpkAS7CTuRSa3A7MaC99origN9i8SuIEsxZf k9Z9jOo89VQ7pKSTAeU2p2rmB+viDDOS7MtqU7/6g5qvGBHs0YUV4kHTH6kEp/2tCEz/Lj KVZ7XXcsr80dymU2OW0OJdmj9xNe4PQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-533-2DP4VlENNSiuEXBWVUnbEw-1; Sun, 04 Jul 2021 05:54:35 -0400 X-MC-Unique: 2DP4VlENNSiuEXBWVUnbEw-1 Received: by mail-wm1-f72.google.com with SMTP id m31-20020a05600c3b1fb02902082e9b2132so252414wms.5 for ; Sun, 04 Jul 2021 02:54:35 -0700 (PDT) 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=VYPXgNYdb3c09oXqHPIxazq2MDtMHdph5d1ic1D1Bi8=; b=sSanGAHned35IkNAT0drIqTHP2ia/W/yIQYw+iYeOhH2M8xjWnHsq3qjx/ipRXTIxk cf8TtQI+vzBvom4SIoTx+Vi4zzlq1CRZ4RKxbzyqLZ+PcaGCnGECKo/yRUcst7IqmgQ8 EfmzfXednV7pLKvd4+d+OMG1OkiUlGhIdipyaYJKigpd/hVIkT2LaFi70CN7HGHvw+FJ E58kIRLI4VknaUfF7klmbqMQNLeHDe/mh/YPaE6jjRmCI79tY/SHsxdmBYzp495ojdml mWGWmoYhPbArm2qCoARlDINFiKcsZvLPz7L66EcXpboY+NNPYCCEalZGIVjq1z2xyt1A w3/w== X-Gm-Message-State: AOAM530rvwSvGBV2w/soHAiKP8tyOCM7d6hS2aUOdKs3YfbyqDGydrvo tpwDAk2hqy/vJi14mxEPYn3bBez+Czh4LsjPQMyYoFB/p3JMrnpFoIW72R35468rnK44MNTOMYc zWnGvlHs7gF42vZvVZ6c4b+Cs X-Received: by 2002:a7b:c8d9:: with SMTP id f25mr8743133wml.153.1625392474342; Sun, 04 Jul 2021 02:54:34 -0700 (PDT) X-Received: by 2002:a7b:c8d9:: with SMTP id f25mr8743122wml.153.1625392474177; Sun, 04 Jul 2021 02:54:34 -0700 (PDT) Received: from redhat.com ([2.55.4.39]) by smtp.gmail.com with ESMTPSA id c12sm10458200wrr.90.2021.07.04.02.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jul 2021 02:54:33 -0700 (PDT) Date: Sun, 4 Jul 2021 05:54:29 -0400 From: "Michael S. Tsirkin" To: Arseny Krasnov Cc: Stefan Hajnoczi , Stefano Garzarella , Jason Wang , "David S. Miller" , Jakub Kicinski , 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" , "oxffffaa@gmail.com" Subject: Re: [RFC PATCH v2 0/6] Improve SOCK_SEQPACKET receive logic Message-ID: <20210704055037-mutt-send-email-mst@kernel.org> References: <20210704080820.88746-1-arseny.krasnov@kaspersky.com> <20210704042843-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 04, 2021 at 12:23:03PM +0300, Arseny Krasnov wrote: > > On 04.07.2021 11:30, Michael S. Tsirkin wrote: > > On Sun, Jul 04, 2021 at 11:08:13AM +0300, Arseny Krasnov wrote: > >> This patchset modifies receive logic for SOCK_SEQPACKET. > >> Difference between current implementation and this version is that > >> now reader is woken up when there is at least one RW packet in rx > >> queue of socket and data is copied to user's buffer, while merged > >> approach wake up user only when whole message is received and kept > >> in queue. New implementation has several advantages: > >> 1) There is no limit for message length. Merged approach requires > >> that length must be smaller than 'peer_buf_alloc', otherwise > >> transmission will stuck. > >> 2) There is no need to keep whole message in queue, thus no > >> 'kmalloc()' memory will be wasted until EOR is received. > >> > >> Also new approach has some feature: as fragments of message > >> are copied until EOR is received, it is possible that part of > >> message will be already in user's buffer, while rest of message > >> still not received. And if user will be interrupted by signal or > >> timeout with part of message in buffer, it will exit receive loop, > >> leaving rest of message in queue. To solve this problem special > >> callback was added to transport: it is called when user was forced > >> to leave exit loop and tells transport to drop any packet until > >> EOR met. > > Sorry about commenting late in the game. I'm a bit lost > > > > > > SOCK_SEQPACKET > > Provides sequenced, reliable, bidirectional, connection-mode transmission paths for records. A record can be sent using one or more output operations and received using one or more input operations, but a single operation never transfers part of more than one record. Record boundaries are visible to the receiver via the MSG_EOR flag. > > > > it's supposed to be reliable - how is it legal to drop packets? > > Sorry, seems i need to rephrase description. "Packet" here means fragment of record(message) at transport > > layer. As this is SEQPACKET mode, receiver could get only whole message or error, so if only several fragments > > of message was copied (if signal received for example) we can't return it to user - it breaks SEQPACKET sense. I think, > > in this case we can drop rest of record's fragments legally. > > > Thank You Would not that violate the reliable property? IIUC it's only ok to return an error if socket gets closed. Just like e.g. TCP ... > > > > > >> When EOR is found, this mode is disabled and normal packet > >> processing started. Note, that when 'drop until EOR' mode is on, > >> incoming packets still inserted in queue, reader will be woken up, > >> tries to copy data, but nothing will be copied until EOR found. > >> It was possible to drain such unneeded packets it rx work without > >> kicking user, but implemented way is simplest. Anyway, i think > >> such cases are rare. > > > >> New test also added - it tries to copy to invalid user's > >> buffer. > >> > >> Arseny Krasnov (16): > >> af_vsock/virtio/vsock: change seqpacket receive logic > >> af_vsock/virtio/vsock: remove 'seqpacket_has_data' callback > >> virtio/vsock: remove 'msg_count' based logic > >> af_vsock/virtio/vsock: add 'seqpacket_drop()' callback > >> virtio/vsock: remove record size limit for SEQPACKET > >> vsock_test: SEQPACKET read to broken buffer > >> > >> drivers/vhost/vsock.c | 2 +- > >> include/linux/virtio_vsock.h | 7 +- > >> include/net/af_vsock.h | 4 +- > >> net/vmw_vsock/af_vsock.c | 44 ++++---- > >> net/vmw_vsock/virtio_transport.c | 2 +- > >> net/vmw_vsock/virtio_transport_common.c | 103 ++++++++----------- > >> net/vmw_vsock/vsock_loopback.c | 2 +- > >> tools/testing/vsock/vsock_test.c | 120 ++++++++++++++++++++++ > >> 8 files changed, 193 insertions(+), 91 deletions(-) > >> > >> v1 -> v2: > >> Patches reordered and reorganized. > >> > >> Signed-off-by: Arseny Krasnov > >> --- > >> cv.txt | 0 > >> 1 file changed, 0 insertions(+), 0 deletions(-) > >> create mode 100644 cv.txt > >> > >> diff --git a/cv.txt b/cv.txt > >> new file mode 100644 > >> index 000000000000..e69de29bb2d1 > >> -- > >> 2.25.1 > >