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 1513D5A004F for ; Thu, 04 Jul 2024 06:58:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1720069127; bh=ZOPIFWeJGH4XOZyNe18Muc6EcSH3zjUCpQuD21353d8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JRBsS7CeZFoPHh8GeyEKu96ZDePhi4v37I99fL3kVurvDLPJoUC2i1r4LNYM5PiVg lzz0bRX4w6YrV82XborSh6gcAtvAnhcPrGVP9xAFnjjemsJz6crJ1mbpYouOesyMJX MtVlFxHhvQdsCaZu6nK6g1dcg/0DA/OMq1e75j5OHSBoC1A4XG7ymR26tajxQG/jv9 swF8EkcXUYHlx5U+aY+i8E2SyWSCm6nf1YxH699pJaQUc23gvB6rQGk79S1zHTEWp4 sWNl1AH5UiR46aC4G0476dWNnRFr+wBgeDadCWhxpysKbaKfQ5c0G99XZq/iqjbdRe 7aXFuAaibVV7g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WF4DR4Jnkz4x1V; Thu, 4 Jul 2024 14:58:47 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 07/11] udp: Don't repeatedly initialise udp[46]_eth_hdr Date: Thu, 4 Jul 2024 14:58:31 +1000 Message-ID: <20240704045835.1149746-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240704045835.1149746-1-david@gibson.dropbear.id.au> References: <20240704045835.1149746-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: EFJ3WMMZAMCUUSPW6X43GYP7EQJ3ZD65 X-Message-ID-Hash: EFJ3WMMZAMCUUSPW6X43GYP7EQJ3ZD65 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 454f9e74..c841d389 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