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=GYCIX5/5; 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 9AC805A0288 for ; Mon, 23 Jun 2025 13:07:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750676850; 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=GYCIX5/5NMSr6TbiLoxGNCDdAlwnGU50F+6lH3Or0ceIXFvFAaaWCqIaao8AYarEmyvulj R6viJuSgD0fnTYxPjr9GxmolbphzXSX3CwhdJFNfAQHdDeRcN9uAJpa2uV/ZQUlgjL8nWQ j+lgtsp2jzRDHHx1hpafD8iUx3vp1To= 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-569-yRTgEi5yOC2uyiFPDIBShA-1; Mon, 23 Jun 2025 07:07:29 -0400 X-MC-Unique: yRTgEi5yOC2uyiFPDIBShA-1 X-Mimecast-MFC-AGG-ID: yRTgEi5yOC2uyiFPDIBShA_1750676848 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 8D7D11800287 for ; Mon, 23 Jun 2025 11:07:28 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.45.224.132]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 767071956096; Mon, 23 Jun 2025 11:07:27 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v7 27/31] ndp: use iov_tail rather than pool Date: Mon, 23 Jun 2025 13:06:31 +0200 Message-ID: <20250623110635.1478625-28-lvivier@redhat.com> In-Reply-To: <20250623110635.1478625-1-lvivier@redhat.com> References: <20250623110635.1478625-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5WyOSWyGl814DRzcETogpkxlqsFIMkqxxo3e4qqNazo_1750676848 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: EMJEXZWDK5YUHYDTJPCKEMHBJ73T6JGH X-Message-ID-Hash: EMJEXZWDK5YUHYDTJPCKEMHBJ73T6JGH 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