Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp266112imn; Wed, 27 Jul 2022 05:48:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sN0OOHq+1u164dZkB0O/8yYduo/jYiBrPiQ4pcR+p0yYYQH9kv0p8uXFWBNbLdyVVXa78U X-Received: by 2002:a63:1c24:0:b0:41b:40c5:f114 with SMTP id c36-20020a631c24000000b0041b40c5f114mr3864860pgc.3.1658926113461; Wed, 27 Jul 2022 05:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658926113; cv=none; d=google.com; s=arc-20160816; b=vpdM3M/YGgnCCSHI32WJgDlHU/horwAEFHeF2Iix7tOzPFRJ+YNaiSloxs1t/3fJYl aNySkP++4E6pLvDzesRd8pKLnyKC9sZK9RPVXfRKDQ6RE54iriFYSl22Ptf4wkjYSMa8 yMkqkvYp4zXwpbwMZzAWJeWqVd/OqUmbzQ3eO1YQCd7Vz3KgetmgVWBJlj0dZuxPgKOy ZUVr1Ud04BB/vLgMRJBI/SzoNXwXsBQ6jT8BLOxb8MJiIW3Nd1/oYbZrppkGf3WUQjNy mFkEkeKfDLhHUd4SZdqM5btaZxc+ofsUjkKm3akqoSVbr8mlhQ88dL1fWZPRxZJ/leV9 U/lw== 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=dapYisiCBXlgZkwMi+Hyveg1G9f8dLox6yKCT12ZMlw=; b=opA5Ez5ZPq1zBIPs6GM+YBUS0iZNfYD0kEsn7j8WrYWSzODKH1mYQt6y7yodUWrBvt h7n6NgI7sZCA3zLbcZwd/hVE9mznNuI3YsoE088VGf4K9IZwyXlGGvk8sfJmXevTJv/A 3HBpfIMV9632uw5LuBdpK0vC4Xw0gWT5x9tR0u64+aObA/8yKEB9saZvS+GUdSnuPUiU j4SfPwzgsUlArLbGgo6SpW8GhXf79+l+uUakaPgFpRHelXH9Xy2cOQ6lxcJD9RbQJOLE heYIdl1a9a/nKZr+WUUHexxUdnyD2PPwLxHZ07sul2m3hbQjmGMpnvjemX48xwxrQlzn EJrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Os9ibwKH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h71-20020a62834a000000b005254abef688si18403013pfe.239.2022.07.27.05.48.18; Wed, 27 Jul 2022 05:48:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Os9ibwKH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232921AbiG0MYb (ORCPT + 99 others); Wed, 27 Jul 2022 08:24:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232925AbiG0MY2 (ORCPT ); Wed, 27 Jul 2022 08:24:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E6C14B49D for ; Wed, 27 Jul 2022 05:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658924666; 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=dapYisiCBXlgZkwMi+Hyveg1G9f8dLox6yKCT12ZMlw=; b=Os9ibwKHZCbV2+07ovnFkq/xVnf2YPtkViszeCBPjsjHVAy1TpnUTxZo6doZR9hEeHGpk4 seSBsffdsuVwkbLIrNUfNURoOIR8kxVk7p0ubnuKAnuZD87G/rOVGu1ORb5fOu3AHy4aF2 bebSaPaArp2zEqgFM1b8WCV+qtFJER4= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-458-M9E2s2O3MgyNdy3oHj2oWA-1; Wed, 27 Jul 2022 08:24:25 -0400 X-MC-Unique: M9E2s2O3MgyNdy3oHj2oWA-1 Received: by mail-wm1-f70.google.com with SMTP id v18-20020a05600c215200b003a2fea66b7cso484931wml.4 for ; Wed, 27 Jul 2022 05:24:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dapYisiCBXlgZkwMi+Hyveg1G9f8dLox6yKCT12ZMlw=; b=iWyi9xxBXYzJyfYAWplISEaOSN+8yoGIoqEOfe1GX4kWcxy1mxKjmy9BQI3QkrhFlt rAKNWCweJThdHIqVvOZR9sKppi1TFDxC+DHRwLbj1lWHoUkNyz0ZMyd4ZvtZbG4GB/0b AhzmxapOf5xTU+nBRaySFf0HprLn7k6+oYd6KPM3LI0kU9vhYZqPaeNDiWhFf1Bqi0mF ho5FRovelIB38QX5gq/AYZ9y/xgO0Xyz6gspxO1xL7DRP0n8oW2szUuUw0H2p20eQN9K ucKrLY3afVsGNyGdAS70g9z2PYl+k7jvIKmuE59Yig6bXD0qd5S2VQ6QggEzUM92RmjI w1/w== X-Gm-Message-State: AJIora+pzNxFCk9KAvMU00sAxOOu3q8QlqO+O7TdFCliZzBVhI7R7mgL DrkiN/9NCDEAnKGQjR07tW1Bxf/s8OkVFOJ+z2gpdDfxRKMdOoS4NxO3iY9kPvyVqc9QcPXgWRl AsZIt1pthNymTFdaptozbkiRq X-Received: by 2002:a05:6000:1541:b0:21d:b298:96be with SMTP id 1-20020a056000154100b0021db29896bemr13644419wry.206.1658924663470; Wed, 27 Jul 2022 05:24:23 -0700 (PDT) X-Received: by 2002:a05:6000:1541:b0:21d:b298:96be with SMTP id 1-20020a056000154100b0021db29896bemr13644403wry.206.1658924663274; Wed, 27 Jul 2022 05:24:23 -0700 (PDT) Received: from sgarzare-redhat (host-79-46-200-178.retail.telecomitalia.it. [79.46.200.178]) by smtp.gmail.com with ESMTPSA id bg26-20020a05600c3c9a00b003a3279b9037sm2308365wmb.16.2022.07.27.05.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 05:24:22 -0700 (PDT) Date: Wed, 27 Jul 2022 14:24:17 +0200 From: Stefano Garzarella To: Arseniy Krasnov Cc: "David S. Miller" , "edumazet@google.com" , Jakub Kicinski , Paolo Abeni , "kys@microsoft.com" , "haiyangz@microsoft.com" , "sthemmin@microsoft.com" , "wei.liu@kernel.org" , Dexuan Cui , Stefan Hajnoczi , Krasnov Arseniy , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "kvm@vger.kernel.org" , kernel Subject: Re: [RFC PATCH v2 5/9] vsock: SO_RCVLOWAT transport set callback Message-ID: <20220727122417.jvdfjnuybk3mwxkq@sgarzare-redhat> References: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> <8baa2e3a-af6b-c0fe-9bfb-7cf89506474a@sberdevices.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <8baa2e3a-af6b-c0fe-9bfb-7cf89506474a@sberdevices.ru> X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 25, 2022 at 08:05:28AM +0000, Arseniy Krasnov wrote: >This adds transport specific callback for SO_RCVLOWAT, because in some >transports it may be difficult to know current available number of bytes >ready to read. Thus, when SO_RCVLOWAT is set, transport may reject it. > >Signed-off-by: Arseniy Krasnov >--- > include/net/af_vsock.h | 1 + > net/vmw_vsock/af_vsock.c | 19 +++++++++++++++++++ > 2 files changed, 20 insertions(+) > >diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h >index f742e50207fb..eae5874bae35 100644 >--- a/include/net/af_vsock.h >+++ b/include/net/af_vsock.h >@@ -134,6 +134,7 @@ struct vsock_transport { > u64 (*stream_rcvhiwat)(struct vsock_sock *); > bool (*stream_is_active)(struct vsock_sock *); > bool (*stream_allow)(u32 cid, u32 port); >+ int (*set_rcvlowat)(struct vsock_sock *, int); > > /* SEQ_PACKET. */ > ssize_t (*seqpacket_dequeue)(struct vsock_sock *vsk, struct msghdr *msg, >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index 63a13fa2686a..b7a286db4af1 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -2130,6 +2130,24 @@ vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, > return err; > } > >+static int vsock_set_rcvlowat(struct sock *sk, int val) >+{ >+ const struct vsock_transport *transport; >+ struct vsock_sock *vsk; >+ int err = 0; >+ >+ vsk = vsock_sk(sk); >+ transport = vsk->transport; `transport` can be NULL if the user call SO_RCVLOWAT before we assign it, so we should check it. I think if the transport implements `set_rcvlowat`, maybe we should set there sk->sk_rcvlowat, so I would do something like that: if (transport && transport->set_rcvlowat) err = transport->set_rcvlowat(vsk, val); else WRITE_ONCE(sk->sk_rcvlowat, val ? : 1); return err; In addition I think we should check that val does not exceed vsk->buffer_size, something similar of what tcp_set_rcvlowat() does. Thanks, Stefano