Skip to content

Commit

Permalink
dco: pass local option to DCO
Browse files Browse the repository at this point in the history
If the local option is present, DCO should use it as the source IP, or
Linux may pick a different IP as the source IP, breaking the connection.

Signed-off-by: Qingfang Deng <[email protected]>
  • Loading branch information
LGA1150 committed Jan 14, 2025
1 parent 5e086c0 commit 1563695
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/openvpn/dco.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ dco_p2p_add_new_peer(struct context *c)
ASSERT(sock->info.connection_established);

struct sockaddr *remoteaddr = &sock->info.lsa->actual.dest.addr.sa;
struct sockaddr *localaddr = NULL;
struct tls_multi *multi = c->c2.tls_multi;
#ifdef TARGET_FREEBSD
/* In Linux in P2P mode the kernel automatically removes an existing peer
Expand All @@ -503,8 +504,11 @@ dco_p2p_add_new_peer(struct context *c)
c->c2.tls_multi->dco_peer_id = -1;
}
#endif
if (ls->bind_local && ls->info.lsa->bind_local)

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / gcc-mingw - x64 - OSSL

‘ls’ undeclared (first use in this function)

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / gcc-mingw - x86 - OSSL

‘ls’ undeclared (first use in this function)

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - arm64 - openssl

'ls': undeclared identifier [D:\a\openvpn\openvpn\out\build\win-arm64-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - arm64 - openssl

left of '->bind_local' must point to struct/union [D:\a\openvpn\openvpn\out\build\win-arm64-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - arm64 - openssl

'ls': undeclared identifier [D:\a\openvpn\openvpn\out\build\win-arm64-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - arm64 - openssl

left of '->info' must point to struct/union [D:\a\openvpn\openvpn\out\build\win-arm64-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - amd64 - openssl

'ls': undeclared identifier [D:\a\openvpn\openvpn\out\build\win-amd64-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - amd64 - openssl

left of '->bind_local' must point to struct/union [D:\a\openvpn\openvpn\out\build\win-amd64-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - amd64 - openssl

'ls': undeclared identifier [D:\a\openvpn\openvpn\out\build\win-amd64-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - amd64 - openssl

left of '->info' must point to struct/union [D:\a\openvpn\openvpn\out\build\win-amd64-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - x86 - openssl

'ls': undeclared identifier [D:\a\openvpn\openvpn\out\build\win-x86-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - x86 - openssl

left of '->bind_local' must point to struct/union [D:\a\openvpn\openvpn\out\build\win-x86-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - x86 - openssl

'ls': undeclared identifier [D:\a\openvpn\openvpn\out\build\win-x86-release\openvpn.vcxproj]

Check failure on line 507 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - x86 - openssl

left of '->info' must point to struct/union [D:\a\openvpn\openvpn\out\build\win-x86-release\openvpn.vcxproj]
localaddr = ls->info.lsa->bind_local->ai_addr;

Check failure on line 508 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - arm64 - openssl

'ls': undeclared identifier [D:\a\openvpn\openvpn\out\build\win-arm64-release\openvpn.vcxproj]

Check failure on line 508 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - arm64 - openssl

left of '->info' must point to struct/union [D:\a\openvpn\openvpn\out\build\win-arm64-release\openvpn.vcxproj]

Check failure on line 508 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - amd64 - openssl

'ls': undeclared identifier [D:\a\openvpn\openvpn\out\build\win-amd64-release\openvpn.vcxproj]

Check failure on line 508 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - amd64 - openssl

left of '->info' must point to struct/union [D:\a\openvpn\openvpn\out\build\win-amd64-release\openvpn.vcxproj]

Check failure on line 508 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - x86 - openssl

'ls': undeclared identifier [D:\a\openvpn\openvpn\out\build\win-x86-release\openvpn.vcxproj]

Check failure on line 508 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - x86 - openssl

left of '->info' must point to struct/union [D:\a\openvpn\openvpn\out\build\win-x86-release\openvpn.vcxproj]

int ret = dco_new_peer(&c->c1.tuntap->dco, multi->peer_id,
c->c2.link_sockets[0]->sd, NULL, remoteaddr, NULL, NULL);
c->c2.link_sockets[0]->sd, localaddr, remoteaddr, NULL, NULL);
if (ret < 0)
{
return ret;
Expand Down Expand Up @@ -616,7 +620,12 @@ dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi)
vpn_addr6 = &c->c2.push_ifconfig_ipv6_local;
}

if (dco_multi_get_localaddr(m, mi, &local))
struct link_socket *ls = c->c2.link_socket;

Check failure on line 623 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / gcc-mingw - x64 - OSSL

‘struct context_2’ has no member named ‘link_socket’; did you mean ‘link_sockets’?

Check failure on line 623 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / gcc-mingw - x86 - OSSL

‘struct context_2’ has no member named ‘link_socket’; did you mean ‘link_sockets’?

Check failure on line 623 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - arm64 - openssl

'link_socket': is not a member of 'context_2' [D:\a\openvpn\openvpn\out\build\win-arm64-release\openvpn.vcxproj]

Check failure on line 623 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - amd64 - openssl

'link_socket': is not a member of 'context_2' [D:\a\openvpn\openvpn\out\build\win-amd64-release\openvpn.vcxproj]

Check failure on line 623 in src/openvpn/dco.c

View workflow job for this annotation

GitHub Actions / msbuild - x86 - openssl

'link_socket': is not a member of 'context_2' [D:\a\openvpn\openvpn\out\build\win-x86-release\openvpn.vcxproj]
if (ls->bind_local && ls->info.lsa->bind_local)
{
localaddr = ls->info.lsa->bind_local->ai_addr;
}
else if (dco_multi_get_localaddr(m, mi, &local))
{
localaddr = (struct sockaddr *)&local;
}
Expand Down

0 comments on commit 1563695

Please sign in to comment.