Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1390837rwb; Wed, 26 Jul 2023 11:43:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlG/sUHJTE6223DUsIXQdJIvfzEt9SLUBkKXQ0s1+yMMBoOJ7+swLEQZ5YIU+ZCcEwTJCuzU X-Received: by 2002:a05:6a20:430d:b0:137:2f8f:68af with SMTP id h13-20020a056a20430d00b001372f8f68afmr2994487pzk.34.1690397037666; Wed, 26 Jul 2023 11:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690397037; cv=none; d=google.com; s=arc-20160816; b=sKGNz5jppLWpiuXEdAtt3qcaO8NQK1dtSJBY5Kx8+94tJEtdfeqaE8sRz2Z5vhMy4+ JPHhlCdCr3AMoxvIXoiq8ntfuc9dEDl2MkZMyq9BXUFDUz3H92faGsCSCfPgaC5Rzkb1 MmZNqygNSeDUwd3k4iuikWYXAj2yXbXaY0bxUfzNxEtmPHMxxK62zgKy8e/TrfgJwB5W r47GS+zSshLCLdURAMjNXm8DK9uwNWnzFr5/b3CNpP7yxecTGkOaapNKKU7tV2zOxLnK nSUQdPQ1/QE5s4rXdSimWCruaHOkvlIF+DfwyaLH7gRcZTw3+c8NIKsACP2zBrNEtWEa VgFQ== 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=/YJKcaPv1jYD2cQZ5S5R7oRv+E2C9zFFFjCUSa+rubM=; fh=LDHiWBGdjMvG2iIcnBRi1Jmkc2jc6vBL8oVx9UpQ7zQ=; b=WreNZHAxJPks4TpMDEd6H4j+Ij9hKqRRtOtlWJft3X8AaW0obnP9V0QVXErI74bvTp c9MlDQDy6ZpwHuX++3TDGc0mbiJgoE7O7VptqoKf5A3qoK2NvbnWGyhP3t/cogAFXLnp sI4uorcqygwurRiFWPFiYXafT72FkQYlAQvwSD7nvbOBBbnV9CGMK79Atb131OfBX+EL U/H4/bxcLSkuDACrJIZDBuout58LevJX1dUI4YeOv6JDabAbh4n2MBSG/FP9f8AdOYHZ 4DOD9di+m0im0XCo2EmIBilj/DU2P+ykdg6EcQGxpEMttv8p35fqiY+Z/QOcpu21/txn PAQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mZkwf5zW; 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 ca13-20020a056a00418d00b00686edfcc922si299885pfb.73.2023.07.26.11.43.45; Wed, 26 Jul 2023 11:43:57 -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=mZkwf5zW; 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 S230143AbjGZR6Q (ORCPT + 99 others); Wed, 26 Jul 2023 13:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjGZR6P (ORCPT ); Wed, 26 Jul 2023 13:58:15 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 409F3121; Wed, 26 Jul 2023 10:58:14 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-686ea67195dso93725b3a.2; Wed, 26 Jul 2023 10:58:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690394293; x=1690999093; 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=/YJKcaPv1jYD2cQZ5S5R7oRv+E2C9zFFFjCUSa+rubM=; b=mZkwf5zWFZeIiX0fU/UFJoxuzD6Wpz0HN320FewBuhVtwxAloF8LgDHfXgcir9p0PC 8MJG0/wOnbUsKi3x+8GXQBKbfOc3xSVTh0FFc+hbGvcHnCuy5C1urw8JFc+6us72qneN LmC7sXZbmM2u2LneV6r4YKoEvdOHO/fUVsMSVsJXGkLtxNkxKwiPgWWARo0hF40tvt78 haLNtRk22yTQaYRgwOCX+4ufOJCVVFLhb/Un8nU8QauRMy/cReIPd6u1bvbi84y+hwIE wVuwr6dOLd6OQ9nFPe9fEyS6D3DFhR2/JZc/0drGX3hJ+r1RLpQjni5AdAxm5VEBv6n4 7y4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690394293; x=1690999093; 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=/YJKcaPv1jYD2cQZ5S5R7oRv+E2C9zFFFjCUSa+rubM=; b=YqP+bc73BttZ377F5zvmVInanV19s55J0v/3teOMDghbHHK0L6KaKwqX/VbmI5yGxM 9PnOXv5KXdwfR/kHo0bZFjMt+8zBy06dzJ5O/dnTm0lZgJsgd0K1YLYhBKJFf7slN+Eg WhZ9kJO1rG+3hAq8dYepFz3OeeeE0yk5hx5AHjgEulh/XA1FCdg1fG963ieX9ltVfrbp zI7kjyeskb9XrUBkOgwRqpQqY0nRe7hYexwoWAn5QQKX72rfhW0UORp+Sq+CIdCY2Qxd xZeXMNEoi0DWfSCLbdHGSTjcdx/5HfxPeCw29ZM4Fi8d+OkuTBPqxO4TOEIcCj63l+cB hQ/Q== X-Gm-Message-State: ABy/qLa3dYZKw41xUL4NGKeELwqBvUSgLP6nINoBaYz4Ifgz3OlB5HHW ABusmEIJZ4loLkZE6nnxFBw= X-Received: by 2002:a05:6a00:88b:b0:677:c9da:14b0 with SMTP id q11-20020a056a00088b00b00677c9da14b0mr3042053pfj.32.1690394293576; Wed, 26 Jul 2023 10:58:13 -0700 (PDT) Received: from localhost (c-73-190-126-111.hsd1.wa.comcast.net. [73.190.126.111]) by smtp.gmail.com with ESMTPSA id g20-20020a62e314000000b00672401787c6sm621035pfh.109.2023.07.26.10.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:58:13 -0700 (PDT) Date: Wed, 26 Jul 2023 17:58: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 support 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 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? > > 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