From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 7DD735A031A for ; Wed, 14 Aug 2024 06:31:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1723609853; bh=VN+zPhlN5wFLl/brZNWFg2sPrP6zul0+6snedpVsi0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LnzN6oVrR9OoA8yjvQkb9UMaXEdND7myS0ScN5EGjf4jcMNQodtF7xa0+bjdhzf3C QtDpkLh5a7YNimGXfhR1vcdGkzwJnishlcwaYillppGzmnK21YKbMUF73mSjDwSpOS OXhbAk8d0VFOAgyEzYkT1fUUs7WjS9PCp2fL6Lk2scRqlD99L2mPAl3jD+91BNf5qq 8qhu9xNDV5fN9UY6pGx2QMM0AjlpciICDl2uCOzU87prWCkmmq+SL3BuAeMX8fsEZN wSHKg29nsnEEGbpYUbwIrhigL7aRk4OworJtrEQUSXLxlAWilJOiLw4px9p10+3uXd lf7ZhHmrDNhMA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WkFgK2f3Jz4xDQ; Wed, 14 Aug 2024 14:30:53 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 16/16] Initialise our_tap_ll to ip6.gw when suitable Date: Wed, 14 Aug 2024 14:30:50 +1000 Message-ID: <20240814043050.4177037-17-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240814043050.4177037-1-david@gibson.dropbear.id.au> References: <20240814043050.4177037-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 27UUL746DLS6YL3SVKMPECVPDIWMTT5K X-Message-ID-Hash: 27UUL746DLS6YL3SVKMPECVPDIWMTT5K 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: In every place we use our_tap_ll, we only use it as a fallback if the IPv6 gateway address is not link-local. We can avoid that conditional at use time by doing it at initialisation of our_tap_ll instead. Signed-off-by: David Gibson --- conf.c | 3 +++ dhcpv6.c | 5 +---- ndp.c | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/conf.c b/conf.c index f1727ade..30769474 100644 --- a/conf.c +++ b/conf.c @@ -721,6 +721,9 @@ static unsigned int conf_ip6(unsigned int ifi, ip6->addr_seen = ip6->addr; + if (IN6_IS_ADDR_LINKLOCAL(&ip6->gw)) + ip6->our_tap_ll = ip6->gw; + if (MAC_IS_ZERO(mac)) { rc = nl_link_get_mac(nl_sock, ifi, mac); if (rc < 0) { diff --git a/dhcpv6.c b/dhcpv6.c index 44e954e7..69841abc 100644 --- a/dhcpv6.c +++ b/dhcpv6.c @@ -453,10 +453,7 @@ int dhcpv6(struct ctx *c, const struct pool *p, c->ip6.addr_ll_seen = *saddr; - if (IN6_IS_ADDR_LINKLOCAL(&c->ip6.gw)) - src = &c->ip6.gw; - else - src = &c->ip6.our_tap_ll; + src = &c->ip6.our_tap_ll; mh = packet_get(p, 0, sizeof(*uh), sizeof(*mh), NULL); if (!mh) diff --git a/ndp.c b/ndp.c index 3a76b00a..a1ee8349 100644 --- a/ndp.c +++ b/ndp.c @@ -341,10 +341,7 @@ dns_done: else c->ip6.addr_seen = *saddr; - if (IN6_IS_ADDR_LINKLOCAL(&c->ip6.gw)) - rsaddr = &c->ip6.gw; - else - rsaddr = &c->ip6.our_tap_ll; + rsaddr = &c->ip6.our_tap_ll; if (ih->icmp6_type == NS) { dlen = sizeof(struct ndp_na); -- 2.46.0