aboutgitcodebugslistschat
path: root/dhcpv6.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-20 11:10:23 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-20 11:10:23 +0200
commit9618d247006a41fba5c1b0470e4723196f96b424 (patch)
tree915f636f855f4cae765ecb1eb6542a387282633f /dhcpv6.c
parent12cfa6444cd239dbc04391027ad3161f53b6901c (diff)
downloadpasst-9618d247006a41fba5c1b0470e4723196f96b424.tar
passt-9618d247006a41fba5c1b0470e4723196f96b424.tar.gz
passt-9618d247006a41fba5c1b0470e4723196f96b424.tar.bz2
passt-9618d247006a41fba5c1b0470e4723196f96b424.tar.lz
passt-9618d247006a41fba5c1b0470e4723196f96b424.tar.xz
passt-9618d247006a41fba5c1b0470e4723196f96b424.tar.zst
passt-9618d247006a41fba5c1b0470e4723196f96b424.zip
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 <sbrivio@redhat.com>
Diffstat (limited to 'dhcpv6.c')
-rw-r--r--dhcpv6.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/dhcpv6.c b/dhcpv6.c
index cac220e..27d3a9c 100644
--- a/dhcpv6.c
+++ b/dhcpv6.c
@@ -452,6 +452,7 @@ int dhcpv6(struct ctx *c, struct ethhdr *eh, size_t len)
{
struct ipv6hdr *ip6h = (struct ipv6hdr *)(eh + 1);
struct opt_hdr *ia, *bad_ia, *client_id, *server_id;
+ struct in6_addr *src;
struct msg_hdr *mh;
struct udphdr *uh;
uint8_t proto;
@@ -476,6 +477,11 @@ int dhcpv6(struct ctx *c, struct ethhdr *eh, size_t len)
c->addr6_ll_seen = ip6h->saddr;
+ if (IN6_IS_ADDR_LINKLOCAL(&c->gw6))
+ src = &c->gw6;
+ else
+ src = &c->addr6_ll;
+
mh = (struct msg_hdr *)(uh + 1);
mlen -= sizeof(struct msg_hdr);
@@ -527,7 +533,7 @@ int dhcpv6(struct ctx *c, struct ethhdr *eh, size_t len)
resp_not_on_link.hdr.xid = mh->xid;
- tap_ip_send(c, &c->gw6, IPPROTO_UDP,
+ tap_ip_send(c, src, IPPROTO_UDP,
(char *)&resp_not_on_link, n, mh->xid);
return 1;
@@ -577,7 +583,7 @@ int dhcpv6(struct ctx *c, struct ethhdr *eh, size_t len)
resp.hdr.xid = mh->xid;
- tap_ip_send(c, &c->gw6, IPPROTO_UDP, (char *)&resp, n, mh->xid);
+ tap_ip_send(c, src, IPPROTO_UDP, (char *)&resp, n, mh->xid);
c->addr6_seen = c->addr6;
return 1;