Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5234955rwb; Mon, 31 Jul 2023 21:59:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlGrmj4SpaaDgVYFfseZDLt/fGXia7SHHJwfE2+cG9NFBUlf9mjcsM1iTfFmH6CzJya6evFe X-Received: by 2002:a05:6358:27a3:b0:134:f326:e819 with SMTP id l35-20020a05635827a300b00134f326e819mr2129462rwb.29.1690865963292; Mon, 31 Jul 2023 21:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690865963; cv=none; d=google.com; s=arc-20160816; b=ES162mTfyXC9yvF0PZlp6AFw8Y8iVsAHKD5tkqTyRkYloOmuFih5QODzDSkqsbsTaI 4x/b5TxT3Yj3CzKH3KSDNbOjw06AHkTE5rGTsM5s14dWauagXSDabKcXpj8aaw8JMFx2 EtJZW3XGYvrY5frU5TV+UlM46gaNzoaRP37AwklAirDZbkwEn67uFqBvaS2l+w96n7rP hfxLSw8FiuZE44RWA4zlTajecl8h9ILGXWGy7GAWn1OtdgtrDoXhFmbR0xWDXDA29AjZ eavWsJracNWjLOydShB7ewKcEXmt/v4QAmANShPqnZL5fTQE2Xb3+ugMa1WUbnbiKbzm wdyQ== 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=D+Qr+Vl6m/WbbDISDjD1yyCZ2hR5HHEvke4EmXEj2Uw=; fh=LDHiWBGdjMvG2iIcnBRi1Jmkc2jc6vBL8oVx9UpQ7zQ=; b=l3qVNt6ZETG94Lckxk3OnhhLOnEh3mYjkWHIczNf2b1AJ9Ooj9AeuW7bEuj3yRyKoI Zz5x6A4H0n5UrI/DjcgKMpMlEl4/f4wqrKceyrIO7tax1ksX+EUBoVWHn1cscIlyalDL UzX8IShsc1mb1uS3J4o9+Z7RBQeUNhkatONGoA6qFd+pMpdN+HvbZQ8S+26DPO9lM7R2 cYINgfjG2TGnRVXhV6TX0xfsDr18gQEgCo53PhO+Cc2qzy2Q1KFbqkDq3U5eiudSaELU 1Qp/FsiRZzWtgEd8j+umEzoZ+B24xzSnO7isb8ooPZMn9iYz4WozFXMyBnY6hQaXEJ67 4yMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=pIz+Kd+2; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k186-20020a6384c3000000b0055ffa8eb7f5si865232pgd.28.2023.07.31.21.59.09; Mon, 31 Jul 2023 21:59:23 -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=@gmail.com header.s=20221208 header.b=pIz+Kd+2; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbjHAEOS (ORCPT + 99 others); Tue, 1 Aug 2023 00:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjHAEOQ (ORCPT ); Tue, 1 Aug 2023 00:14:16 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A866DE49; Mon, 31 Jul 2023 21:14:14 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-686daaa5f1fso3635342b3a.3; Mon, 31 Jul 2023 21:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690863254; x=1691468054; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=D+Qr+Vl6m/WbbDISDjD1yyCZ2hR5HHEvke4EmXEj2Uw=; b=pIz+Kd+2aIGkwz0drO4/9pu9r8QDYtL8kmf1bgJ0EtiKl8D5Dq1pruHje/mBtmcd7D 95ay4nhbosIOs7YbjYOFSwpwuKb2x/raH71dbfEbl0ighvQVE/QyedPwMsDk6k8l+GUT VyFMj5qNklAfs0B/ns7Az9lYDYDNXEg/FDmaidwfHjueT5L2gRFBdFZA9WczyFgAqPfT EeeVGL/C19UAdymTIwSQ0NtZxCdNlHGXtANr3/6EwVv13cD4tg07pnYk78ptn7Q4Cb0Y k6uCS9G9oWyxUPltKR8NmVNyvB5UiQRcoUMlDu8wDpTeD0umyjYoMhMLjR+K5eFUG7gl ODcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690863254; x=1691468054; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=D+Qr+Vl6m/WbbDISDjD1yyCZ2hR5HHEvke4EmXEj2Uw=; b=kEyqBqwc5KJWS+IHCXPN8zlWs9uxc8gvKXQXjuzdEUM8FRwH0TyxA883+4KKcaSY4R RxCgA/QFbakBUiiyUNecttbQyA8QAfM7f4JhlmYqCAUU48amDZFNt4v8nCdeW17GUEvk 1s8758jWsY2dqpZ/+4tVahO+ip0Wgu227F36h3oAX/M78R83tioCaMT375F93eYxf0jr B4CReaMDY/ctHVUkImWKN3jS1OoYXBYIZUAbVt++kEAJgGH4F5ecubephq7/dn2P9mik SwMLGs17Yy/L0FxIdGGi0VR69UA2vNnWjTfLPQ8kiL7mEg6U1MiqbMmQHcWxPR87opi/ bGaw== X-Gm-Message-State: ABy/qLYkf8ZJNO4rE8ukyM3Ipwfg5NUjQVPB+7BxlHmkSaG5GUgl/eDi rpBZ9PzbI/qAi/dyxg7+mOGWE/Z6cqgWGWdr X-Received: by 2002:a05:6a21:498e:b0:12f:dc60:2b9e with SMTP id ax14-20020a056a21498e00b0012fdc602b9emr11084938pzc.48.1690863253921; Mon, 31 Jul 2023 21:14:13 -0700 (PDT) Received: from localhost (c-67-166-91-86.hsd1.wa.comcast.net. [67.166.91.86]) by smtp.gmail.com with ESMTPSA id d7-20020aa78147000000b0068718aadda7sm5242014pfn.108.2023.07.31.21.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 21:14:13 -0700 (PDT) Date: Tue, 1 Aug 2023 04:14:12 +0000 From: Bobby Eshleman To: Arseniy Krasnov Cc: Bobby Eshleman , Stefan Hajnoczi , Stefano Garzarella , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Bryan Tan , Vishnu Dasa , VMware PV-Drivers Reviewers , Dan Carpenter , Simon Horman , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH RFC net-next v5 13/14] virtio/vsock: implement datagram supporty Message-ID: References: <20230413-b4-vsock-dgram-v5-0-581bd37fdb26@bytedance.com> <20230413-b4-vsock-dgram-v5-13-581bd37fdb26@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Thu, Jul 27, 2023 at 11:09:21AM +0300, Arseniy Krasnov wrote: > > > On 26.07.2023 20:58, Bobby Eshleman wrote: > > On Sat, Jul 22, 2023 at 11:45:29AM +0300, Arseniy Krasnov wrote: > >> > >> > >> On 19.07.2023 03:50, Bobby Eshleman wrote: > >>> This commit implements datagram support for virtio/vsock by teaching > >>> virtio to use the general virtio transport ->dgram_addr_init() function > >>> and implementation a new version of ->dgram_allow(). > >>> > >>> Additionally, it drops virtio_transport_dgram_allow() as an exported > >>> symbol because it is no longer used in other transports. > >>> > >>> Signed-off-by: Bobby Eshleman > >>> --- > >>> include/linux/virtio_vsock.h | 1 - > >>> net/vmw_vsock/virtio_transport.c | 24 +++++++++++++++++++++++- > >>> net/vmw_vsock/virtio_transport_common.c | 6 ------ > >>> 3 files changed, 23 insertions(+), 8 deletions(-) > >>> > >>> diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h > >>> index b3856b8a42b3..d0a4f08b12c1 100644 > >>> --- a/include/linux/virtio_vsock.h > >>> +++ b/include/linux/virtio_vsock.h > >>> @@ -211,7 +211,6 @@ void virtio_transport_notify_buffer_size(struct vsock_sock *vsk, u64 *val); > >>> 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); > >>> -bool virtio_transport_dgram_allow(u32 cid, u32 port); > >>> void virtio_transport_dgram_addr_init(struct sk_buff *skb, > >>> struct sockaddr_vm *addr); > >>> > >>> diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c > >>> index ac2126c7dac5..713718861bd4 100644 > >>> --- a/net/vmw_vsock/virtio_transport.c > >>> +++ b/net/vmw_vsock/virtio_transport.c > >>> @@ -63,6 +63,7 @@ struct virtio_vsock { > >>> > >>> u32 guest_cid; > >>> bool seqpacket_allow; > >>> + bool dgram_allow; > >>> }; > >>> > >>> static u32 virtio_transport_get_local_cid(void) > >>> @@ -413,6 +414,7 @@ static void virtio_vsock_rx_done(struct virtqueue *vq) > >>> queue_work(virtio_vsock_workqueue, &vsock->rx_work); > >>> } > >>> > >>> +static bool virtio_transport_dgram_allow(u32 cid, u32 port); > >> > >> May be add body here? Without prototyping? Same for loopback and vhost. > >> > > > > Sounds okay with me, but this seems to go against the pattern > > established by seqpacket. Any reason why? > > Stefano Garzarella commented my patch with the same approach: > > https://lore.kernel.org/netdev/lex6l5suez7azhirt22lidndtjomkbagfbpvvi5p7c2t7klzas@4l2qly7at37c/ > > Thanks, Arseniy > Gotcha, sounds good. Thanks, Bobby > > > > >>> static bool virtio_transport_seqpacket_allow(u32 remote_cid); > >>> > >>> static struct virtio_transport virtio_transport = { > >>> @@ -430,6 +432,7 @@ static struct virtio_transport virtio_transport = { > >>> > >>> .dgram_enqueue = virtio_transport_dgram_enqueue, > >>> .dgram_allow = virtio_transport_dgram_allow, > >>> + .dgram_addr_init = virtio_transport_dgram_addr_init, > >>> > >>> .stream_dequeue = virtio_transport_stream_dequeue, > >>> .stream_enqueue = virtio_transport_stream_enqueue, > >>> @@ -462,6 +465,21 @@ static struct virtio_transport virtio_transport = { > >>> .send_pkt = virtio_transport_send_pkt, > >>> }; > >>> > >>> +static bool virtio_transport_dgram_allow(u32 cid, u32 port) > >>> +{ > >>> + struct virtio_vsock *vsock; > >>> + bool dgram_allow; > >>> + > >>> + dgram_allow = false; > >>> + rcu_read_lock(); > >>> + vsock = rcu_dereference(the_virtio_vsock); > >>> + if (vsock) > >>> + dgram_allow = vsock->dgram_allow; > >>> + rcu_read_unlock(); > >>> + > >>> + return dgram_allow; > >>> +} > >>> + > >>> static bool virtio_transport_seqpacket_allow(u32 remote_cid) > >>> { > >>> struct virtio_vsock *vsock; > >>> @@ -655,6 +673,9 @@ static int virtio_vsock_probe(struct virtio_device *vdev) > >>> if (virtio_has_feature(vdev, VIRTIO_VSOCK_F_SEQPACKET)) > >>> vsock->seqpacket_allow = true; > >>> > >>> + if (virtio_has_feature(vdev, VIRTIO_VSOCK_F_DGRAM)) > >>> + vsock->dgram_allow = true; > >>> + > >>> vdev->priv = vsock; > >>> > >>> ret = virtio_vsock_vqs_init(vsock); > >>> @@ -747,7 +768,8 @@ static struct virtio_device_id id_table[] = { > >>> }; > >>> > >>> static unsigned int features[] = { > >>> - VIRTIO_VSOCK_F_SEQPACKET > >>> + VIRTIO_VSOCK_F_SEQPACKET, > >>> + VIRTIO_VSOCK_F_DGRAM > >>> }; > >>> > >>> static struct virtio_driver virtio_vsock_driver = { > >>> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c > >>> index 96118e258097..77898f5325cd 100644 > >>> --- a/net/vmw_vsock/virtio_transport_common.c > >>> +++ b/net/vmw_vsock/virtio_transport_common.c > >>> @@ -783,12 +783,6 @@ bool virtio_transport_stream_allow(u32 cid, u32 port) > >>> } > >>> EXPORT_SYMBOL_GPL(virtio_transport_stream_allow); > >>> > >>> -bool virtio_transport_dgram_allow(u32 cid, u32 port) > >>> -{ > >>> - return false; > >>> -} > >>> -EXPORT_SYMBOL_GPL(virtio_transport_dgram_allow); > >>> - > >>> int virtio_transport_connect(struct vsock_sock *vsk) > >>> { > >>> struct virtio_vsock_pkt_info info = { > >>> > >> > >> Thanks, Arseniy > > > > Thanks, > > Bobby