public inbox for wireguard@lists.zx2c4.com
 help / color / mirror / Atom feed
From: Torin Carey <torin@tcarey.uk>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	wireguard@lists.zx2c4.com, netdev@vger.kernel.org
Subject: [PATCH] wireguard: do not use sin6_scope_id if not needed
Date: Mon, 15 Sep 2025 11:58:34 +0000	[thread overview]
Message-ID: <aMf_ZORMji8eiHpH@omega.tcarey.uk> (raw)

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.

Signed-off-by: Torin Carey <torin@tcarey.uk>
---
 drivers/net/wireguard/netlink.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlink.c
index 67f962eb8b46..738041f72c2b 100644
--- a/drivers/net/wireguard/netlink.c
+++ b/drivers/net/wireguard/netlink.c
@@ -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
-- 
2.48.1



                 reply	other threads:[~2025-11-19 14:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aMf_ZORMji8eiHpH@omega.tcarey.uk \
    --to=torin@tcarey.uk \
    --cc=Jason@zx2c4.com \
    --cc=netdev@vger.kernel.org \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox