From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 6B4195A0265 for ; Wed, 19 Oct 2022 02:44:10 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4MsX6S1ctZz4xH0; Wed, 19 Oct 2022 11:44:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1666140240; bh=d6ptqp7psWBYBlS4/iB+rD4V+ez4B1NxX+kIhMa6Ybo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWkWuzncgPZYEb7nTnNVsXf9xb4oaS1ktYma+lT85zC4Nto9m7Xx3Jx/lUqxG4sd4 DbHTcalUN/q0JGJmwvnIdOOJfwvsdmm49XA6ZrjsZpNaMapvYMnFCYmliJik9X4/q9 aR0qqkEdzQgR0q1qBeasM30NafZOBCHC93yjFWvA= From: David Gibson To: Stefano Brivio Subject: [PATCH v2 11/14] ndp: Remove unneeded eh_source parameter Date: Wed, 19 Oct 2022 11:43:54 +1100 Message-Id: <20221019004357.1454325-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221019004357.1454325-1-david@gibson.dropbear.id.au> References: <20221019004357.1454325-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: MCJG2R7IBL3QH7UIVESYLQWSOOLPBHFL X-Message-ID-Hash: MCJG2R7IBL3QH7UIVESYLQWSOOLPBHFL 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: passt-dev@passt.top, David Gibson X-Mailman-Version: 3.3.3 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: ndp() takes a parameter giving the ethernet source address of the packet it is to respond to, which it uses to determine the destination address to send the reply packet to. This is not necessary, because the address will always be the guest's MAC address. Even if the guest has just changed MAC address, then either tap_handler_passt() or tap_handler_pasta() - which are the only call paths leading to ndp() will have updated c->mac_guest with the new value. So, remove the parameter, and just use c->mac_guest, making it more consistent with other paths where we construct packets to send inwards. Signed-off-by: David Gibson --- ndp.c | 6 ++---- ndp.h | 3 +-- tap.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ndp.c b/ndp.c index 79be0cf..f96b4b7 100644 --- a/ndp.c +++ b/ndp.c @@ -41,13 +41,11 @@ * ndp() - Check for NDP solicitations, reply as needed * @c: Execution context * @ih: ICMPv6 header - * @eh_source: Source Ethernet address * @saddr Source IPv6 address * * Return: 0 if not handled here, 1 if handled, -1 on failure */ -int ndp(struct ctx *c, const struct icmp6hdr *ih, - const unsigned char *eh_source, const struct in6_addr *saddr) +int ndp(struct ctx *c, const struct icmp6hdr *ih, const struct in6_addr *saddr) { char buf[BUFSIZ] = { 0 }; struct ipv6hdr *ip6hr; @@ -196,7 +194,7 @@ dns_done: ip6hr->hop_limit = 255; len += sizeof(*ehr) + sizeof(*ip6hr) + sizeof(*ihr); - memcpy(ehr->h_dest, eh_source, ETH_ALEN); + memcpy(ehr->h_dest, c->mac_guest, ETH_ALEN); memcpy(ehr->h_source, c->mac, ETH_ALEN); ehr->h_proto = htons(ETH_P_IPV6); diff --git a/ndp.h b/ndp.h index d857425..b012747 100644 --- a/ndp.h +++ b/ndp.h @@ -6,7 +6,6 @@ #ifndef NDP_H #define NDP_H -int ndp(struct ctx *c, const struct icmp6hdr *ih, - const unsigned char *eh_source, const struct in6_addr *saddr); +int ndp(struct ctx *c, const struct icmp6hdr *ih, const struct in6_addr *saddr); #endif /* NDP_H */ diff --git a/tap.c b/tap.c index 135d799..0031d82 100644 --- a/tap.c +++ b/tap.c @@ -576,7 +576,7 @@ resume: if (l4_len < sizeof(struct icmp6hdr)) continue; - if (ndp(c, (struct icmp6hdr *)l4h, eh->h_source, saddr)) + if (ndp(c, (struct icmp6hdr *)l4h, saddr)) continue; tap_packet_debug(NULL, ip6h, NULL, proto, NULL, 1); -- 2.37.3