git: 471e14267bea - main - nfsd: Update the rc.d script for RDMA for the nfsd service

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Fri, 14 Aug 2026 19:57:50 UTC
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=471e14267bea79e0f7d5768aa241471d34079e93

commit 471e14267bea79e0f7d5768aa241471d34079e93
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2026-08-14 19:55:54 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2026-08-14 19:55:54 +0000

    nfsd: Update the rc.d script for RDMA for the nfsd service
    
    Commit 7144a1d58c5c added the hooks for the nfsrdma.ko module.
    Once loaded, this module adds RDMA support to the nfsd.
    
    This patch adds a few lines to /etc/rc.d/nfsd, so that
    nfs_server_rdma_enable="YES"
    in your /etc/rc.conf will load nfsrdma.ko, so that RDMA
    service is enabled.
    It also supports
    nfs_server_rdma_listen="port#"
    so that the default of 20490 can be overridden in /etc/rc.conf.
    
    At this available as time, the nfsrdma.ko module is an unofficial port,
    since it was developed by Vinicius Ferrao <ferrao@versatushpc.com.br>
    using generative AI.
    As soon as it is available, it will be announced on
    freebsd-current@freebsd.org.
    
    Suggested by:   Vinicius Ferrao <versatushpc.com.br>
    MFC after:      1 month
---
 libexec/rc/rc.conf   | 2 ++
 libexec/rc/rc.d/nfsd | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
index ab92a464b133..497bdb4f7ab5 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -386,6 +386,8 @@ nfs_server_enable="NO"		# This host is an NFS server (or NO).
 nfs_server_flags="-u -t"	# Flags to nfsd (if enabled).
 nfs_server_managegids="NO"	# The NFS server maps gids for AUTH_SYS (or NO).
 nfs_server_maxio="131072"	# Maximum I/O size for the nfsd.
+nfs_server_rdma_enable="NO"	# Enable the use of the nfsrdma module for RDMA
+nfs_server_rdma_listen="20490"	# Port# for the NFS server to listen on for RDMA
 mountd_enable="NO"		# Run mountd (or NO).
 mountd_flags="-r -S"		# Flags to mountd (if NFS server enabled).
 weak_mountd_authentication="NO"	# Allow non-root mount requests to be served.
diff --git a/libexec/rc/rc.d/nfsd b/libexec/rc/rc.d/nfsd
index 364c2a3b6bd3..89e5977687b3 100755
--- a/libexec/rc/rc.d/nfsd
+++ b/libexec/rc/rc.d/nfsd
@@ -63,6 +63,13 @@ nfsd_precmd()
 	if [ -n "${nfs_server_vhost}" ]; then
 		command_args="-V \"${nfs_server_vhost}\""
 	fi
+
+	if checkyesno nfs_server_rdma_enable; then
+		load_kld nfsrdma || err 1 "Cannot load nfsrdma"
+		if ! sysctl vfs.nfsd.rdma_listen=${nfs_server_rdma_listen} >/dev/null; then
+			warn "Failed to set RDMA listen port#"
+		fi
+	fi
 }
 
 run_rc_command "$1"