From patchwork Thu Jul 27 22:26:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 127237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp58919vqg; Thu, 27 Jul 2023 16:01:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlFU47q50rUGUwcqRewPZjfNYUB6Ds88yZGqsmelkn85EpGQVW1PCeCuw+05PVq3FcLfSLBa X-Received: by 2002:a05:6a00:cd0:b0:686:6166:3739 with SMTP id b16-20020a056a000cd000b0068661663739mr37967pfv.13.1690498894367; Thu, 27 Jul 2023 16:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690498894; cv=none; d=google.com; s=arc-20160816; b=qqMYwmZ+GBisTWBhNhCUL2vnVMNtFaoH3x/2P4owB9kAXQixp/6hXX3SxY4WcqZ5WH 9MagR6bgNDBWkHj8Nix9frH5Q6BzbbedNbHfrf+bV5ia5tFXM+wicXUjGVFaJvytmLAS O8S7oY6WRJhl+yW/7Nt9nD2IYXAHHV2+WhLT4gjFb5qDwJTK+8FaVLm6DpVqXkjnLwdd s/qfcWSOMUM+SXQJn6sQKgPoZJPMsK7SKH9pr3RIPprUzOVooNsqqWQHmAsL0hplyrFn PdXr/sU+y84RQ66fcZPGy/BIA7sMphkgVkSoH0reUa9FahHaTEl5NA7lawgeBRV6TSXp 3Mvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=ELg8tdObHqRyBIr3ossHVFNdgqgdC5F8jC1bSiv1HnA=; fh=IiLlUAYZQ4hWuQbi3V9KE00VdjFsw4tg4Y6JCUFRLn0=; b=Z/YDjW/1e2iKi6oNs1sn1ARXQzZnhnoMa+f+2HDoU4w3a3I/gaPAnkFrekgy3cU38E wb3oGNJ9Xd9imd1n4huT5XGwsungn1Vve6OK8bDu9Vwc9TKYrQ+wQLC2FJGb0gKJDBRo w4dymMDikMXmLAJPXBr+qcA2l0UbkgOVI6cOhufx6cY2WSGetj3CsoWnrzDE/UYlWjDE CYPLaKyJzZRWP0BhCC+YSsA/qwCXMtbz/659XVl2Zp8DB/KasTiA/V6NGDT3oQZryVXC aI6gE61HKzwlgUt8ShKGQlTDkKTnuTujtw/2JMYxUpBuPLvGcK9KLr1qlysQ4Vp2bwEw bqQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=GnlgzL0q; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z33-20020a056a001da100b006870878c6dbsi592155pfw.191.2023.07.27.16.01.21; Thu, 27 Jul 2023 16:01:34 -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=@sberdevices.ru header.s=mail header.b=GnlgzL0q; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232884AbjG0WcS (ORCPT + 99 others); Thu, 27 Jul 2023 18:32:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232774AbjG0WcQ (ORCPT ); Thu, 27 Jul 2023 18:32:16 -0400 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5601530C0; Thu, 27 Jul 2023 15:32:14 -0700 (PDT) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id C3E2C10000B; Fri, 28 Jul 2023 01:32:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru C3E2C10000B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1690497132; bh=ELg8tdObHqRyBIr3ossHVFNdgqgdC5F8jC1bSiv1HnA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=GnlgzL0qP1Gougz/TOc/NWoV7oXH1TyaFavUhOmmftTpeN7d895WXMz3e1Rwji9rH 272cBVe8PjFa6Zduuc2vqbaKop3c7u/D6x+/ctnssm8kWPZRbyvJo+LcR9xDgrvu7L NyQOSecFilNtoBew5OG0GoYWLIgRCwhCquWrMaWBrqZFYYFMurvubxIFGOtRZ3VVVd avilfwK/n4w5Pb1j9N5SKr2OwIBLfdefZ+6tf8kX7e9wcnbq5Iy30ITwm0cNoeQ5fx 5YNUqdAZmPC9Ul550tyop2XQvFFhWPZSdN0j0beR4Jpu1L+KG4CQN6CU68YfznszcX 6q1FfgRn09LhQ== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Fri, 28 Jul 2023 01:32:12 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Fri, 28 Jul 2023 01:31:52 +0300 From: Arseniy Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman CC: , , , , , , , Arseniy Krasnov Subject: [PATCH net-next v4 3/4] vsock/virtio: non-linear skb handling for tap Date: Fri, 28 Jul 2023 01:26:26 +0300 Message-ID: <20230727222627.1895355-4-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230727222627.1895355-1-AVKrasnov@sberdevices.ru> References: <20230727222627.1895355-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 178796 [Jul 22 2023] X-KSMG-AntiSpam-Version: 5.9.59.0 X-KSMG-AntiSpam-Envelope-From: AVKrasnov@sberdevices.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 525 525 723604743bfbdb7e16728748c3fa45e9eba05f7d, {Tracking_from_domain_doesnt_match_to}, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/07/23 08:49:00 #21663637 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772616568736673326 X-GMAIL-MSGID: 1772616568736673326 For tap device new skb is created and data from the current skb is copied to it. This adds copying data from non-linear skb to new the skb. Signed-off-by: Arseniy Krasnov Reviewed-by: Stefano Garzarella --- net/vmw_vsock/virtio_transport_common.c | 31 ++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 0b6a89139810..de7b44675254 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -106,6 +106,27 @@ virtio_transport_alloc_skb(struct virtio_vsock_pkt_info *info, return NULL; } +static void virtio_transport_copy_nonlinear_skb(const struct sk_buff *skb, + void *dst, + size_t len) +{ + struct iov_iter iov_iter = { 0 }; + struct kvec kvec; + size_t to_copy; + + kvec.iov_base = dst; + kvec.iov_len = len; + + iov_iter.iter_type = ITER_KVEC; + iov_iter.kvec = &kvec; + iov_iter.nr_segs = 1; + + to_copy = min_t(size_t, len, skb->len); + + skb_copy_datagram_iter(skb, VIRTIO_VSOCK_SKB_CB(skb)->frag_off, + &iov_iter, to_copy); +} + /* Packet capture */ static struct sk_buff *virtio_transport_build_skb(void *opaque) { @@ -114,7 +135,6 @@ static struct sk_buff *virtio_transport_build_skb(void *opaque) struct af_vsockmon_hdr *hdr; struct sk_buff *skb; size_t payload_len; - void *payload_buf; /* A packet could be split to fit the RX buffer, so we can retrieve * the payload length from the header and the buffer pointer taking @@ -122,7 +142,6 @@ static struct sk_buff *virtio_transport_build_skb(void *opaque) */ pkt_hdr = virtio_vsock_hdr(pkt); payload_len = pkt->len; - payload_buf = pkt->data; skb = alloc_skb(sizeof(*hdr) + sizeof(*pkt_hdr) + payload_len, GFP_ATOMIC); @@ -165,7 +184,13 @@ static struct sk_buff *virtio_transport_build_skb(void *opaque) skb_put_data(skb, pkt_hdr, sizeof(*pkt_hdr)); if (payload_len) { - skb_put_data(skb, payload_buf, payload_len); + if (skb_is_nonlinear(pkt)) { + void *data = skb_put(skb, payload_len); + + virtio_transport_copy_nonlinear_skb(pkt, data, payload_len); + } else { + skb_put_data(skb, pkt->data, payload_len); + } } return skb;