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=aixtbujt; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 0E1E95A004F for ; Thu, 17 Oct 2024 07:33:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1729143190; bh=7J9NMsLwRzxQyQGOnfP1b/g7uaRDeXMU3l5CrLrEyig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aixtbujtlAlrKRih3VgGhUV0hExPmywJhJU0isMePOtcLwPLaqa7svMbMFpFlqL8J uLR6FXfd1k4PmYUClyIlqIq7zMKqPGU0iDzczNmsj5f7VMhHQXy87yL4EVlKLFjiP3 +rkmHbdpbTfEpHQGo0/lXxl+Lh+Yh48VQMHYQLV2XiyNkueesiUrk7gnBC0JdWPISV GNuUI3Kdxs9hqz9xwsclpCjX/5s+byEsQFyCXi5iM/CBuFec8CVfar+WqBqrf1Q+JS VoW/XbtwraxmM3axePCdV5rFuXua9/bMO83cUyDA4deHu7nxS1zKrFX7JrQeuF00cN 7gtF+xpO2LkYg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XTc1f6rdqz4x3J; Thu, 17 Oct 2024 16:33:10 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v4 1/7] arp: Fix a handful of small warts Date: Thu, 17 Oct 2024 16:32:58 +1100 Message-ID: <20241017053304.909386-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241017053304.909386-1-david@gibson.dropbear.id.au> References: <20241017053304.909386-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: FZQRN44CNXSCAFCRJ4C3ROJALBWIDGIG X-Message-ID-Hash: FZQRN44CNXSCAFCRJ4C3ROJALBWIDGIG 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..d34b20e 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 guest's assigned address, either. */ if (!memcmp(am->tip, &c->ip4.addr, sizeof(am->tip))) return 1; -- 2.47.0