Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6063587rwp; Mon, 17 Jul 2023 14:17:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlHgEIr8iXBTNWGQm2UdyUX1bq/yo0xxjhlHxmCZM9EBARezyU5jjhY9e/mF6Lo1BWjMDPFg X-Received: by 2002:a05:6a20:5482:b0:133:5eca:a8aa with SMTP id i2-20020a056a20548200b001335ecaa8aamr15650774pzk.46.1689628662398; Mon, 17 Jul 2023 14:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689628662; cv=none; d=google.com; s=arc-20160816; b=whZoG88+zZxovynPfuOgVPMBLc0qSNDkfkirJlx2iTuSOfJ2uLiZCOgieErxJvhJc8 kMtk0Ff4DMou5j5ayxDWAiqh2LBbH7qIOHAP3EyY08EGtH+roNSmcfZJGkvtgvv8ePg1 CVjxolrd3sFJagnfPiA7Gu+vi+Rh9qJBciWl00z5oWzp6lSnQjRhxHtuSQImpyWno4mf B4f3MmXg3lkL2GhArWH76h8yGxFrbNy+lycp/BLmgSuU45jZ5oKVHd7xiCZ8oe03HnjJ KCAY83Y1pvhcxkctJHGUdVl3Zt74rsXpvE+ZhvGvuYp2ERzaeox6Gk/7ye4TYiZM8V/p rFdQ== 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=ydsf/FQJHsRd7VM9sT5BCFNwDtuvxxMDFyVsLpjPMoM=; fh=IiLlUAYZQ4hWuQbi3V9KE00VdjFsw4tg4Y6JCUFRLn0=; b=U6NQRYsDeJu2SYX5dWoKAR+RNHLYjrNLc2b46nGZsD0/3NUurGT9a2hwJgxQbxwMHc 8Lw4be+wXpds+L24o1X61s9kAeFcUNgU1+H+2VO2nxc1DLoOl7LJjU+E7EVWbOXeya58 EHvmh12wMu4n1QGSARvL4oFAGDwXqItZFXla1oa+V4El/fMi4fsGibJamOZl/cObhh8y H3zheK8W5nHkthy7SFjU1VcLclt67XH9okLeNW4Ag9fGoLPeV2DUUESgBUy8xXJ9faKU 5NwtYPW4+hZLYeERc/mgVlPfmwQiTaBlhzSeMKdFI7YKXcgUuEF3rkcJoDbgMrA0NDYj 5lPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=D7k6OrpH; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n11-20020a63ee4b000000b0054fe295d487si374516pgk.434.2023.07.17.14.17.30; Mon, 17 Jul 2023 14:17: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=@sberdevices.ru header.s=mail header.b=D7k6OrpH; 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 S231373AbjGQVGg (ORCPT + 99 others); Mon, 17 Jul 2023 17:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbjGQVGa (ORCPT ); Mon, 17 Jul 2023 17:06:30 -0400 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16B6A10C7; Mon, 17 Jul 2023 14:06:29 -0700 (PDT) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id AF783100014; Tue, 18 Jul 2023 00:06:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru AF783100014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1689627987; bh=ydsf/FQJHsRd7VM9sT5BCFNwDtuvxxMDFyVsLpjPMoM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=D7k6OrpHzQF+wJs6pKpyovgILTHKOLATgpbvzNYaf49uj6rEgCjI1U4oOxCA9Aglp PZE+2b8Ho/JO2ipGpYAHwZfJckcCq/XWdbt/G19o4VFcMuH22m/owszREODoiG5ieA Dwm+CXcswySVWCMp410awLpkuftHmBFRv+X1GNhvLUq2UowT45OO940MAGLw6vPIxe 0t0+e7iK+SFJZC1YdiEJkY37F6yAznUBMbcmLTSPikHp/qdeyEWvFayi8l6dcEfMpA 8yS8aqFLl8+RMBbZKbwpFakHa6WC0LRs+o0p1w7jROMir3s54AmP6MCiNNkOwick+q jaBLTVvXOd/5w== 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; Tue, 18 Jul 2023 00:06:27 +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; Tue, 18 Jul 2023 00:06:26 +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 v1 3/4] vsock/virtio: non-linear skb handling for tap Date: Tue, 18 Jul 2023 00:00:50 +0300 Message-ID: <20230717210051.856388-4-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230717210051.856388-1-AVKrasnov@sberdevices.ru> References: <20230717210051.856388-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) 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: 178666 [Jul 17 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: 523 523 523027ce26ed1d9067f7a52a4756a876e54db27c, {Tracking_from_domain_doesnt_match_to}, 100.64.160.123:7.1.2;sberdevices.ru:5.0.1,7.1.1;p-i-exch-sc-m01.sberdevices.ru:5.0.1,7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1, FromAlignment: s, {Tracking_white_helo}, 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/17 13:15:00 #21627216 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 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 1a376f808ae6..26a4d10da205 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; -- 2.25.1