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=CQljeJoe; 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 78F275A0285 for ; Wed, 04 Jun 2025 15:09:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749042551; 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=YAsJjwKbnoXHJaqidNO20L/rHHJqPkv5zzOm52j5EDg=; b=CQljeJoevTosmmCALXHrwGMBv+CR3GEE+48D2JOyoZt+LXfcVOxd3EAYnaSoxITrUpVft4 1T2T9PU9EMIYoV+RdwMCA3tX0wOp6Ex1K96gJ/S14XM7vn5jOfv8+1iescByawN4V54UkQ P/bdOj9twGQmyMybMDFLdDitUzOSePc= 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-130-Q0sfo1fVMwerIycm7iwAxA-1; Wed, 04 Jun 2025 09:09:08 -0400 X-MC-Unique: Q0sfo1fVMwerIycm7iwAxA-1 X-Mimecast-MFC-AGG-ID: Q0sfo1fVMwerIycm7iwAxA_1749042547 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 5D75B18002BE; Wed, 4 Jun 2025 13:09:07 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.45.225.52]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 42B551955DDA; Wed, 4 Jun 2025 13:09:05 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v6 15/30] dhcpv6: Convert to iov_tail Date: Wed, 4 Jun 2025 15:08:19 +0200 Message-ID: <20250604130834.3868010-16-lvivier@redhat.com> In-Reply-To: <20250604130834.3868010-1-lvivier@redhat.com> References: <20250604130834.3868010-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: v3L19hmsDAqicTT-ny0QKV_VAsZafgRspwswtfOsLfg_1749042547 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: 5VCGGT7IGWUZFISH3PUU3BHG5VJSL5AM X-Message-ID-Hash: 5VCGGT7IGWUZFISH3PUU3BHG5VJSL5AM 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: Use packet_data() and extract headers using IOV_REMOVE_HEADER() and IOV_PEEK_HEADER() rather than packet_get(). Signed-off-by: Laurent Vivier Reviewed-by: David Gibson --- dhcpv6.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dhcpv6.c b/dhcpv6.c index 8e6c29df205d..ae06e646f92f 100644 --- a/dhcpv6.c +++ b/dhcpv6.c @@ -533,12 +533,18 @@ int dhcpv6(struct ctx *c, const struct pool *p, { const struct opt_hdr *client_id, *server_id, *ia; const struct in6_addr *src; + struct msg_hdr mh_storage; const struct msg_hdr *mh; + struct udphdr uh_storage; const struct udphdr *uh; struct opt_hdr *bad_ia; + struct iov_tail data; size_t mlen, n; - uh = packet_get(p, 0, 0, sizeof(*uh), &mlen); + if (!packet_data(p, 0, &data)) + return -1; + + uh = IOV_REMOVE_HEADER(&data, uh_storage); if (!uh) return -1; @@ -551,6 +557,7 @@ int dhcpv6(struct ctx *c, const struct pool *p, if (!IN6_IS_ADDR_MULTICAST(daddr)) return -1; + mlen = iov_tail_size(&data); if (mlen + sizeof(*uh) != ntohs(uh->len) || mlen < sizeof(*mh)) return -1; @@ -558,7 +565,7 @@ int dhcpv6(struct ctx *c, const struct pool *p, src = &c->ip6.our_tap_ll; - mh = packet_get(p, 0, sizeof(*uh), sizeof(*mh), NULL); + mh = IOV_PEEK_HEADER(&data, mh_storage); if (!mh) return -1; -- 2.49.0