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=QU6mkVob; 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 D22BD5A027A for ; Tue, 02 Sep 2025 09:53:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756799594; 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=RaGnL2QV0KutpQT/hw5ETwkhH9PiJaJI+GpWDVrxB4Q=; b=QU6mkVobhHlhVEzibLDtbcd0aIeAMwvVlJc+/oOtsjqWZBdlb2IZ+FMNUWOe/jUx8BkhE+ StUaZ1eDmOtRCbryHKDx3fBhdq8+ypSiw7Ust0XY1aula0fwLWQpCY1hUnWdJfayUyPhHi zAuOeLe8JArWGgNG8juucNTFQYXKWUM= Received: from mx-prod-mc-02.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-326-2YsMF7TKPtuR2sDU4FEAbw-1; Tue, 02 Sep 2025 03:53:13 -0400 X-MC-Unique: 2YsMF7TKPtuR2sDU4FEAbw-1 X-Mimecast-MFC-AGG-ID: 2YsMF7TKPtuR2sDU4FEAbw_1756799592 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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A1FDC195608E; Tue, 2 Sep 2025 07:53:12 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.45.224.111]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 28B261800447; Tue, 2 Sep 2025 07:53:10 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v11 07/30] arp: Convert to iov_tail Date: Tue, 2 Sep 2025 09:52:30 +0200 Message-ID: <20250902075253.990038-8-lvivier@redhat.com> In-Reply-To: <20250902075253.990038-1-lvivier@redhat.com> References: <20250902075253.990038-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: Y3_2ptTo6uN6ExjACnqAB-U-nnLNvxuKxPK8jpi-wz8_1756799592 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: T2VYUWYXU62QF5PTBIKQR5USXCPRDTXH X-Message-ID-Hash: T2VYUWYXU62QF5PTBIKQR5USXCPRDTXH 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() rather than packet_get(). Signed-off-by: Laurent Vivier Reviewed-by: David Gibson --- arp.c | 12 +++++++++--- packet.c | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arp.c b/arp.c index 9f1fedeafec0..b3ac42082841 100644 --- a/arp.c +++ b/arp.c @@ -74,14 +74,20 @@ int arp(const struct ctx *c, const struct pool *p) struct arphdr ah; struct arpmsg am; } __attribute__((__packed__)) resp; + struct arphdr ah_storage; + struct ethhdr eh_storage; + struct arpmsg am_storage; const struct ethhdr *eh; const struct arphdr *ah; const struct arpmsg *am; + struct iov_tail data; - eh = packet_get(p, 0, 0, sizeof(*eh), NULL); - ah = packet_get(p, 0, sizeof(*eh), sizeof(*ah), NULL); - am = packet_get(p, 0, sizeof(*eh) + sizeof(*ah), sizeof(*am), NULL); + if (!packet_data(p, 0, &data)) + return -1; + eh = IOV_REMOVE_HEADER(&data, eh_storage); + ah = IOV_REMOVE_HEADER(&data, ah_storage); + am = IOV_REMOVE_HEADER(&data, am_storage); if (!eh || !ah || !am) return -1; diff --git a/packet.c b/packet.c index 82adc9fd1a39..34b1722b9a03 100644 --- a/packet.c +++ b/packet.c @@ -201,7 +201,6 @@ void *packet_get_do(const struct pool *p, const size_t idx, * Return: false if packet index is invalid, true otherwise. * If something wrong with @data, don't return at all (assert). */ -/* cppcheck-suppress unusedFunction */ bool packet_data_do(const struct pool *p, size_t idx, struct iov_tail *data, const char *func, int line) -- 2.50.1