From nobody Wed Nov 27 06:39:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1700299799; cv=none; d=zohomail.com; s=zohoarc; b=WrA/1HG+Ee8bVYls5jxyiQss6/IQJeeIV9zPCEQWJdl3k3MoEFLMOMWF3/fpqOUxIQXvA6G9mPVHKutmWKkVbXYRciuXKZJLw7oIdcwJdJkb8oUiE6j7IFG1Hg9ndUl157ztCM9+SDva27hXnjRgpmpns0JUmXzfG28F/GrmJVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700299799; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:Message-Id:Reply-To:To; bh=xzliMeH7ucLi+5KlHbqTM6VmGafQ4Ql4J7jH/gf4kF0=; b=MHdHsE/HvlVnKg7jf/6CucCW/m/pKB2/dMUwXL0tD0pQA38CCWsxUBSuB1SsG4mJ4i1gbxkuDZfn7KCF7VYhj66eoOvTOvQvwfwYqJycULZfGI/DYDeqHKE1sfxSgkoUxswR6++WLp3udHcYp0ge8OluwM9cel413DKQE5GzS3A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17002997997543.522125392797875; Sat, 18 Nov 2023 01:29:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r4Hb2-0006DR-5S; Sat, 18 Nov 2023 04:26:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r4Hb0-0006D4-BQ for qemu-devel@nongnu.org; Sat, 18 Nov 2023 04:26:34 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4Hay-0003iT-Uf for qemu-devel@nongnu.org; Sat, 18 Nov 2023 04:26:34 -0500 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5b8f68ba4e5so2048056a12.1 for ; Sat, 18 Nov 2023 01:26:32 -0800 (PST) Received: from localhost ([157.82.205.15]) by smtp.gmail.com with UTF8SMTPSA id p4-20020a170902bd0400b001b850c9d7b3sm2616635pls.249.2023.11.18.01.26.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Nov 2023 01:26:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1700299591; x=1700904391; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xzliMeH7ucLi+5KlHbqTM6VmGafQ4Ql4J7jH/gf4kF0=; b=jxvYL/GrKparnqkeTszKyZLm0oitUDwJAFazCO/Jk7QqbmB28szutcnb2jrocxVVWA +DNWNqQg4vwEBfnw+zqoSCImZotjZ5+zSitkjHmo7vFtxvOk9iqxL7HV37aXPTqkmkyk UiGdTy1RQZGs5g5WlqX3qjtnMF5qH6SuSMQz7RvzdsYlaFDS6CXAh7a33o/9l7ViKheA 17RO+WKo3tF5dPasIfzjspFi3HRVPSywZ9n50htk07IjofLZ1g6U4XzGKD1aodliKJbf 6re1jPUt+tME6B1J1FZOwdmbyXrB9+nhLcyMxlJQQ8EoQBmuOeFc8pBi6jmLJgGp2iRw isFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700299591; x=1700904391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xzliMeH7ucLi+5KlHbqTM6VmGafQ4Ql4J7jH/gf4kF0=; b=Sd75xzxlXPP30tvpxjHRZ/onq+pKK//mY45Ju8smJS9sePS25ggv4dGBLfBKob3m5q YcAhuaN7hMeEsVaNwguhdq4kcq/K2CebtpTlbqIjPWh6+V6uUxKAac+V3y5f+OZjhJ+h Of8vtGloxs8wlnChW+rel+/revuu4jbKInx7Pnimtyq6IlTFpjAV0mSu2XkwfP5L8sei dNUvF+YmKfhDFOZqM0nDa9DnMZDY0Po0drhgfFdXTuyQB/T8M4w9Cu49BPnULvQW+sGv 2w5C7nu04l9G4Iq7k7Vfaky53mZ0P3jZlxFIR6M34593ux5ZrzFf21TRiL+RGmmMsjYn 5ffg== X-Gm-Message-State: AOJu0YxzZFuXEiyFVXup9jWXBDqx/tPha6abRWlmRfqGKjCyrzkHKeO9 +rHGEiCwku+pYbdgG+3d/XSEW0asMVYhnUXfBbk= X-Google-Smtp-Source: AGHT+IH3RcI//cpbXHlTwdcpLFs3V+n9uQ1Tb1qIUPDPUO4LwCzhasoVuPFWHURMXoX7jIGlLP/zBg== X-Received: by 2002:a17:903:22cb:b0:1cc:e76e:f216 with SMTP id y11-20020a17090322cb00b001cce76ef216mr2305074plg.24.1700299591488; Sat, 18 Nov 2023 01:26:31 -0800 (PST) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , "Zhang, Chen" , Akihiko Odaki Subject: [PATCH RESEND v7 05/19] tap: Call tap_receive_iov() from tap_receive() Date: Sat, 18 Nov 2023 18:25:45 +0900 Message-ID: <20231118092601.7132-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231118092601.7132-1-akihiko.odaki@daynix.com> References: <20231118092601.7132-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::52c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1700299800088100001 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki This will save duplicate logic found in both of tap_receive_iov() and tap_receive(). Suggested-by: "Zhang, Chen" Signed-off-by: Akihiko Odaki --- net/tap.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/net/tap.c b/net/tap.c index 09ad8ae255..4d450d2972 100644 --- a/net/tap.c +++ b/net/tap.c @@ -133,39 +133,14 @@ static ssize_t tap_receive_iov(NetClientState *nc, co= nst struct iovec *iov, return tap_write_packet(s, iovp, iovcnt); } =20 -static ssize_t tap_receive_raw(NetClientState *nc, const uint8_t *buf, siz= e_t size) -{ - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); - struct iovec iov[2]; - int iovcnt =3D 0; - struct virtio_net_hdr_mrg_rxbuf hdr =3D { }; - - if (s->host_vnet_hdr_len) { - iov[iovcnt].iov_base =3D &hdr; - iov[iovcnt].iov_len =3D s->host_vnet_hdr_len; - iovcnt++; - } - - iov[iovcnt].iov_base =3D (char *)buf; - iov[iovcnt].iov_len =3D size; - iovcnt++; - - return tap_write_packet(s, iov, iovcnt); -} - static ssize_t tap_receive(NetClientState *nc, const uint8_t *buf, size_t = size) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); - struct iovec iov[1]; - - if (s->host_vnet_hdr_len && !s->using_vnet_hdr) { - return tap_receive_raw(nc, buf, size); - } - - iov[0].iov_base =3D (char *)buf; - iov[0].iov_len =3D size; + struct iovec iov =3D { + .iov_base =3D (void *)buf, + .iov_len =3D size + }; =20 - return tap_write_packet(s, iov, 1); + return tap_receive_iov(nc, &iov, 1); } =20 #ifndef __sun__ --=20 2.42.1