From: "cron2 (Code Review)" Date: Mon, 12 Jan 2026 18:00:46 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="gZdFCeEnL2I="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: socks: Replace magic "10" for socks header with macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --gZdFCeEnL2I= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1467?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by plaisthos Change subject: socks: Replace magic "10" for socks header with macro ...................................................................... socks: Replace magic "10" for socks header with macro So that it is easier to check that we indeed have reserved this prior to assuming we have. Github: openvpn-private-issues#4 Change-Id: I0aca7e7d9aa190541f11745cf72193cb6b39540a Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1467 Message-Id: <20260112171122.3994-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 214.html Signed-off-by: Gert Doering --- M src/openvpn/init.c M src/openvpn/mtu.c M src/openvpn/mtu.h M src/openvpn/socks.c 4 files changed, 14 insertions(+), 9 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1467/2 diff --git a/src/openvpn/init.c b/src/openvpn/init.c index b690dff..4c23170 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -2927,7 +2927,7 @@ headroom +=3D 4; /* socks proxy header */ - headroom +=3D 10; + headroom +=3D SOCKS_UDPv4_HEADROOM; /* compression header and fragment header (part of the encrypted paylo= ad) */ headroom +=3D 1 + 1; diff --git a/src/openvpn/mtu.c b/src/openvpn/mtu.c index 67ae67f..e5db8ab 100644 --- a/src/openvpn/mtu.c +++ b/src/openvpn/mtu.c @@ -66,11 +66,11 @@ bool tlsmode =3D options->tls_server || options->tls_client; - /* A socks proxy adds 10 byte of extra header to each packet + /* A socks proxy adds extra header to each packet * (we only support Socks with IPv4, this value is different for IPv6)= */ if (options->ce.socks_proxy_server && proto_is_udp(options->ce.proto)) { - header_size +=3D 10; + header_size +=3D SOCKS_UDPv4_HEADROOM; } /* TCP stream based packets have a 16 bit length field */ diff --git a/src/openvpn/mtu.h b/src/openvpn/mtu.h index 29a7d04..ca8109c 100644 --- a/src/openvpn/mtu.h +++ b/src/openvpn/mtu.h @@ -94,6 +94,11 @@ */ #define PAYLOAD_ALIGN 4 +/* + * How many bytes we prepend for a SOCKS UDP proxy. + * This only handles IPv4 right now. + */ +#define SOCKS_UDPv4_HEADROOM 10 /*************************************************************************= */ /** diff --git a/src/openvpn/socks.c b/src/openvpn/socks.c index ed2d9e9..671d33c 100644 --- a/src/openvpn/socks.c +++ b/src/openvpn/socks.c @@ -434,7 +434,7 @@ } /* - * Remove the 10 byte socks5 header from an incoming + * Remove the socks5 header from an incoming * UDP packet, setting *from to the source address. * * Run after UDP read. @@ -444,7 +444,7 @@ { int atyp; - if (BLEN(buf) < 10) + if (BLEN(buf) < SOCKS_UDPv4_HEADROOM) { goto error; } @@ -471,7 +471,7 @@ } /* - * Add a 10 byte socks header prior to UDP write. + * Add a socks header prior to UDP write. * *to is the destination address. * * Run before UDP write. @@ -481,11 +481,11 @@ socks_process_outgoing_udp(struct buffer *buf, const struct link_socket_ac= tual *to) { /* - * Get a 10 byte subset buffer prepended to buf -- + * Get a subset buffer prepended to buf -- * we expect these bytes will be here because * we always allocate space for these bytes */ - struct buffer head =3D buf_sub(buf, 10, true); + struct buffer head =3D buf_sub(buf, SOCKS_UDPv4_HEADROOM, true); /* crash if not enough headroom in buf */ ASSERT(buf_defined(&head)); @@ -496,5 +496,5 @@ buf_write(&head, &to->dest.addr.in4.sin_addr, sizeof(to->dest.addr.in4= .sin_addr)); buf_write(&head, &to->dest.addr.in4.sin_port, sizeof(to->dest.addr.in4= .sin_port)); - return 10; + return SOCKS_UDPv4_HEADROOM; } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1467?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I0aca7e7d9aa190541f11745cf72193cb6b39540a Gerrit-Change-Number: 1467 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --gZdFCeEnL2I= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #2 to the change originally created by flichtenhel= d.

View Change

The following approvals got outdated and were remove= d: Code-Review+2 by plaisthos

socks: Replace magic "10&q=
uot; for socks header with macro

So that it is easier to check that = we indeed
have reserved this prior to assuming we have.

