Skip to content

Commit 576b047

Browse files
authored
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.
1 parent 4859d25 commit 576b047

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/openvpn/route.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,14 +1830,22 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flag
18301830
* but for link-local destinations, we MUST specify the interface, so
18311831
* we build a combined "$gateway%$interface" gateway string
18321832
*/
1833-
if (r6->iface != NULL && gateway_needed
1834-
&& IN6_IS_ADDR_LINKLOCAL(&r6->gateway)) /* fe80::...%intf */
1835-
{
1836-
int len = strlen(gateway) + 1 + strlen(r6->iface) + 1;
1837-
char *tmp = gc_malloc(len, true, &gc);
1838-
snprintf(tmp, len, "%s%%%s", gateway, r6->iface);
1839-
gateway = tmp;
1833+
if (IN6_IS_ADDR_LINKLOCAL(&r6->gateway)) { /* fe80::...%intf */
1834+
1835+
if (r6->iface != NULL && gateway_needed) {
1836+
int len = strlen(gateway) + 1 + strlen(r6->iface)+1;
1837+
char *tmp = gc_malloc( len, true, &gc );
1838+
snprintf( tmp, len, "%s%%%s", gateway, r6->iface );
1839+
gateway = tmp;
1840+
1841+
} else if (device) {
1842+
int len = strlen(gateway) + 1 + strlen(device)+1;
1843+
char *tmp = gc_malloc( len, true, &gc );
1844+
snprintf( tmp, len, "%s%%%s", gateway, device );
1845+
gateway = tmp;
1846+
}
18401847
}
1848+
18411849
#endif
18421850

18431851
#ifndef _WIN32

0 commit comments

Comments
 (0)