From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202410 header.b=FYJHbmK1; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 7A26D5A004F for ; Fri, 18 Oct 2024 03:36:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1729215357; bh=75aQxoXbFP2KkmoS2xDdbX+VK3uzmONXnLn1vhWl5vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FYJHbmK1g7Kb2dNMz2ax+bJINuVDekzXWp98Zb0qzcM8bbpy9sW9JsF0YlHArXZS8 LfQ7+YNTf63KqKv9qv3YxuvO/UJmY7MZJjp0ODGCXNLEFwGjP6RKlAGHvKSjnsH+Bl 0Xn3Dg455u9nddH+VMlSKPOGkFQlFoLS3pD73z5x3hCRDPEyugTOIJ+jiwfWfSyZZQ fo2YaNcNbhF3YrpAt+XdCuyiXnvVr8uGT/wKv4BIR4qQCRL83zr1wjhy+IDbDXnkuD +hdyR7cgY5JLNIC945fsk0JoGB0M9Erp89EX7dfORQb5xsQ8qT0XTzUaG0E0xLDgAf U6GfEL39/LkBQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XV6jT1cJjz4wj2; Fri, 18 Oct 2024 12:35:57 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v5 1/7] arp: Fix a handful of small warts Date: Fri, 18 Oct 2024 12:35:50 +1100 Message-ID: <20241018013556.1266295-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241018013556.1266295-1-david@gibson.dropbear.id.au> References: <20241018013556.1266295-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 2YE7BFMMTAKVLJAEVXCHU7VR3W7ZUXRD X-Message-ID-Hash: 2YE7BFMMTAKVLJAEVXCHU7VR3W7ZUXRD X-MailFrom: dgibson@gandalf.ozlabs.org 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: 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: This fixes a number of harmless but slightly ugly warts in the ARP resolution code: * Use in4addr_any to represent 0.0.0.0 rather than hand constructing an example. * When comparing am->sip against 0.0.0.0 use sizeof(am->sip) instead of sizeof(am->tip) (same value, but makes more logical sense) * Described the guest's assigned address as such, rather than as "our address" - that's not usually what we mean by "our address" these days * Remove "we might have the same IP address" comment which I can't make sense of in context (possibly it's relating to the statement below, which already has its own comment?) Signed-off-by: David Gibson --- arp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arp.c b/arp.c index 53334da..fc482bb 100644 --- a/arp.c +++ b/arp.c @@ -59,14 +59,12 @@ int arp(const struct ctx *c, const struct pool *p) ah->ar_op != htons(ARPOP_REQUEST)) return 1; - /* Discard announcements (but not 0.0.0.0 "probes"): we might have the - * same IP address, hide that. - */ - if (memcmp(am->sip, (unsigned char[4]){ 0 }, sizeof(am->tip)) && + /* Discard announcements, but not 0.0.0.0 "probes" */ + if (memcmp(am->sip, &in4addr_any, sizeof(am->sip)) && !memcmp(am->sip, am->tip, sizeof(am->sip))) return 1; - /* Don't resolve our own address, either. */ + /* Don't resolve the guest's assigned address, either. */ if (!memcmp(am->tip, &c->ip4.addr, sizeof(am->tip))) return 1; -- 2.47.0