Skip to contentSkip to conversation

wireguard: do not use sin6_scope_id if not needed

PATCH New Torin Carey 1 participant 1 message Sep 15, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wireguard: do not use sin6_scope_id if not needed

sin6_scope_id should only be used if the address is link-local and otherwise ignored.

Currently send6 uses the sin6_scope_id for flowi6_oif without a check of whether this is needed, so this can cause non-link local endpoints to use an incorrect device.

---
 drivers/net/wireguard/netlink.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/wireguard/netlink.c +2 -0
index 67f962eb8b46..738041f72c2b 100644
@@ -453,6 +453,8 @@ static int set_peer(struct wg_device *wg, struct nlattr **attrs)
 			wg_socket_set_peer_endpoint(peer, &endpoint);
 		} else if (len == sizeof(struct sockaddr_in6) && addr->sa_family == AF_INET6) {
 			endpoint.addr6 = *(struct sockaddr_in6 *)addr;
+			if (!__ipv6_addr_needs_scope_id(ipv6_addr_type(&endpoint.addr6.sin6_addr)))
+				endpoint.addr6.sin6_scope_id = 0;
 			wg_socket_set_peer_endpoint(peer, &endpoint);
 		}
 	}

base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585

Signature · 1 line
2.48.1