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=QYies1ZI; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id E631B5A0279 for ; Tue, 05 Aug 2025 17:47:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754408841; 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=rfjKFdQypVfrSSZW0yozBJMol4hPhitD6E/Ld4wd3lI=; b=QYies1ZIoGDgi6NqNaW4gR1WEJFmwtxM1aGat7UB4ClwkYDQIz7L9IWkSJt/TtgEOqx0/p omWGHRADYLX4Y/PQU0yzlsJ10HCYCQMmfeguiIhuETg6gf+qtSant1aXIfCSyR14Zy0cft AhEwJrF7+Gg5O7X86hqwFGbma+Kz/DY= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-341-mgJMHj2qNxqbsC-1sx_1PA-1; Tue, 05 Aug 2025 11:47:19 -0400 X-MC-Unique: mgJMHj2qNxqbsC-1sx_1PA-1 X-Mimecast-MFC-AGG-ID: mgJMHj2qNxqbsC-1sx_1PA_1754408839 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DDF831800773 for ; Tue, 5 Aug 2025 15:47:18 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.45.225.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C8B921955E88; Tue, 5 Aug 2025 15:47:17 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v8 26/30] ndp: use iov_tail rather than pool Date: Tue, 5 Aug 2025 17:46:24 +0200 Message-ID: <20250805154628.301343-27-lvivier@redhat.com> In-Reply-To: <20250805154628.301343-1-lvivier@redhat.com> References: <20250805154628.301343-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 18Kefc3QWM-I6UFQNeI_9TSoQU0nSUDgO8YlukTzE3c_1754408839 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: 2PODSXJ62PUVSX3JKKEZNDPMLTSHSC4S X-Message-ID-Hash: 2PODSXJ62PUVSX3JKKEZNDPMLTSHSC4S 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 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: The ndp() function signature is changed to accept `struct iov_tail *data` directly, replacing the previous `const struct pool *p` and `const struct icmp6hdr *ih` parameters. This change simplifies callers, like tap6_handler(), which now provide the iov_tail representing the L4 ICMPv6 segment directly to ndp(). Signed-off-by: Laurent Vivier --- ndp.c | 19 +++++++++++-------- ndp.h | 4 ++-- tap.c | 10 +++------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ndp.c b/ndp.c index ba87a0aaa6e9..eb090cd2c5a7 100644 --- a/ndp.c +++ b/ndp.c @@ -336,13 +336,20 @@ static void ndp_ra(const struct ctx *c, const struct in6_addr *dst) * ndp() - Check for NDP solicitations, reply as needed * @c: Execution context * @saddr: Source IPv6 address - * @p: Packet pool + * @data: Single packet with ICMPv6 header * * Return: 0 if not handled here, 1 if handled, -1 on failure */ -int ndp(const struct ctx *c, const struct icmp6hdr *ih, - const struct in6_addr *saddr, const struct pool *p) +int ndp(const struct ctx *c, const struct in6_addr *saddr, + struct iov_tail *data) { + struct icmp6hdr ih_storage; + const struct icmp6hdr *ih; + + ih = IOV_PEEK_HEADER(data, ih_storage); + if (!ih) + return -1; + if (ih->icmp6_type < RS || ih->icmp6_type > NA) return 0; @@ -352,12 +359,8 @@ int ndp(const struct ctx *c, const struct icmp6hdr *ih, if (ih->icmp6_type == NS) { struct ndp_ns ns_storage; const struct ndp_ns *ns; - struct iov_tail data; - - if (!packet_get(p, 0, &data)) - return -1; - ns = IOV_REMOVE_HEADER(&data, ns_storage); + ns = IOV_REMOVE_HEADER(data, ns_storage); if (!ns) return -1; diff --git a/ndp.h b/ndp.h index 41c2000356ec..b1dd5e82c085 100644 --- a/ndp.h +++ b/ndp.h @@ -8,8 +8,8 @@ struct icmp6hdr; -int ndp(const struct ctx *c, const struct icmp6hdr *ih, - const struct in6_addr *saddr, const struct pool *p); +int ndp(const struct ctx *c, const struct in6_addr *saddr, + struct iov_tail *data); void ndp_timer(const struct ctx *c, const struct timespec *now); #endif /* NDP_H */ diff --git a/tap.c b/tap.c index 48152a84674c..d327ec0c3d54 100644 --- a/tap.c +++ b/tap.c @@ -942,9 +942,7 @@ resume: } if (proto == IPPROTO_ICMPV6) { - struct icmp6hdr l4h_storage; - const struct icmp6hdr *l4h; - PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); + struct iov_tail ndp_data; if (c->no_icmp) continue; @@ -952,10 +950,8 @@ resume: if (l4len < sizeof(struct icmp6hdr)) continue; - packet_add(pkt, &data); - - l4h = IOV_PEEK_HEADER(&data, l4h_storage); - if (ndp(c, (struct icmp6hdr *)l4h, saddr, pkt)) + ndp_data = data; + if (ndp(c, saddr, &ndp_data)) continue; tap_packet_debug(NULL, ip6h, NULL, proto, NULL, 1); -- 2.49.0