From: "cron2 (Code Review)" Date: Sat, 21 Feb 2026 14:46:02 +0000 References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <59941536208e0a4d2d2615dfe02132ca95742dae-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="SK+u899Ruzs="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO ... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --SK+u899Ruzs= 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/+/1551?usp=3Demail to review the following change. Change subject: dco_freebsd: use AF_LOCAL sockets for ioctl() communication= with DCO driver ...................................................................... dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver DCO FreeBSD uses ioctl() calls for userland -> driver communication, on a socket() file descriptor. The original code uses AF_INET sockets, which fails if using a kernel compiled without IPv4 support. The kernel side ioctl() handling does not differentiate between AF_INET, AF_INET6 and AF_LOCAL sockets, and only the latter are guaranteed to be present. While add it, add a clear message if the socket() call in dco_available() fails (it will lead to disabling of DCO). FreeBSD PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D286263 Reported-by: Marek Zarychta Change-Id: I84fe7a11391eafde3660d25a3c99094a0c525f3d Signed-off-by: Gert Doering --- M src/openvpn/dco_freebsd.c 1 file changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/51/1551/1 diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index ee3a5d0..718cd8b 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -205,7 +205,7 @@ return -1; } - dco->fd =3D socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); + dco->fd =3D socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (dco->fd !=3D -1) { dco->open =3D true; @@ -715,9 +715,10 @@ * loaded, or built into the kernel. */ (void)kldload("if_ovpn"); - fd =3D socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); + fd =3D socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (fd < 0) { + msg(M_WARN | M_ERRNO, "%s: socket() failed, disabling data channel= offload", __func__); return false; } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1551?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: I84fe7a11391eafde3660d25a3c99094a0c525f3d Gerrit-Change-Number: 1551 Gerrit-PatchSet: 1 Gerrit-Owner: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --SK+u899Ruzs= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

cron2 would like plaisthos to review this change.

V= iew Change

dco_freebsd: use AF_LOCAL sockets for ioctl=
() communication with DCO driver

DCO FreeBSD uses ioctl() calls for = userland -> driver communication, on
a socket() file descriptor. The= original code uses AF_INET sockets,
which fails if using a kernel compi= led without IPv4 support.

The kernel side ioctl() handling does not = differentiate between AF_INET,
AF_INET6 and AF_LOCAL sockets, and only t= he latter are guaranteed to be
present.

While add it, add a clear= message if the socket() call in dco_available()
fails (it will lead to = disabling of DCO).

FreeBSD PR: https://bugs.freebsd.org/bugzilla/sho= w_bug.cgi?id=3D286263
Reported-by: Marek Zarychta <zarychtam@...3004...= ..>

Change-Id: I84fe7a11391eafde3660d25a3c99094a0c525f3d
Signe= d-off-by: Gert Doering <gert@...1296...>
---
M src/openvpn/dco_= freebsd.c
1 file changed, 3 insertions(+), 2 deletions(-)

<= pre class=3D"blocks" style=3D"font-family: monospace,monospace; white-space= : pre-wrap;">git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/5= 1/1551/1
diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_f=
reebsd.c
index ee3a5d0..718cd8b 100644
--- = a/src/openvpn/dco_freebsd.c
+++ b/src/openvpn/dco_freebsd.c=
@@ -205,7 +205,7 @@
return -1;
}

- dco->fd =3D socket(AF_INET, SOCK_DGRAM | SOCK_CLOEX= EC, 0);
+ dco->= fd =3D socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
= if (dco->fd !=3D -1)
{
dc= o->open =3D true;
@@ -715,9 +715,10 @@
= * loaded, or built into the kernel. */
(void)kldl= oad("if_ovpn");

- fd =3D socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC,= 0);
+ fd =3D sock= et(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (fd <= ; 0)
{
+ msg(M_WARN | M_ERRNO, "%s: socket() failed, disabling = data channel offload", __func__);
return fals= e;
}


To view, visit change 1551. To unsubscribe, or for help writing mail filte= rs, visit settin= gs.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I84fe7a11391eafde3660d25a3c9= 9094a0c525f3d
Gerrit-Change-Number: 1551
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <gert@...1296...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --SK+u899Ruzs=--