Skip to content

Commit 2d65cc8

Browse files
committed
socket: restore per-connection lport override over global default
OpenVPN 2.7.x introduced a regression where --lport specified inside a <connection> block did not override a globally defined local port. As a result, the socket was bound to the global default port instead of the per-connection value. Adjust the socket local_port selection logic to honour local_port_defined when set for the active connection profile. This change restores the documented and previously working behaviour from 2.6.x, where connection-level lport takes precedence over global defaults. Github: OpenVPN#995 Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
1 parent 9735675 commit 2d65cc8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/openvpn/socket.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,9 @@ link_socket_init_phase1(struct context *c, int sock_index, int mode)
13471347
ASSERT(sock);
13481348

13491349
const char *host = o->ce.local_list->array[sock_index]->local;
1350-
const char *port = o->ce.local_list->array[sock_index]->port;
1350+
const char *port = (o->mode == MODE_POINT_TO_POINT && o->ce.local_port_defined)
1351+
? o->ce.local_port
1352+
: o->ce.local_list->array[sock_index]->port;
13511353
int proto = o->ce.local_list->array[sock_index]->proto;
13521354
const char *remote_host = o->ce.remote;
13531355
const char *remote_port = o->ce.remote_port;

0 commit comments

Comments
 (0)