Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1048181rwd; Wed, 7 Jun 2023 10:12:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4n2dpJM98MBGuP0LHu6YP+MxIjXXMudVu8qPWoRE83invXN32bHyTBgkF3qHb00QFEw05w X-Received: by 2002:a05:6a20:7354:b0:10e:96a4:e31d with SMTP id v20-20020a056a20735400b0010e96a4e31dmr4441698pzc.22.1686157962543; Wed, 07 Jun 2023 10:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686157962; cv=none; d=google.com; s=arc-20160816; b=w9QpTJ5wFPesG7NE27EA3geoL0P/Egkcl6Gy2pLGCtbT4Twmm8UmJWkwW0KNmlwfPH fSddt5HixiyZ1Ed68nhv88RGt5bvgqd5gdcVUHqKbk2FnZJpvIj6ONH1soVs/1e5h9CG QFpSqERr579mUN+6Ni34GJzOT/p/MJ9oa07jgfxrtM6uB2QlmP3k+Y52D5jeVypbJ3sf N6ZJRtv8cepW9TftAI05DSA61Bgiv9DVOhfkM8kp8sEYxZu1sple+471Z/7buvGRE9ma Y2uregFe7w3MCYtIqj+/DWGv7/sf1TvgpZHGFdcRvr9TpOMwRZvKScK5vDR12Br61239 nqVQ== 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=b7l4QEpU0+LQkmsHXgVOh37YgpJ+290D8omMu7e7uYk=; b=P8AXclykZk56x8zhCgmoC/fl6rghSHYcuOUI9B8aTOretwhX3FCuhjNYvTTdI1rEUH b6cfLHFDfsXYZCfPmhCFHu5fDT7ekpvlceSzM6Xx4zoXV/NdOkSIQccsUgshCTi3GKJq mwZLBfCmYtdv4B1765jLSsdl5WHW3MuPxaQeV1jnswW2e3BfHsKG4d2djZ/TpbZTl1cp +YYlEtc7H2tQUwhAcqiIpBtZZkrxf7ekiBCSESiCf13w5CzhsP27SESSjMxhDVbkLLm2 wt2M05s2yMeoaKaL3MVkhx85Q5irzGG7ZFKsMB82/PTiSHq4EXFkN2F3rgmi0jkPfJvQ 0VNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=knwnj2+f; 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 138-20020a630090000000b0053fa62e7c4csi8927602pga.776.2023.06.07.10.12.27; Wed, 07 Jun 2023 10:12:42 -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=knwnj2+f; 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 S231282AbjFGQxo (ORCPT + 99 others); Wed, 7 Jun 2023 12:53:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbjFGQxi (ORCPT ); Wed, 7 Jun 2023 12:53:38 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7FB91FE0; Wed, 7 Jun 2023 09:53:25 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-662f0feafb2so79620b3a.1; Wed, 07 Jun 2023 09:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686156805; x=1688748805; 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=b7l4QEpU0+LQkmsHXgVOh37YgpJ+290D8omMu7e7uYk=; b=knwnj2+fd6vq6FbFstDS35YGJ++HxkyO5xhWNIcrlBOTKoiZszvzNQ5+VKppnE6tup 1/52xt/D1hQ7vLiuFfpbbFRjjg+urgFg5Wz9ALfvVeKt5u9dzgET3lMxuxdU+E8kSWSy t1Jyt63SD0xf78qxeGH/HH6Mdvr5rCqfb7/uTFAy7hqTlBaRR65mKIb8afbWyTRnCDXO KLfEgh8t3ys9a8OqMAAmxsTN0+xIIdiFy/bj217NTrtDrPSDAPA/juD2rb8pPdvA1T6c 75Sr89EYvQIhccQgAOTm03X7oMNFFspmfd5IsqxA3TiHvrPOalvoomvZZ8DyWiy7OcuE 60dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686156805; x=1688748805; 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=b7l4QEpU0+LQkmsHXgVOh37YgpJ+290D8omMu7e7uYk=; b=RmQGa6TLcu3iBJch0gidVHgD+6+yj1cEGpaDewzgAG/45zaTyrYgTREnG0/wEkV56H Ps7dJbVx4kFl7gW6a32nmXdOqCpfX0H54qTTNMrJsiG6fKHJnbhmNxQ4t7S6KETkxE0y xHHgio/UkMetjwtmOElTUnIvafKb81lrYq16YgCXrgyaaSMI6y/A9M7u+J76IV6dUhQp iwiWja890hp46t14y1RY2uLz9VYEB0LoZvH/U7So39xmzuVCB7T5KEKRt5bSuLbl1bbN do5oQZl6JpGry2UEDOy1JYHdQfrWJIRnupV+UMqaF60kVuHMhjnU5Ajv9rWZAxBIWyhi 2P2w== X-Gm-Message-State: AC+VfDw46bTOJ6iS74N7DoAkoIyBqD6OFWnhSCB3yX2T7mwL7v7tDJfZ kFhwSWF1RtXMmcuBv+vumuQ= X-Received: by 2002:a05:6a00:16d1:b0:64f:ad7c:70fb with SMTP id l17-20020a056a0016d100b0064fad7c70fbmr6644193pfc.17.1686156804938; Wed, 07 Jun 2023 09:53:24 -0700 (PDT) Received: from localhost (ec2-52-8-182-0.us-west-1.compute.amazonaws.com. [52.8.182.0]) by smtp.gmail.com with ESMTPSA id v11-20020a63480b000000b0053f22b76cdcsm9270839pga.82.2023.06.07.09.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 09:53:24 -0700 (PDT) Date: Thu, 1 Jun 2023 07:53:25 +0000 From: Bobby Eshleman To: Simon Horman Cc: Bobby Eshleman , Stefan Hajnoczi , Stefano Garzarella , "Michael S. Tsirkin" , Jason Wang , "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 , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Subject: Re: [PATCH RFC net-next v3 1/8] vsock/dgram: generalize recvmsg and drop transport->dgram_dequeue Message-ID: References: <20230413-b4-vsock-dgram-v3-0-c2414413ef6a@bytedance.com> <20230413-b4-vsock-dgram-v3-1-c2414413ef6a@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,DATE_IN_PAST_96_XX, 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=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 Wed, May 31, 2023 at 05:56:48PM +0200, Simon Horman wrote: > On Wed, May 31, 2023 at 12:35:05AM +0000, Bobby Eshleman wrote: > > This commit drops the transport->dgram_dequeue callback and makes > > vsock_dgram_recvmsg() generic. It also adds additional transport > > callbacks for use by the generic vsock_dgram_recvmsg(), such as for > > parsing skbs for CID/port which vary in format per transport. > > > > Signed-off-by: Bobby Eshleman > > ... > > > diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c > > index b370070194fa..b6a51afb74b8 100644 > > --- a/net/vmw_vsock/vmci_transport.c > > +++ b/net/vmw_vsock/vmci_transport.c > > @@ -1731,57 +1731,40 @@ static int vmci_transport_dgram_enqueue( > > return err - sizeof(*dg); > > } > > > > -static int vmci_transport_dgram_dequeue(struct vsock_sock *vsk, > > - struct msghdr *msg, size_t len, > > - int flags) > > +int vmci_transport_dgram_get_cid(struct sk_buff *skb, unsigned int *cid) > > { > > - int err; > > struct vmci_datagram *dg; > > - size_t payload_len; > > - struct sk_buff *skb; > > > > - if (flags & MSG_OOB || flags & MSG_ERRQUEUE) > > - return -EOPNOTSUPP; > > + dg = (struct vmci_datagram *)skb->data; > > + if (!dg) > > + return -EINVAL; > > > > - /* Retrieve the head sk_buff from the socket's receive queue. */ > > - err = 0; > > - skb = skb_recv_datagram(&vsk->sk, flags, &err); > > - if (!skb) > > - return err; > > + *cid = dg->src.context; > > + return 0; > > +} > > Hi Bobby, > > clang-16 with W=1 seems a bit unhappy about this. > > net/vmw_vsock/vmci_transport.c:1734:5: warning: no previous prototype for function 'vmci_transport_dgram_get_cid' [-Wmissing-prototypes] > int vmci_transport_dgram_get_cid(struct sk_buff *skb, unsigned int *cid) > ^ > net/vmw_vsock/vmci_transport.c:1734:1: note: declare 'static' if the function is not intended to be used outside of this translation unit > int vmci_transport_dgram_get_cid(struct sk_buff *skb, unsigned int *cid) > ^ > static > net/vmw_vsock/vmci_transport.c:1746:5: warning: no previous prototype for function 'vmci_transport_dgram_get_port' [-Wmissing-prototypes] > int vmci_transport_dgram_get_port(struct sk_buff *skb, unsigned int *port) > ^ > net/vmw_vsock/vmci_transport.c:1746:1: note: declare 'static' if the function is not intended to be used outside of this translation unit > int vmci_transport_dgram_get_port(struct sk_buff *skb, unsigned int *port) > ^ > static > net/vmw_vsock/vmci_transport.c:1758:5: warning: no previous prototype for function 'vmci_transport_dgram_get_length' [-Wmissing-prototypes] > int vmci_transport_dgram_get_length(struct sk_buff *skb, size_t *len) > ^ > net/vmw_vsock/vmci_transport.c:1758:1: note: declare 'static' if the function is not intended to be used outside of this translation unit > int vmci_transport_dgram_get_length(struct sk_buff *skb, size_t *len) > ^ > > I see similar warnings for net/vmw_vsock/af_vsock.c in patch 4/8. > > > + > > +int vmci_transport_dgram_get_port(struct sk_buff *skb, unsigned int *port) > > +{ > > + struct vmci_datagram *dg; > > > > dg = (struct vmci_datagram *)skb->data; > > if (!dg) > > - /* err is 0, meaning we read zero bytes. */ > > - goto out; > > - > > - payload_len = dg->payload_size; > > - /* Ensure the sk_buff matches the payload size claimed in the packet. */ > > - if (payload_len != skb->len - sizeof(*dg)) { > > - err = -EINVAL; > > - goto out; > > - } > > + return -EINVAL; > > > > - if (payload_len > len) { > > - payload_len = len; > > - msg->msg_flags |= MSG_TRUNC; > > - } > > + *port = dg->src.resource; > > + return 0; > > +} > > > > - /* Place the datagram payload in the user's iovec. */ > > - err = skb_copy_datagram_msg(skb, sizeof(*dg), msg, payload_len); > > - if (err) > > - goto out; > > +int vmci_transport_dgram_get_length(struct sk_buff *skb, size_t *len) > > +{ > > + struct vmci_datagram *dg; > > > > - if (msg->msg_name) { > > - /* Provide the address of the sender. */ > > - DECLARE_SOCKADDR(struct sockaddr_vm *, vm_addr, msg->msg_name); > > - vsock_addr_init(vm_addr, dg->src.context, dg->src.resource); > > - msg->msg_namelen = sizeof(*vm_addr); > > - } > > - err = payload_len; > > + dg = (struct vmci_datagram *)skb->data; > > + if (!dg) > > + return -EINVAL; > > > > -out: > > - skb_free_datagram(&vsk->sk, skb); > > - return err; > > + *len = dg->payload_size; > > + return 0; > > } > > > > static bool vmci_transport_dgram_allow(u32 cid, u32 port) > > ... Thanks for the review! Your feedback from both emails will be incorporated in the next rev (with C=1 and W=1 output clearing). Thanks again, Bobby