git: 992f457cae0b - 2026Q2 - security/nebula: fix build on 32 bit platforms

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Fri, 26 Jun 2026 12:16:05 UTC
The branch 2026Q2 has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=992f457cae0b6018adc3484db0521eb1ea487239

commit 992f457cae0b6018adc3484db0521eb1ea487239
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2026-06-24 11:55:34 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2026-06-26 12:13:13 +0000

    security/nebula: fix build on 32 bit platforms
    
    The structure syscall.Iovec has 32 bit fields on 32 bit platforms,
    64 bit fields on 64 bit platforms.  Go copes poorly with this difference
    (why didn't they just use int?).  Apply a conditional patch to fix the
    build on 32 bit platforms.
    
    Approved by:    portmgr (build fix blanket)
    MFH:            2026Q2
    
    (cherry picked from commit 59b1c90a7f8f718c7dbe6f097999e0dbb0e8a489)
---
 security/nebula/Makefile                           |  9 +++++++-
 .../files/extra-patch-overlay_tun__freebsd.go      | 26 ++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/security/nebula/Makefile b/security/nebula/Makefile
index a19cb3e54bbe..f0d97d2b6626 100644
--- a/security/nebula/Makefile
+++ b/security/nebula/Makefile
@@ -26,6 +26,13 @@ PLIST_FILES=	bin/nebula \
 		bin/nebula-cert \
 		etc/${PORTNAME}/config.yml.example
 
+.include <bsd.port.pre.mk>
+
+# 32 bit architectures
+.if ${ARCH:Marmv?} || ${ARCH} == "i386" || ${ARCH} == "powerpc"
+EXTRA_PATCHES=	${PATCHDIR}/extra-patch-overlay_tun__freebsd.go
+.endif
+
 pre-patch:
 .for m in net term sys
 	${RM} -r ${WRKSRC}/vendor/golang.org/x/$m
@@ -42,4 +49,4 @@ post-install:
 	${INSTALL_DATA} ${WRKSRC}/examples/config.yml \
 		${STAGEDIR}${PREFIX}/etc/${PORTNAME}/config.yml.example
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff --git a/security/nebula/files/extra-patch-overlay_tun__freebsd.go b/security/nebula/files/extra-patch-overlay_tun__freebsd.go
new file mode 100644
index 000000000000..af9e388f3046
--- /dev/null
+++ b/security/nebula/files/extra-patch-overlay_tun__freebsd.go
@@ -0,0 +1,26 @@
+The syscall.Iovec struct has differently typed fields depending on the
+word size of the architecture.  This patch fixes the build on 32 bit
+platforms but is incorrect on 64 bit platforms.
+
+See also https://stackoverflow.com/q/79966298/417501
+
+--- overlay/tun_freebsd.go.orig	2026-06-24 11:24:23 UTC
++++ overlay/tun_freebsd.go
+@@ -107,7 +107,7 @@ func (t *tun) Read(to []byte) (int, error) {
+ 
+ 	iovecs := []syscall.Iovec{
+ 		{&head[0], 4},
+-		{&to[0], uint64(len(to))},
++		{&to[0], uint32(len(to))},
+ 	}
+ 
+ 	n, _, errno := syscall.Syscall(syscall.SYS_READV, uintptr(t.devFd), uintptr(unsafe.Pointer(&iovecs[0])), uintptr(2))
+@@ -151,7 +151,7 @@ func (t *tun) Write(from []byte) (int, error) {
+ 	}
+ 	iovecs := []syscall.Iovec{
+ 		{&head[0], 4},
+-		{&from[0], uint64(len(from))},
++		{&from[0], uint32(len(from))},
+ 	}
+ 
+ 	n, _, errno := syscall.Syscall(syscall.SYS_WRITEV, uintptr(t.devFd), uintptr(unsafe.Pointer(&iovecs[0])), uintptr(2))