1
0
mirror of https://passt.top/passt synced 2024-09-19 14:00:53 +00:00

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>
This commit is contained in:
David Gibson 2024-08-21 14:20:11 +10:00 committed by Stefano Brivio
parent 8d4baa4446
commit 975cfa5f32
4 changed files with 6 additions and 12 deletions

3
conf.c
View File

@ -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) {

View File

@ -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)

5
fwd.c
View File

@ -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)) {

5
ndp.c
View File

@ -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);