diff options
| -rw-r--r-- | conf.c | 8 | ||||
| -rw-r--r-- | fwd.c | 6 | ||||
| -rw-r--r-- | passt.h | 2 |
3 files changed, 13 insertions, 3 deletions
@@ -490,6 +490,8 @@ static unsigned int conf_ip6(unsigned int ifi, struct ip6_ctx *ip6) if (IN6_IS_ADDR_LINKLOCAL(&ip6->guest_gw)) ip6->our_tap_ll = ip6->guest_gw; + else + ip6->our_tap_addr = ip6->guest_gw; if (IN6_IS_ADDR_UNSPECIFIED(&ip6->addr) || IN6_IS_ADDR_UNSPECIFIED(&ip6->our_tap_ll)) @@ -507,10 +509,12 @@ static void conf_ip6_local(struct ip6_ctx *ip6) if (IN6_IS_ADDR_UNSPECIFIED(&ip6->guest_gw)) ip6->guest_gw = IP6_LL_GUEST_GW; - if (IN6_IS_ADDR_LINKLOCAL(&ip6->guest_gw)) + if (IN6_IS_ADDR_LINKLOCAL(&ip6->guest_gw)) { ip6->our_tap_ll = ip6->guest_gw; - else + } else { + ip6->our_tap_addr = ip6->guest_gw; ip6->our_tap_ll = IP6_LL_GUEST_GW; + } ip6->no_copy_addrs = ip6->no_copy_routes = true; } @@ -1090,7 +1090,11 @@ uint8_t fwd_nat_from_host(const struct ctx *c, return PIF_NONE; tgt->oaddr = inany_from_v4(c->ip4.our_tap_addr); } else { - tgt->oaddr.a6 = c->ip6.our_tap_ll; + if (inany_is_linklocal6(&tgt->eaddr) || + IN6_IS_ADDR_UNSPECIFIED(&c->ip6.our_tap_addr)) + tgt->oaddr.a6 = c->ip6.our_tap_ll; + else + tgt->oaddr.a6 = c->ip6.our_tap_addr; } } tgt->oport = ini->eport; @@ -121,6 +121,7 @@ struct ip4_ctx { * @dns: DNS addresses for DHCPv6 and NDP * @dns_match: Forward DNS query if sent to this address * @our_tap_ll: Link-local IPv6 address for passt's use on tap + * @our_tap_addr: Non-LL IPv6 address for passt's use on tap (if any) * @dns_host: Use this DNS on the host for forwarding * @addr_out: Optional source address for outbound traffic * @ifname_out: Optional interface name to bind outbound sockets to @@ -140,6 +141,7 @@ struct ip6_ctx { struct in6_addr dns[MAXNS]; struct in6_addr dns_match; struct in6_addr our_tap_ll; + struct in6_addr our_tap_addr; /* PIF_HOST addresses */ struct in6_addr dns_host; |
