aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-08-21 14:20:11 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-08-21 12:00:22 +0200
commit975cfa5f3255ae0ece3cdeda33675076b17be1c7 (patch)
tree079e312e66887f7c738ffe4be48fe60e6d5a0f77
parent8d4baa4446c6482d66aa09dfcd6cdbe94f616f76 (diff)
downloadpasst-975cfa5f3255ae0ece3cdeda33675076b17be1c7.tar
passt-975cfa5f3255ae0ece3cdeda33675076b17be1c7.tar.gz
passt-975cfa5f3255ae0ece3cdeda33675076b17be1c7.tar.bz2
passt-975cfa5f3255ae0ece3cdeda33675076b17be1c7.tar.lz
passt-975cfa5f3255ae0ece3cdeda33675076b17be1c7.tar.xz
passt-975cfa5f3255ae0ece3cdeda33675076b17be1c7.tar.zst
passt-975cfa5f3255ae0ece3cdeda33675076b17be1c7.zip
Initialise our_tap_ll to ip6.gw when suitable
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 <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--conf.c3
-rw-r--r--dhcpv6.c5
-rw-r--r--fwd.c5
-rw-r--r--ndp.c5
4 files changed, 6 insertions, 12 deletions
diff --git a/conf.c b/conf.c
index 1130ce5..954f20e 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 fa1dccc..14a5c7e 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 dccc947..75dc015 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 3a76b00..a1ee834 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);