Skip to contentSkip to conversation

dco: print FreeBSD version

PATCH In review Kristof Provost 2 participants 2 messages Mar 9, 2023 – Mar 13, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dco: print FreeBSD version

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

Implement dco_version_string() for FreeBSD.
Unlike Linux and Windows the DCO driver is built into the operating system itself, so we log the OS version as a proxy for the DCO version.

---
 src/openvpn/dco_freebsd.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
src/openvpn/dco_freebsd.c +11 -1
index 2b94b2a2..5238ebdd 100644
@@ -31,6 +31,8 @@
 #include <sys/param.h>
 #include <sys/linker.h>
 #include <sys/nv.h>
+#include <sys/utsname.h>
+
 #include <netinet/in.h>
 
 #include "dco_freebsd.h"
@@ -627,7 +629,15 @@ out:
 const char *
 dco_version_string(struct gc_arena *gc)
 {
-    return "v0";
+    struct utsname* uts;
+    ALLOC_OBJ_GC(uts, struct utsname, gc);
+
+    if (uname(uts) != 0)
+    {
+        return "N/A";
+    }
+
+    return uts->version;
 }
 
 void
Signature · 1 line
2.39.2
Acked-by on v1 1/1
#1 lore raw

Tested on FreeBSD 14

DCO version: FreeBSD 14.0-CURRENT #10 main-n259930-e898a3af97f9: Wed Jan 4 13:33:06 CET 2023 [email protected]...:/usr/obj/usr/src/amd64.amd64/sys/GENERIC

and on 12 (nothing, as expected). Learned about $UNAME_v today :-)

I have added your s-o-b: line, and fixed one whitespace detail uncrustify was complaining about.

Your patch has been applied to the master and release/2.6 branch.

commit fe0853d2e72dd3a639a95e420ad7eeed6b49e81b (master) commit 5617f0f01837ffa01b81dfb2c5c7da8ee4c42072 (release/2.6)

Author: Kristof Provost
Date:   Thu Mar 9 13:23:32 2023 +0100
     dco: print FreeBSD version

     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]/msg26367.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering