From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jD8sSXvk; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 4E5CC5A0262 for ; Tue, 16 Jun 2026 14:51:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781614297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zG/jDQPWH5kEhcde3rsdsGVHIC45gDY2dBgQ93Dmo4A=; b=jD8sSXvkzfrWq4dm7PiLeclFJNNvOjKZMEJnW31tLTN8Can6yM/hos0gyaTu49JHDkzPJm PQjIJl0YPG8FalmwCUzzgpoc47STBrSTVK9XboCK8PUqAhVAlI+QXR/MIBC5rPLikPyjmU GZ+VmwB1n6IrVEczqtGej+Ky9d0Shyo= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-354-0hov1g1_P4GzN2mL_fQb-Q-1; Tue, 16 Jun 2026 08:51:36 -0400 X-MC-Unique: 0hov1g1_P4GzN2mL_fQb-Q-1 X-Mimecast-MFC-AGG-ID: 0hov1g1_P4GzN2mL_fQb-Q_1781614295 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C678019540DE; Tue, 16 Jun 2026 12:51:34 +0000 (UTC) Received: from lenovo-t14s.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 614C11800591; Tue, 16 Jun 2026 12:51:33 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v5 01/12] tap: Remove pool parameter from tap4_handler() and tap6_handler() Date: Tue, 16 Jun 2026 14:51:19 +0200 Message-ID: <20260616125130.1324274-2-lvivier@redhat.com> In-Reply-To: <20260616125130.1324274-1-lvivier@redhat.com> References: <20260616125130.1324274-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: giOqVZt1NjQPeEqrWuX6Xg_xuynYXMg9QPME8Itp1Yk_1781614295 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: IFKJLKZNLFYTKRYH56F24I2ILELOCLBQ X-Message-ID-Hash: IFKJLKZNLFYTKRYH56F24I2ILELOCLBQ X-MailFrom: lvivier@redhat.com 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: Laurent Vivier , 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: These handlers only ever operate on their respective global pools (pool_tap4 and pool_tap6). The pool parameter was always passed the same value, making it unnecessary indirection. Access the global pools directly instead, simplifying the function signatures. Signed-off-by: Laurent Vivier Reviewed-by: David Gibson --- tap.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/tap.c b/tap.c index 4cba4c785617..4699c5ef9177 100644 --- a/tap.c +++ b/tap.c @@ -699,23 +699,21 @@ static bool tap4_is_fragment(const struct iphdr *iph, /** * tap4_handler() - IPv4 and ARP packet handler for tap file descriptor * @c: Execution context - * @in: Ingress packet pool, packets with Ethernet headers * @now: Current timestamp * * Return: count of packets consumed by handlers */ -static int tap4_handler(struct ctx *c, const struct pool *in, - const struct timespec *now) +static int tap4_handler(struct ctx *c, const struct timespec *now) { unsigned int i, j, seq_count; struct tap4_l4_t *seq; - if (!c->ifi4 || !in->count) - return in->count; + if (!c->ifi4 || !pool_tap4->count) + return pool_tap4->count; i = 0; resume: - for (seq_count = 0, seq = NULL; i < in->count; i++) { + for (seq_count = 0, seq = NULL; i < pool_tap4->count; i++) { size_t l3len, hlen, l4len; struct ethhdr eh_storage; struct iphdr iph_storage; @@ -725,7 +723,7 @@ resume: struct iov_tail data; struct iphdr *iph; - if (!packet_get(in, i, &data)) + if (!packet_get(pool_tap4, i, &data)) continue; eh = IOV_PEEK_HEADER(&data, eh_storage); @@ -797,7 +795,7 @@ resume: if (iph->protocol == IPPROTO_UDP) { struct iov_tail eh_data; - packet_get(in, i, &eh_data); + packet_get(pool_tap4, i, &eh_data); if (dhcp(c, &eh_data)) continue; } @@ -828,7 +826,7 @@ resume: goto append; if (seq_count == TAP_SEQS) - break; /* Resume after flushing if i < in->count */ + break; /* Resume after flushing if i < pool_tap4->count */ for (seq = tap4_l4 + seq_count - 1; seq >= tap4_l4; seq--) { if (L4_MATCH(iph, uh, seq)) { @@ -874,10 +872,10 @@ append: } } - if (i < in->count) + if (i < pool_tap4->count) goto resume; - return in->count; + return pool_tap4->count; } #define IPV6_NH_OPT(nh) \ @@ -935,23 +933,21 @@ found: /** * tap6_handler() - IPv6 packet handler for tap file descriptor * @c: Execution context - * @in: Ingress packet pool, packets with Ethernet headers * @now: Current timestamp * * Return: count of packets consumed by handlers */ -static int tap6_handler(struct ctx *c, const struct pool *in, - const struct timespec *now) +static int tap6_handler(struct ctx *c, const struct timespec *now) { unsigned int i, j, seq_count = 0; struct tap6_l4_t *seq; - if (!c->ifi6 || !in->count) - return in->count; + if (!c->ifi6 || !pool_tap6->count) + return pool_tap6->count; i = 0; resume: - for (seq_count = 0, seq = NULL; i < in->count; i++) { + for (seq_count = 0, seq = NULL; i < pool_tap6->count; i++) { size_t l4len, plen, check; struct in6_addr *saddr, *daddr; struct ipv6hdr ip6h_storage; @@ -963,7 +959,7 @@ resume: struct ipv6hdr *ip6h; uint8_t proto; - if (!packet_get(in, i, &data)) + if (!packet_get(pool_tap6, i, &data)) return -1; eh = IOV_REMOVE_HEADER(&data, eh_storage); @@ -1076,7 +1072,7 @@ resume: goto append; if (seq_count == TAP_SEQS) - break; /* Resume after flushing if i < in->count */ + break; /* Resume after flushing if i < pool_tap6->count */ for (seq = tap6_l4 + seq_count - 1; seq >= tap6_l4; seq--) { if (L4_MATCH(ip6h, proto, uh, seq)) { @@ -1123,10 +1119,10 @@ append: } } - if (i < in->count) + if (i < pool_tap6->count) goto resume; - return in->count; + return pool_tap6->count; } /** @@ -1145,8 +1141,8 @@ void tap_flush_pools(void) */ void tap_handler(struct ctx *c, const struct timespec *now) { - tap4_handler(c, pool_tap4, now); - tap6_handler(c, pool_tap6, now); + tap4_handler(c, now); + tap6_handler(c, now); } /** @@ -1182,14 +1178,14 @@ void tap_add_packet(struct ctx *c, struct iov_tail *data, case ETH_P_ARP: case ETH_P_IP: if (!pool_can_fit(pool_tap4, data)) { - tap4_handler(c, pool_tap4, now); + tap4_handler(c, now); pool_flush(pool_tap4); } packet_add(pool_tap4, data); break; case ETH_P_IPV6: if (!pool_can_fit(pool_tap6, data)) { - tap6_handler(c, pool_tap6, now); + tap6_handler(c, now); pool_flush(pool_tap6); } packet_add(pool_tap6, data); -- 2.54.0