diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-08-21 14:20:08 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-08-21 12:00:13 +0200 |
commit | c9f0ec3227d4861afe7dd8aa4c2eb55ed095586c (patch) | |
tree | 7a98af03a1c23fc6313c58a7a5511a98e8539401 | |
parent | 57532f1ded4d850e6184b585567cd327f08368fd (diff) | |
download | passt-c9f0ec3227d4861afe7dd8aa4c2eb55ed095586c.tar passt-c9f0ec3227d4861afe7dd8aa4c2eb55ed095586c.tar.gz passt-c9f0ec3227d4861afe7dd8aa4c2eb55ed095586c.tar.bz2 passt-c9f0ec3227d4861afe7dd8aa4c2eb55ed095586c.tar.lz passt-c9f0ec3227d4861afe7dd8aa4c2eb55ed095586c.tar.xz passt-c9f0ec3227d4861afe7dd8aa4c2eb55ed095586c.tar.zst passt-c9f0ec3227d4861afe7dd8aa4c2eb55ed095586c.zip |
util: Correct sock_l4() binding for link local addresses
When binding an IPv6 socket in sock_l4() we need to supply a scope id
if the address is link-local. We check for this by comparing the
given address to c->ip6.addr_ll. This is correct only by accident:
while c->ip6.addr_ll is typically set to the host interface's link
local address, the actual purpose of it is to provide a link local
address for passt's private use on the tap interface.
Instead set the scope id for any link-local address we're binding to.
We're going to need something and this is what makes sense for sockets
on the host. It doesn't make sense for PIF_SPLICE sockets, but those
should always have loopback, not link-local addresses.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r-- | util.c | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -199,8 +199,7 @@ int sock_l4(const struct ctx *c, sa_family_t af, enum epoll_type type, if (bind_addr) { addr6.sin6_addr = *(struct in6_addr *)bind_addr; - if (!memcmp(bind_addr, &c->ip6.addr_ll, - sizeof(c->ip6.addr_ll))) + if (IN6_IS_ADDR_LINKLOCAL(bind_addr)) addr6.sin6_scope_id = c->ifi6; } return sock_l4_sa(c, type, &addr6, sizeof(addr6), ifname, |