From patchwork Sat Jun 3 20:49: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: 102918 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1841686vqr; Sat, 3 Jun 2023 13:59:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5XsTh5SV9IJZoMJGDrBsBh9yehiM6tdHyhDCOI3AsmhoLh92zdWYly9Xj4nB/qqENlCL78 X-Received: by 2002:a05:6358:428f:b0:118:daa:ce7 with SMTP id s15-20020a056358428f00b001180daa0ce7mr18865064rwc.0.1685825970964; Sat, 03 Jun 2023 13:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685825970; cv=none; d=google.com; s=arc-20160816; b=H+SA08/sdFwK+ZLcCXE8Dk/Cmg9h6lFXA7P21cCS2BrdvZV/Rrb9TPiDXj6p2r7XO8 FkTkzRV1BOMGGo1tKm+ITI2QuD2OfLMhAmIAgTGDxtqBj7nhXrWhJv9RMOuoNcEwfgu/ yGFTkSOcFvR0XpY13AdEzXLW4z9ff7NeMAxtC0cMqga1OP/7Xu/UuFTYlCU9Nwgy6HwO mXHCFYJIBhbumEe/WfsW8hFq46iY/olr/bR3GWymg89ISDmPaMYDRktR64g+qIS4V7wB obIibcqPjGWeZv2/e7IxLlLUm2cQsC6lY6WCQLnzUJF/lTI836LapfZBWjFzu6hMtxXd 6ORA== 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; bh=22Y5ntJ+4qJ6mCXCPM4xdNhop4Y9r+djJZMggy4Cf+Y=; b=w6CgM+qWQVyXkARyXp7ry9CSKpP3oZGtgzN9SCD/2gLmP2twbn/9q1B3QH2qqVYP1m 2wuUZja+ApntK2XBp1/rJDo/YSLavPKYiqLqw7uEWvhDyICks7qYGTl6JZCkAyTTVZk2 d0CVvxck2gIxuLlFJFyvrOSFyY3qNtJ9w9TRu/ULuzPz6yQ4peipwY07lfNH71kmv9Tp QSrST1qu0azE3QoE2s0WKEwJtQMpq2emDwbCCKyk/E6KLIgoZFQ2Ot/qIhdCLx+DJ+v3 3G+c/yUaU8wF7/f01Z+VexteEHgTVxMbCvYmfw6EsrdSuvSOusxKLGfp/s8H1ZgfYBYZ 7DsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b="JEMt/1+D"; 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 k197-20020a633dce000000b005030eb175d1si3164865pga.107.2023.06.03.13.59.17; Sat, 03 Jun 2023 13:59:30 -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="JEMt/1+D"; 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 S232200AbjFCUy4 (ORCPT + 99 others); Sat, 3 Jun 2023 16:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232454AbjFCUyy (ORCPT ); Sat, 3 Jun 2023 16:54:54 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BB0C1B6; Sat, 3 Jun 2023 13:54:49 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 27D365FD34; Sat, 3 Jun 2023 23:54:47 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685825687; bh=22Y5ntJ+4qJ6mCXCPM4xdNhop4Y9r+djJZMggy4Cf+Y=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=JEMt/1+DlvTGWX7tlvjoLwRd2mXXxqUGwlX5UMfrqSe4pFX5w5M/NPCNJg0uANqHS pkfrfGq6qIwucGph3vNh6zV6e2ie20Lo8R+EFOd5wvWdUJB96BJ0ENwWsE9uWCxwIu cAzFOaUobK4Q1N7sNiFSqRSW4egMXEfqMRr/CxrHB4gaKFyKMlf3j+GWRWjMhdqGjO n21mhYdI2YHUhZhBIeFPDFeywgZvzgrgfHlVU5XJ03qigw4MG0x8yEl/Zjrc/QpCOQ l3becVRU1ix74gnK3cYaMheezkrmoZQkYCMMC1kHPFrsyxbkM+Gn7PF++n0niOV9Wm rGM9gBZnHfyPA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Sat, 3 Jun 2023 23:54:47 +0300 (MSK) 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: [RFC PATCH v4 04/17] vsock/virtio: non-linear skb handling for tap Date: Sat, 3 Jun 2023 23:49:26 +0300 Message-ID: <20230603204939.1598818-5-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230603204939.1598818-1-AVKrasnov@sberdevices.ru> References: <20230603204939.1598818-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/03 16:55:00 #21417531 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,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767716653127805587?= X-GMAIL-MSGID: =?utf-8?q?1767716653127805587?= 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 --- 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 5819a9cd4515..0de562c1dc4b 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(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;