icmp: Set sin6_scope_id for outbound ICMPv6 echo requests

If we ping a link-local address, we need to pass this to sendto(), as
it will obviously fail with -EINVAL otherwise.

If we ping other addresses, it's probably a good idea anyway to
specify the configured outbound interface here.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Stefano Brivio 2022-10-12 06:46:25 +02:00
parent 57e2c066e9
commit abbe01af59

1
icmp.c
View file

@ -192,6 +192,7 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
struct sockaddr_in6 sa = { struct sockaddr_in6 sa = {
.sin6_family = AF_INET6, .sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_ANY_INIT, .sin6_addr = IN6ADDR_ANY_INIT,
.sin6_scope_id = c->ifi6,
}; };
struct icmp6hdr *ih; struct icmp6hdr *ih;
int id, s; int id, s;