Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5428025rdb; Sat, 16 Sep 2023 17:29:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7klrX8pn8PqGTG6iLElsRJkgtgcO/E+6fIp1iY47XpAWQGbkh4ToZMyJ5LhwDXP9nNOGE X-Received: by 2002:a05:6870:b01c:b0:1bc:1ad8:2b7b with SMTP id y28-20020a056870b01c00b001bc1ad82b7bmr6760610oae.58.1694910589188; Sat, 16 Sep 2023 17:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694910589; cv=none; d=google.com; s=arc-20160816; b=JhCgmayaDJLbI4fG12vE5v4VfnU24BdSm58r9GqCORd1Tnp8J3cW2OX2KQuFvka3nZ ipYLTZ4tdAXfkxrcpEIvvLZYpnbPrwpft+u8BLfiAGK2A+/5x+Ms5Qv5Pw6/gwFBuo3N UsBDG/dcIr5Jpz5ZRo9/cK0hsZaqkYi9jDssbn2hUYYVPAHdwKkEVyZEeG1qeJJgTrZS z9JdG4YLey9yoRAn/Pvz29RKjElouJbsc3Tg2G1Xa+X/eqO3Q8i7GzKbx+6wU3ODyTPU 9Uv1v9xueYDzVi5nb5c6WSuFe2Wmfkgsv3aTpjqiZcgA8UkPCV2AQTLKe/cDwqppQsZ+ XxXw== 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=xFK2zZglKSg74HZYjaJqEfKu/loXA70ororX/hFfqQY=; fh=wIHqZpOIuzcidDZ82yQbOZuyHJty7uvaWDEh/efoVzA=; b=aKbYhpziWgxKcBFKeaCkOAZ+xoHcmTueFtvIckI9/tRGR6JdtgJ+Uy72i9rM6depN/ s1cHEktMjAYnNI9ExMbADkX8v7k27i8pDXRJGOj0Ff5/uko/3l5UhcJyDzcCldPtE8M7 YOw3dF1Qh/p9FRifYWzOuP31yHYslV43Usey0WmY1RUb8Zqk262nLXWKS0f6K1+9hNXg S4ZYrY2XV3bicu2vK3/dEh6y7HDC0AXB17mL8n2UtUIoTPztC7mDjcBI6JCX/owXMuEC g7jcOqLnWs0xHNq/+ECocXkHOOM9j0WW0wXOGtaid/DvwxWvcdqwXa4Vc92HTTB89Wi6 OZqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="ItX/9E6a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id f18-20020a17090aa79200b00273fd5cbf0bsi5532523pjq.69.2023.09.16.17.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 17:29:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="ItX/9E6a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4CF7287A3F67; Sat, 16 Sep 2023 06:17:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239303AbjIPNQs (ORCPT + 99 others); Sat, 16 Sep 2023 09:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239215AbjIPNQ0 (ORCPT ); Sat, 16 Sep 2023 09:16:26 -0400 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E74313E; Sat, 16 Sep 2023 06:16:18 -0700 (PDT) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id BF209120010; Sat, 16 Sep 2023 16:16:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru BF209120010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1694870176; bh=xFK2zZglKSg74HZYjaJqEfKu/loXA70ororX/hFfqQY=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ItX/9E6a4i6nw63wUN1EjSNnRSi/kQ4YxYMSSDa96sg5GgmA8trD9rlfv2tPlt+O4 k8vTUlTNWj5knOMkaO0LVDJ2t1Iybuj3GO6fa0AQffPN0HZNmnERN5rGK5/mkl2oh+ 09Qs9s4sPiw7UUbp5OQA69KQG2ysBrl8EjDDiVPaamQFXv3I4QnUjeNylAZWXlBAT6 b4M4aIxFUgpeQsn92baMs8yDUAm4pH9AQrvhVWIMGjMRhiDSmc/GNsd2v3KQHQ+o4e AOhi1pKsktiNMvaMTtDuO2SEpIWLtgx1pFcfl2H7dPhepqbvvAocjTuX+EdqgYaBgR UsDDNB5vMIFcw== 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; Sat, 16 Sep 2023 16:16:16 +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; Sat, 16 Sep 2023 16:16:16 +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: , , , , , , Subject: [PATCH net-next v9 3/4] vsock/virtio: non-linear skb handling for tap Date: Sat, 16 Sep 2023 16:09:17 +0300 Message-ID: <20230916130918.4105122-4-avkrasnov@salutedevices.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230916130918.4105122-1-avkrasnov@salutedevices.com> References: <20230916130918.4105122-1-avkrasnov@salutedevices.com> 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-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: 179905 [Sep 16 2023] X-KSMG-AntiSpam-Version: 5.9.59.0 X-KSMG-AntiSpam-Envelope-From: avkrasnov@salutedevices.com 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: 530 530 ecb1547b3f72d1df4c71c0b60e67ba6b4aea5432, {Tracking_from_domain_doesnt_match_to}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;p-i-exch-sc-m01.sberdevices.ru:5.0.1,7.1.1;127.0.0.199:7.1.2;salutedevices.com:7.1.1;100.64.160.123:7.1.2, 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/09/16 12:14:00 #21905676 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,URIBL_BLOCKED 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 16 Sep 2023 06:17:40 -0700 (PDT) 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 3e08d52a9355..3a48e48a99ac 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)->offset, + &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