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=cFh5Zyfv; 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 CFB165A0271 for ; Thu, 07 Aug 2025 15:11:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754572308; 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=PY1ZDA3aPa1StlcXxfija96Igph3NBIjLAW2fMZJTyM=; b=cFh5Zyfvrv+z9MiaNJEfel8q32ha/Tvi3NJF4GN5BPyk/UYMJF8ntr/mUxTBsoxuWgDn/9 hREVkjZxxOX3erLIED3EK5pgmzxCrmmpPNag9cdiaiy5ZJClDXTmLE8nYaTEF5jfnThGfk d6MTaXDm5EnOnx9K5zFvLfN23y/PMto= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-zGjuoRloOhWc6rBUzPeItg-1; Thu, 07 Aug 2025 09:11:47 -0400 X-MC-Unique: zGjuoRloOhWc6rBUzPeItg-1 X-Mimecast-MFC-AGG-ID: zGjuoRloOhWc6rBUzPeItg_1754572306 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-617d299bda5so208615a12.3 for ; Thu, 07 Aug 2025 06:11:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754572305; x=1755177105; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=PY1ZDA3aPa1StlcXxfija96Igph3NBIjLAW2fMZJTyM=; b=vgIk/+MvyqTEWO100J6mvLciFcUqVB33uTWvARwhn0zmnRpAp9pvv3I1GF8Z7jAGwU VxMj1pj5GlWeqH/4aiJV2jOTWeFdpk/wJdbn+NBDLOw7dyEJOQHy75qQ7ok8atj52QXP GXw7Jd+GnPWGhR/bvSKvFn9xPSMvlRS8cIy02CBJY/IFJPNQmWVSO1ZGOHowlIWtsR11 tWP9a6H7URsy2GVrScpADfllQROMB2l3Jvt0b6lWx8qjs25NkGjH80d3S1re5XxBcLNz f7GTY5w/5cRRWD1nRbpT3lUE1AYL7LrVq5A8IqNMtvFFvJ/2wtcdEuWp9IPz/G2zTizK PDug== X-Gm-Message-State: AOJu0YxiHTjd5d4VZ/oz0H+oe9aPImDedeptu7R07YmrBgrC4na7cdua K8B+S9ZfzIGRnJCe1A6w09a7dVSNMqC572a3//amd/y1o22/l5q2oAjLapRW1sxC7cZtQBWnBtE V6T56MyAN1BqSVHyoSXeXDVXtPBCM3hUtatyuRLS7yaHS4sbBiiK9Zw== X-Gm-Gg: ASbGncsDplEisnjT66mzPH7uWst7Vhl4oyE3vl5swYQUbsz+3Ekc1jrJ6/gs0bYptDn bG0RrKmt9AGYsuObv6Dk4owEgZvnxLjTWJ+jp9X1MXOjqcTYEzW3y3HoL6AKTT/Ahx/SDgm6Pps z6kp+Y8BZnh8VjnEIVngTT5uteJFcG/vSvCZtVk4zthjr2iKV6xTJChdlXdgS1EqgnIuu2Up4dL P9RvL5APiDOEi7TEg3mQ6/5+Kdem6EXNS+JXhnz2xFl3EaQtBiatGprhzkI8Pom2v8r9SeZAVYg xbr0Iw5YIVdX5oLqr0IapEJBSoZ6i6st60ibev9DxOQEwcb2M9g= X-Received: by 2002:a05:6000:4305:b0:3a5:57b7:cd7b with SMTP id ffacd0b85a97d-3b8f48dd912mr5748508f8f.22.1754572294926; Thu, 07 Aug 2025 06:11:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4qFOrAzPbIeH3bZXpGEYBrZp5bDysv3jFXZngAmgA1mlJD/Viin9hvnX+Ol1s1s0YiRrPeQ== X-Received: by 2002:a05:6000:4305:b0:3a5:57b7:cd7b with SMTP id ffacd0b85a97d-3b8f48dd912mr5748481f8f.22.1754572294372; Thu, 07 Aug 2025 06:11:34 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b79c3b95desm26266802f8f.20.2025.08.07.06.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Aug 2025 06:11:33 -0700 (PDT) Date: Thu, 7 Aug 2025 15:11:32 +0200 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v8 07/30] arp: Convert to iov_tail Message-ID: <20250807151132.07d1a154@elisabeth> In-Reply-To: <6e7993ce-e668-42dd-83ef-45907e1e66fa@redhat.com> References: <20250805154628.301343-1-lvivier@redhat.com> <20250805154628.301343-8-lvivier@redhat.com> <6e7993ce-e668-42dd-83ef-45907e1e66fa@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: BmmzK3UvoyO6gPJzIIukHA91t0kdUxqf5peEFis4fNc_1754572306 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 5VJUUHABFFDPHIMOIK2GTOMXC3TI3ZV5 X-Message-ID-Hash: 5VJUUHABFFDPHIMOIK2GTOMXC3TI3ZV5 X-MailFrom: sbrivio@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: passt-dev@passt.top, 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: On Thu, 7 Aug 2025 14:58:34 +0200 Laurent Vivier wrote: > On 06/08/2025 04:17, David Gibson wrote: > > On Tue, Aug 05, 2025 at 05:46:05PM +0200, Laurent Vivier wrote: > >> Use packet_data() and extract headers using IOV_REMOVE_HEADER() > >> rather than packet_get(). > >> > >> Signed-off-by: Laurent Vivier > >> Reviewed-by: David Gibson > > > > Still R-b, but making an observation below that's perhaps more > > relevant to the previous patch. > > > >> --- > >> 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; > > > > The only case where packet_data() will return false is if you give it > > a bad packet index. That should never happen, by construction. So > > I'm wondering if that should be an ASSSERT() in packet_data() rather > > than a return value. > > Stefano, why do you think of this idea? Well, yes, it *should* be by construction, but somewhere we might eventually calculate that index (indirectly) using data we receive, and I don't think we want to ASSERT() if somebody finds a way to make us calculate a bad index. It's not a strong objection against ASSERT(), though. It makes the code marginally more terse and might help us find issues, too. I just have a slight preference for a return value in this case anyway (better to dodge a security issue and hide a functional issue than risking hitting both, I think). -- Stefano