Skip to content

Commit b215499

Browse files
committed
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=286263 Reported-by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl> Change-Id: I84fe7a11391eafde3660d25a3c99094a0c525f3d Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: Antonio Quartulli <antonio@mandelbit.com> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1551 Message-Id: <20260227224745.3175-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35795.html Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit 5f19355)
1 parent d88e902 commit b215499

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/openvpn/dco_freebsd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ open_fd(dco_context_t *dco)
205205
return -1;
206206
}
207207

208-
dco->fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
208+
dco->fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
209209
if (dco->fd != -1)
210210
{
211211
dco->open = true;
@@ -715,9 +715,10 @@ dco_available(msglvl_t msglevel)
715715
* loaded, or built into the kernel. */
716716
(void)kldload("if_ovpn");
717717

718-
fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
718+
fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
719719
if (fd < 0)
720720
{
721+
msg(M_WARN | M_ERRNO, "%s: socket() failed, disabling data channel offload", __func__);
721722
return false;
722723
}
723724

0 commit comments

Comments
 (0)