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=fail reason="key not found in DNS" header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202312 header.b=g4Zpa4Y8; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 69E835A028B for ; Wed, 21 Aug 2024 06:20:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1724214023; bh=6HMyoGXSYwlJsFymkmn53lgZS87Xji4uQxTdOU747hc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g4Zpa4Y8B7DaoM8NKIPbgVsqbhSLAXFUQEy7Z8IAmSwbTnx0uiyRIcm3R+TfUh7ou 51XDLka9xxkiX8Y4nsm8iisLZQ9zPVFCSeptUviue7yAn2W5jLLkxkP8I8FhjkMQvf qnfkB+mK/e94oVR2mxtO0cOU/9+gfqd99+NtHXwhzbLkj019m0O3CwDs1R38DrBCBQ TVRLRuvudhtkF1rynE2JwVOEOQioX9N2KRvXn3NfA0WWKoN2ZihJ70E1TT0WDvAI2E Rz0HeqB/VLFntIoWLS/SFFcCwpSsG8Qwkl6LjkTFcWZas08wwIuIwkuiEsVNN3AlJ0 i51W3Dfb9GYBw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WpY5z2YsPz4x8S; Wed, 21 Aug 2024 14:20:23 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 15/23] Initialise our_tap_ll to ip6.gw when suitable Date: Wed, 21 Aug 2024 14:20:11 +1000 Message-ID: <20240821042020.718422-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240821042020.718422-1-david@gibson.dropbear.id.au> References: <20240821042020.718422-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: QLKDVPRSRV5UBVX2WZW5PSE3H2TWBYC6 X-Message-ID-Hash: QLKDVPRSRV5UBVX2WZW5PSE3H2TWBYC6 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: Paul Holzinger , 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 +---- fwd.c | 5 +---- ndp.c | 5 +---- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/conf.c b/conf.c index 1130ce5d..954f20ea 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 fa1dcccc..14a5c7e6 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/fwd.c b/fwd.c index dccc947d..75dc0151 100644 --- a/fwd.c +++ b/fwd.c @@ -317,10 +317,7 @@ uint8_t fwd_nat_from_host(const struct ctx *c, uint8_t proto, } else if (inany_is_loopback6(&tgt->oaddr) || inany_equals6(&tgt->oaddr, &c->ip6.addr_seen) || inany_equals6(&tgt->oaddr, &c->ip6.addr)) { - if (IN6_IS_ADDR_LINKLOCAL(&c->ip6.gw)) - tgt->oaddr.a6 = c->ip6.gw; - else - tgt->oaddr.a6 = c->ip6.our_tap_ll; + tgt->oaddr.a6 = c->ip6.our_tap_ll; } if (inany_v4(&tgt->oaddr)) { 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