From 9618d247006a41fba5c1b0470e4723196f96b424 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 20 Oct 2021 11:10:23 +0200 Subject: ndp, dhcpv6, tcp, udp: Always use link-local as source if gateway isn't This shouldn't happen on any sane configuration, but I just met an example of that: the default IPv6 gateway on the host is configured with a global unicast address, we use that as source for RA, DHCPv6 replies, and the guest ignores it. Same later on if we talk TCP or UDP and the guest has no idea where that address comes from. Use our link-local address in case the gateway address is global. Signed-off-by: Stefano Brivio --- ndp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ndp.c') diff --git a/ndp.c b/ndp.c index 10c091c..e779ae0 100644 --- a/ndp.c +++ b/ndp.c @@ -183,7 +183,11 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len) c->addr6_seen = ip6h->saddr; ip6hr->daddr = ip6h->saddr; - ip6hr->saddr = c->gw6; + if (IN6_IS_ADDR_LINKLOCAL(&c->gw6)) + ip6hr->saddr = c->gw6; + else + ip6hr->saddr = c->addr6_ll; + ip6hr->payload_len = htons(sizeof(*ihr) + len); ip6hr->hop_limit = IPPROTO_ICMPV6; ihr->icmp6_cksum = 0; -- cgit v1.2.3