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=ZmtsS+p0; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id C48385A027C for ; Fri, 16 Aug 2024 07:40:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1723786807; bh=4n00rjf/lJtXyFAjgfk/Zt5JqOdq04WKEluqFd5RGJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZmtsS+p0D7fthL5S2F1bnyAvYvU4kUR8WUlsw3tiLY1C3tB2yCXGe8X+NE6DYxq94 7rzyUSs4HA68V7+MmtiwsOaT46fU/UKH811p+MEHZae+3juymSxiMIyuYjOBbHLv4Q 5ZJM5xS726NwHRLREfSz/nLUy6cYjSvEMVq2GsL0T/sA4QKry7DOtHYjJX79c0k5z7 IpGwIv/U/6FcvsY211VpqfrzosdjvH9RS5gKotcn9jhzmUnwMXWSmOesCYb+Z56S6q Xbotb6KM6u5okWJPT/yPqEmWSdMIcNax/kvP5xEn8KZnC78XtUhgCSmfm36a6BfSkW IByszaMyyVjlg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WlW6H0yLnz4x6n; Fri, 16 Aug 2024 15:40:07 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 15/22] Initialise our_tap_ll to ip6.gw when suitable Date: Fri, 16 Aug 2024 15:39:56 +1000 Message-ID: <20240816054004.1335006-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240816054004.1335006-1-david@gibson.dropbear.id.au> References: <20240816054004.1335006-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: CVBDWYPOQ4ZZKALF7IYHR4YPVMNZVC5B X-Message-ID-Hash: CVBDWYPOQ4ZZKALF7IYHR4YPVMNZVC5B 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 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/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