From: "its_Giaan (Code Review)" Date: Wed, 4 Mar 2026 12:00:37 +0000 References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <2396945518b4d380a696bf4a389f77957a1d2b87-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="brL1jjKG2fo="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: socket: restore per-connection lport override over global default List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --brL1jjKG2fo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1555?usp=3Demail to review the following change. Change subject: socket: restore per-connection lport override over global d= efault ...................................................................... socket: restore per-connection lport override over global default OpenVPN 2.7.x introduced a regression where --lport specified inside a 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: #995 Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b Signed-off-by: Gianmarco De Gregori --- M src/openvpn/socket.c 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1555/1 diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 1df1001..32e2a65 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -1347,7 +1347,9 @@ ASSERT(sock); const char *host =3D o->ce.local_list->array[sock_index]->local; - const char *port =3D o->ce.local_list->array[sock_index]->port; + const char *port =3D (o->mode =3D=3D MODE_POINT_TO_POINT && o->ce.loca= l_port_defined) + ? o->ce.local_port + : o->ce.local_list->array[sock_index]->port; int proto =3D o->ce.local_list->array[sock_index]->proto; const char *remote_host =3D o->ce.remote; const char *remote_port =3D o->ce.remote_port; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1555?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b Gerrit-Change-Number: 1555 Gerrit-PatchSet: 1 Gerrit-Owner: its_Giaan Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --brL1jjKG2fo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

its_Giaan would like plaisthos to review this change.

V= iew Change

socket: restore per-connection lport overri=
de over global default

OpenVPN 2.7.x introduced a regression where -= -lport specified
inside a <connection> block did not override a gl= obally defined
local port. As a result, the socket was bound to the glob= al
default port instead of the per-connection value.

Adjust the s= ocket local_port selection logic to honour
local_port_defined when set f= or the active connection profile.

This change restores the documente= d and previously working
behaviour from 2.6.x, where connection-level lp= ort takes
precedence over global defaults.

Github: #995

Ch= ange-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b
Signed-off-by: Gianma= rco De Gregori <gianmarco@...2726...>
---
M src/openvpn/socket.= c
1 file changed, 3 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1555/1<=
/pre>
-    const char=
 *port =3D o->ce.local_list->array[sock_index]->port;
+ const char *port =3D (o->= mode =3D=3D MODE_POINT_TO_POINT && o->ce.local_port_defined)
+ = ? o->ce.local_port
+ : o->ce.local_list->array[sock_index= ]->port;
int proto =3D o->ce.local_list->arra= y[sock_index]->proto;
const char *remote_host =3D o= ->ce.remote;
const char *remote_port =3D o->ce.r= emote_port;

To view, visit change 1555. To = unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7cf5d5ef7e2531f397ad97baf46= 63e3763072f6b
Gerrit-Change-Number: 1555
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --brL1jjKG2fo=--