From 576b047d6fe0d5cd29cf1d65870188c2f2c599bd Mon Sep 17 00:00:00 2001 From: kabassanov Date: Mon, 5 Jan 2026 12:25:50 +0100 Subject: [PATCH] Update route.c to add interface name for link-local ipv6 addresses even if it is not server special route If a link-local ipv6 gateway is pushed by the server, openvpn client must append the interface name to the address even if this route is not considered as vpn special route. --- src/openvpn/route.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 222a0fa8c77..9915603a39c 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -1830,14 +1830,22 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flag * but for link-local destinations, we MUST specify the interface, so * we build a combined "$gateway%$interface" gateway string */ - if (r6->iface != NULL && gateway_needed - && IN6_IS_ADDR_LINKLOCAL(&r6->gateway)) /* fe80::...%intf */ - { - int len = strlen(gateway) + 1 + strlen(r6->iface) + 1; - char *tmp = gc_malloc(len, true, &gc); - snprintf(tmp, len, "%s%%%s", gateway, r6->iface); - gateway = tmp; + if (IN6_IS_ADDR_LINKLOCAL(&r6->gateway)) { /* fe80::...%intf */ + + if (r6->iface != NULL && gateway_needed) { + int len = strlen(gateway) + 1 + strlen(r6->iface)+1; + char *tmp = gc_malloc( len, true, &gc ); + snprintf( tmp, len, "%s%%%s", gateway, r6->iface ); + gateway = tmp; + + } else if (device) { + int len = strlen(gateway) + 1 + strlen(device)+1; + char *tmp = gc_malloc( len, true, &gc ); + snprintf( tmp, len, "%s%%%s", gateway, device ); + gateway = tmp; + } } + #endif #ifndef _WIN32