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=NsvBbWhE; 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 3C5D05A0272 for ; Wed, 02 Apr 2025 19:24:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743614639; 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=i0xpsYtIf8O1JLP5saMxnh6xgMZQNQ60bIRZsYzEOWE=; b=NsvBbWhEuU+u36vB3V7m3nF9gnIb6cUirlYKAi8FkSLQjRk4qOYNXnA8qeBWX2mswJkLd/ DFzGkPIi7+ErASHPUfX9Uh3C/laC7nRziLWr2/eBNKnxCr5NJV8s25/QIqWxvbzWAmzWdo SezJYorQYBJm9IE0GXRK4GfUJ7fPiRg= 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-261-WysXsQr7McmYwGoDNnPjUw-1; Wed, 02 Apr 2025 13:23:55 -0400 X-MC-Unique: WysXsQr7McmYwGoDNnPjUw-1 X-Mimecast-MFC-AGG-ID: WysXsQr7McmYwGoDNnPjUw_1743614635 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 1B426180025E for ; Wed, 2 Apr 2025 17:23:55 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.33.101]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0A66219560AD; Wed, 2 Apr 2025 17:23:53 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 06/18] arp: Convert to iov_tail Date: Wed, 2 Apr 2025 19:23:31 +0200 Message-ID: <20250402172343.858187-7-lvivier@redhat.com> In-Reply-To: <20250402172343.858187-1-lvivier@redhat.com> References: <20250402172343.858187-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Q0EJ1hM4CS7Dv6oP-Rgxa_z4-MZAROGdARGt8so-1U4_1743614635 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: 7RI4YZMVOOJPR4PHUMRQA6YNURFBK6B4 X-Message-ID-Hash: 7RI4YZMVOOJPR4PHUMRQA6YNURFBK6B4 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: Use packet_base() and extract headers using IOV_REMOVE_HEADER() rather than packet_get(). Signed-off-by: Laurent Vivier --- arp.c | 12 +++++++++--- packet.c | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arp.c b/arp.c index 9d68d7c3b602..cd0e15de7de0 100644 --- a/arp.c +++ b/arp.c @@ -77,11 +77,17 @@ int arp(const struct ctx *c, const struct pool *p) const struct ethhdr *eh; const struct arphdr *ah; const struct arpmsg *am; + struct iov_tail data; + struct arphdr ahc; + struct ethhdr ehc; + struct arpmsg amc; - 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_base(p, 0, &data)) + return -1; + eh = IOV_REMOVE_HEADER(&data, ehc); + ah = IOV_REMOVE_HEADER(&data, ahc); + am = IOV_REMOVE_HEADER(&data, amc); if (!eh || !ah || !am) return -1; diff --git a/packet.c b/packet.c index 25ede38b94cb..8066ac12502b 100644 --- a/packet.c +++ b/packet.c @@ -165,7 +165,6 @@ void *packet_get_do(const struct pool *p, size_t idx, size_t offset, * * Return: pointer to start of data range, NULL on invalid range or descriptor */ -/* cppcheck-suppress unusedFunction */ bool packet_base_do(const struct pool *p, size_t idx, struct iov_tail *data, const char *func, int line) -- 2.49.0