Github: o= penvpn-private-issues#4
Change-Id: I0aca7e7d9aa190541f11745cf72193cb6b39= 540a
Signed-off-by: Frank Lichtenheld <frank@...2641...>
Acked-= by: Arne Schwabe <arne-openvpn@...1227...>
Gerrit URL: https://ger= rit.openvpn.net/c/openvpn/+/1467
Message-Id: <20260112171122.3994-1-g= ert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1697...= .sourceforge.net/msg35214.html
Signed-off-by: Gert Doering <gert@...1386...= 296...>
---
M src/openvpn/init.c
M src/openvpn/mtu.c
M src/o= penvpn/mtu.h
M src/openvpn/socks.c
4 files changed, 14 insertions(+),= 9 deletions(-)

git pull ssh://gerrit.openvpn.ne=
t:29418/openvpn refs/changes/67/1467/2
diff --git a/src/openvpn/ini=
t.c b/src/openvpn/init.c
index b690dff..4c23170 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init= .c
@@ -2927,7 +2927,7 @@
headroom +=3D= 4;

/* socks proxy header */<= br>- headroom +=3D 10;<= br>+ headroom +=3D SOCKS_UDP= v4_HEADROOM;

/* compression header a= nd fragment header (part of the encrypted payload) */
= headroom +=3D 1 + 1;
diff --git a/src/openvpn/mtu.c b/src/o= penvpn/mtu.c
index 67ae67f..e5db8ab 100644
= --- a/src/openvpn/mtu.c
+++ b/src/openvpn/mtu.c
<= span>@@ -66,11 +66,11 @@


bool tlsmod= e =3D options->tls_server || options->tls_client;

- /* A socks proxy ad= ds 10 byte of extra header to each packet
+ /* A socks proxy adds extra header to each packet=
* (we only support Socks with IPv4, this value is di= fferent for IPv6) */
if (options->ce.socks_proxy_se= rver && proto_is_udp(options->ce.proto))
{<= /span>
- header_size += =3D 10;
+ head= er_size +=3D SOCKS_UDPv4_HEADROOM;
}
=
/* TCP stream based packets have a 16 bit length fiel= d */
diff --git a/src/openvpn/mtu.h b/src/openvpn/mtu.h
index 29a7d04..ca8109c 100644
--- a/src/openvp= n/mtu.h
+++ b/src/openvpn/mtu.h
@@ -94,6 +9= 4,11 @@
*/
#define PAYLOAD_ALIGN 4

+/*
+ * How many bytes we pre= pend for a SOCKS UDP proxy.
+ * This only handles IPv4 right now.
+ */
+#define SOCKS_UDPv4_HEADROOM 10

= /*************************************************************************= */
/**
diff --git a/src/openvpn/socks.c b/= src/openvpn/socks.c
index ed2d9e9..671d33c 100644--- a/src/openvpn/socks.c
+++ b/src/openvpn/socks.c<= /span>
@@ -434,7 +434,7 @@
}

/*
- * R= emove the 10 byte socks5 header from an incoming
+ * Remove the socks5 header from an incoming
* UDP packet, setting *from to the source address.<= br> *
* Run after UDP read.
@@ -44= 4,7 +444,7 @@
{
int atyp;
<= span>

- if (BLEN(bu= f) < 10)
+ if (= BLEN(buf) < SOCKS_UDPv4_HEADROOM)
{
goto error;

}
@@ -471,7 +471= ,7 @@
}

/*
- * Add a 10 byte socks header prio= r to UDP write.

+ * A= dd a socks header prior to UDP write.
* *to is the destin= ation address.
*
* Run before UDP write= .
@@ -481,11 +481,11 @@
socks_process_outg= oing_udp(struct buffer *buf, const struct link_socket_actual *to) {
/*
- * Get a 10 byte subset buffer prepended to buf --+ * Get a subset buffer p= repended to buf --
* we expect these bytes will be he= re because
* we always allocate space for these bytes=
*/
- struct buffer head =3D buf_sub(buf, 10, true);
+ struct buffer head =3D buf_sub(buf, = SOCKS_UDPv4_HEADROOM, true);

/* cras= h if not enough headroom in buf */
ASSERT(buf_defined(= &head));
@@ -496,5 +496,5 @@
buf_w= rite(&head, &to->dest.addr.in4.sin_addr, sizeof(to->dest.addr= .in4.sin_addr));
buf_write(&head, &to->dest= .addr.in4.sin_port, sizeof(to->dest.addr.in4.sin_port));

- return 10;
+ return SOCKS_UDPv4_H= EADROOM;
}

To view, vi= sit chan= ge 1467. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0aca7e7d9aa190541f11745cf72= 193cb6b39540a
Gerrit-Change-Number: 1467
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --gZdFCeEnL2I=--