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=RWppoaMi; 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 B60495A061A for ; Wed, 16 Apr 2025 17:26:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744817215; 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=CdMbptencZWl7LEZYF82KtXUrinqKn37YGsl7UlN0zw=; b=RWppoaMiKFJ/ayAo8kgzZ8KbLa3D1q+Vo9aegKH7fYj+JTaX2K+6buoRls34XrixS3d17U RFjkVnw6TgySSj6hH3Hmevw+pNddPhM+m+dyGLkmr7aWRETtwnDSvlT6+mwiziDgo0s+Id QoO+WXWPr8IXd0WgUXbcQ2L601Qwi8g= 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-605-09GfcuHMNUWYjQiR0ZIX2Q-1; Wed, 16 Apr 2025 11:26:54 -0400 X-MC-Unique: 09GfcuHMNUWYjQiR0ZIX2Q-1 X-Mimecast-MFC-AGG-ID: 09GfcuHMNUWYjQiR0ZIX2Q_1744817213 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 AB0E91800876 for ; Wed, 16 Apr 2025 15:26:53 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.32.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9B7761956095; Wed, 16 Apr 2025 15:26:52 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v4 25/28] ndp: use iov_tail rather than pool Date: Wed, 16 Apr 2025 17:26:02 +0200 Message-ID: <20250416152605.3947623-26-lvivier@redhat.com> In-Reply-To: <20250416152605.3947623-1-lvivier@redhat.com> References: <20250416152605.3947623-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: i15pDpS2E2fH4XKRwbZjzOfOflBdo5slcdbiRdVOyAM_1744817213 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: A2LGHDGLDIF2RX74GOIGC4V6XP6GPMO5 X-Message-ID-Hash: A2LGHDGLDIF2RX74GOIGC4V6XP6GPMO5 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: Signed-off-by: Laurent Vivier --- ndp.c | 16 ++++++++-------- ndp.h | 4 ++-- tap.c | 10 +++------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/ndp.c b/ndp.c index b09a1a133f56..95cb1d983f12 100644 --- a/ndp.c +++ b/ndp.c @@ -336,13 +336,17 @@ static void ndp_ra(const struct ctx *c, const struct in6_addr *dst) * @c: Execution context * @ih: ICMPv6 header * @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 ihc; + const struct icmp6hdr *ih; + + ih = IOV_PEEK_HEADER(data, ihc); if (ih->icmp6_type < RS || ih->icmp6_type > NA) return 0; @@ -351,13 +355,9 @@ int ndp(const struct ctx *c, const struct icmp6hdr *ih, if (ih->icmp6_type == NS) { const struct ndp_ns *ns; - struct iov_tail data; struct ndp_ns nsc; - if (!packet_data(p, 0, &data)) - return -1; - - ns = IOV_REMOVE_HEADER(&data, nsc); + ns = IOV_REMOVE_HEADER(data, nsc); 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 d70e387fa7cc..3b5315cf541d 100644 --- a/tap.c +++ b/tap.c @@ -940,9 +940,7 @@ resume: } if (proto == IPPROTO_ICMPV6) { - const struct icmp6hdr *l4h; - struct icmp6hdr l4hc; - PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); + struct iov_tail ndp_data; if (c->no_icmp) continue; @@ -950,10 +948,8 @@ resume: if (l4len < sizeof(struct icmp6hdr)) continue; - packet_add(pkt, &data); - - l4h = IOV_PEEK_HEADER(&data, l4hc); - 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