Skip to contentSkip to conversation

dco-freebsd: support float notifications

PATCH New Kristof Provost 2 participants 3 messages Jul 23, 2025 – Jul 28, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dco-freebsd: support float notifications

Hi,

Here's an implementation of the float notification handling for FreeBSD. The OpenVPN bits are pretty trivial because it just extends existing mechanisms.

This does expect FreeBSD to actually send the notification, which requires this
patch: https://reviews.freebsd.org/D51468
There's a test case in https://reviews.freebsd.org/D51469.

Best regards,
Kristof

#1 lore raw

PATCH 1/1 dco: support float notifications on FreeBSD

From: Kristof Provost <[email protected]...>

---
 configure.ac                   |  9 +++++
 src/openvpn/dco_freebsd.c      | 68 ++++++++++++++++++++++++++++++++++
 src/openvpn/dco_freebsd.h      |  2 +
 src/openvpn/multi.c            |  2 +-
 src/openvpn/ovpn_dco_freebsd.h |  1 +
 5 files changed, 81 insertions(+), 1 deletion(-)
configure.ac +9 -0
index 66cb79b1..50697b8e 100644
@@ -848,6 +848,15 @@ if test "$enable_dco" != "no"; then
 				else
 					AC_MSG_ERROR([DCO support can't be enabled])
 				fi
+			else
+				AC_CHECK_DECLS(
+					[OVPN_NOTIF_FLOAT],
+					[AC_DEFINE([ENABLE_DCO_FLOAT_FREEBSD], [1], [We have DCO float notifications on FreeBSD])],
+					,
+					[[
+						#include <net/if_ovpn.h>
+					]]
+				)
 			fi
 			;;
 		*-mingw*)
src/openvpn/dco_freebsd.c +68 -0

80 lines not on this page · raw message

src/openvpn/dco_freebsd.h +2 -0
index e1a054e0..ab5891e8 100644
@@ -36,6 +36,7 @@ enum ovpn_message_type_t {
     OVPN_CMD_DEL_PEER,
     OVPN_CMD_PACKET,
     OVPN_CMD_SWAP_KEYS,
+    OVPN_CMD_FLOAT_PEER,
 };
 
 enum ovpn_del_reason_t {
@@ -55,6 +56,7 @@ typedef struct dco_context {
     int dco_message_type;
     int dco_message_peer_id;
     int dco_del_peer_reason;
+    struct sockaddr_storage dco_float_peer_ss;
     uint64_t dco_read_bytes;
     uint64_t dco_write_bytes;
 } dco_context_t;
src/openvpn/multi.c +1 -1
index 46966863..8e712e44 100644
@@ -3400,7 +3400,7 @@ multi_process_incoming_dco(struct multi_context *m)
         {
             process_incoming_del_peer(m, mi, dco);
         }
-#if defined(TARGET_LINUX) || defined(TARGET_WIN32)
+#if defined(TARGET_LINUX) || defined(TARGET_WIN32) || defined(TARGET_FREEBSD)
         else if (dco->dco_message_type == OVPN_CMD_FLOAT_PEER)
         {
             ASSERT(mi->context.c2.link_sockets[0]);
src/openvpn/ovpn_dco_freebsd.h +1 -0
index 53f94dfd..7eb643b4 100644
@@ -37,6 +37,7 @@
 enum ovpn_notif_type {
     OVPN_NOTIF_DEL_PEER,
     OVPN_NOTIF_ROTATE_KEY,
+    OVPN_NOTIF_FLOAT,
 };
 
 enum ovpn_del_reason {
Signature · 1 line
2.50.1
#2 lore raw

[Openvpn-devel] [PATCH applied] Re: dco: support float notifications on FreeBSD

Thanks. Tested, works (and I already got chided for my lack of faith).

Uncrustify complained about whitespace conventions, so I've adjusted those (whitespace-only, no code changes), and the patch did not apply "as is" because Antonio changed a bit in dco_freebsd.h in the mean time so one line of diff context was different - trivial fix.

I tested this with the kernel patch in https://reviews.freebsd.org/D51468,
on top of a 14.2-RELEASE-p4 kernel - v4/v4 float on an udp4 socket, v4/v4 and v6/v6 float on an udp6 dual-stack socket.

Running an "old binary" on top of a "very new kernel" has a bit of risk - if a client floats, userland will see an "Unknown kernel notification 2" and kill the instance

SIGTERM[soft,ovpn-dco: unknown reason] received, client-instance exiting

this is somewhat unavoidable as userland depends on having the kernel constant available. So, for the sake of the archives - if you upgrade your FreeBSD and an OpenVPN server kills clients on float, upgrade your userland (old server + old kernel would not support float at all, and clients will just time out).

Your patch has been applied to the master branch.

commit b66b80b2ab73bb422826911b675798e6b789ef03

Author: Kristof Provost
Date:   Wed Jul 23 10:36:49 2025 +0200
     dco: support float notifications on FreeBSD

     Signed-off-by: Kristof Provost <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg32282.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering