From c968f5b7c460f948685783fd5fd9d2504036e100 Mon Sep 17 00:00:00 2001 From: Thymo van Beers Date: Mon, 18 Dec 2023 15:18:49 +0100 Subject: [PATCH] Copy scope id when binding to IPv6 Link-Local address Binding to an IPv6 Link-Local address requires the scope ID to be set. If this is not set bind will return EINVAL. Signed-off-by: Thymo van Beers --- src/net.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/net.c b/src/net.c index b66c03d97a..2e4ee6e19c 100644 --- a/src/net.c +++ b/src/net.c @@ -672,6 +672,9 @@ static int net__bind_interface(struct mosquitto__listener *listener, struct addr memcpy(&((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr, &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr, sizeof(struct in6_addr)); + + ((struct sockaddr_in6 *)rp->ai_addr)->sin6_scope_id = ((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_scope_id; + freeifaddrs(ifaddr); return MOSQ_ERR_SUCCESS; }