From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id D9CD15A004E for ; Fri, 05 Jul 2024 12:44:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1720176252; bh=iLfWagXOZsc6VF3f8Px5qUVMv/Fg6qw00EygifaWuKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LzAyp6gC0pV9O79jkd8nz4yH3KbnlJvlxHbQ1VQGCqvEsVO0i6vMFg216o4Sjicoo g8R9mrQq1g2BgjJ/PVqWgnJ3zztoPXAfPYdglkEfquS5g2kQW9Od+0oTNorMQFwR4V Xttxj0FRzFDTRxmOMWB7oDVC2kESMZL/VWE7n/RfrFzwoWG8H3+RKV4azZmSepazdX YrlrL15hLaikuexEf1pxtn+kqK/aBaIIUnyHmyf9KOwE3iGFo6Ds3SdtryqnDuxLvs IU1xe6lOq6qhBFcPCAA/s3h9JjRt6Fe0x4d3lGapA5LvE3/DQNDYrqpWlEWik2L3jn RrXjTjyvvrbVQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WFqrX0CZzz4x1y; Fri, 5 Jul 2024 20:44:12 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 07/11] udp: Don't repeatedly initialise udp[46]_eth_hdr Date: Fri, 5 Jul 2024 20:44:05 +1000 Message-ID: <20240705104409.3847002-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705104409.3847002-1-david@gibson.dropbear.id.au> References: <20240705104409.3847002-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 4IXADKWNJOTYOWGEIDAHXTVK6BCTDDHU X-Message-ID-Hash: 4IXADKWNJOTYOWGEIDAHXTVK6BCTDDHU X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Since we split our packet frame buffers into different pieces, we have a single buffer per IP version for the ethernet header, rather than one per frame. This makes sense since our ethernet header is alwaus the same. However we initialise those buffers udp[46]_eth_hdr inside a per frame loop. Pull that outside the loop so we just initialise them once. Signed-off-by: David Gibson --- udp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/udp.c b/udp.c index 8729dea2..2d403378 100644 --- a/udp.c +++ b/udp.c @@ -314,8 +314,6 @@ static void udp_iov_init_one(const struct ctx *c, size_t i) }; *siov = IOV_OF_LVALUE(payload->data); - udp4_eth_hdr.h_proto = htons_constant(ETH_P_IP); - udp6_eth_hdr.h_proto = htons_constant(ETH_P_IPV6); tiov[UDP_IOV_TAP] = tap_hdr_iov(c, &meta->taph); tiov[UDP_IOV_PAYLOAD].iov_base = payload; @@ -351,6 +349,9 @@ static void udp_iov_init(const struct ctx *c) { size_t i; + udp4_eth_hdr.h_proto = htons_constant(ETH_P_IP); + udp6_eth_hdr.h_proto = htons_constant(ETH_P_IPV6); + for (i = 0; i < UDP_MAX_FRAMES; i++) udp_iov_init_one(c, i); } -- 2.45.2