Message ID | 20240710212555.1617795-14-amery.hung@bytedance.com (mailing list archive) |
---|---|
State | RFC |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | virtio/vsock: support datagrams | expand |
Hi Bobby, Amery Thank you for working on this! > This commit implements datagram support with a new version of > ->dgram_allow(). Commit messages should be imperative "This commit implements X" -> "Implements X". https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes This suggestion applies to many of the commits in this series. > +static bool virtio_transport_dgram_allow(u32 cid, u32 port) > +{ > + struct virtio_vsock *vsock; > + bool dgram_allow; > + > + dgram_allow = false; I think you can initialize the variable in the declaration. > + rcu_read_lock(); > + vsock = rcu_dereference(the_virtio_vsock); > + if (vsock) > + dgram_allow = vsock->dgram_allow; > + rcu_read_unlock(); > + > + return dgram_allow; > +} > + The rest LGTM. Thanks, Luigi
On Thu, Jul 11, 2024 at 4:03 PM Luigi Leonardi <luigi.leonardi@outlook.com> wrote: > > Hi Bobby, Amery > > Thank you for working on this! > > > This commit implements datagram support with a new version of > > ->dgram_allow(). > > Commit messages should be imperative "This commit implements X" -> "Implements X". > https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes > This suggestion applies to many of the commits in this series. Thanks for pointing this out. I will change the commit message in the next version. > > > +static bool virtio_transport_dgram_allow(u32 cid, u32 port) > > +{ > > + struct virtio_vsock *vsock; > > + bool dgram_allow; > > + > > + dgram_allow = false; > > I think you can initialize the variable in the declaration. Got it. Thanks, Amery > > > + rcu_read_lock(); > > + vsock = rcu_dereference(the_virtio_vsock); > > + if (vsock) > > + dgram_allow = vsock->dgram_allow; > > + rcu_read_unlock(); > > + > > + return dgram_allow; > > +} > > + > > The rest LGTM. > > Thanks, > Luigi
diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h index 4408749febd2..fe8fa0a9669d 100644 --- a/include/linux/virtio_vsock.h +++ b/include/linux/virtio_vsock.h @@ -222,7 +222,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); int virtio_transport_connect(struct vsock_sock *vsk); diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index 4891b845fcde..4e1ed3b11e26 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; /* These fields are used only in tx path in function * 'virtio_transport_send_pkt_work()', so to save @@ -492,6 +493,21 @@ static bool virtio_transport_msgzerocopy_allow(void) return true; } +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); static struct virtio_transport virtio_transport = { @@ -753,6 +769,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); @@ -850,7 +869,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 a571b575fde9..52f671287fe3 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -1010,12 +1010,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 = {