git: 1ffc369aa3e2 - main - Add dnctl rc.d service

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 22 Nov 2022 10:42:23 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=1ffc369aa3e2372ee1492183f8c79f9c2c08a782

commit 1ffc369aa3e2372ee1492183f8c79f9c2c08a782
Author:     Goran Mekic <meka@tilda.center>
AuthorDate: 2022-11-22 09:46:19 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-11-22 09:46:19 +0000

    Add dnctl rc.d service
    
    As PF now also supports dummynet but can not configure it on its own,
    the service which configures pipes, queues and schedulers is needed.
    
    Reviewed by:    kp
    Differential Revision:  https://reviews.freebsd.org/D37451
---
 libexec/rc/rc.conf       |  3 +++
 libexec/rc/rc.d/Makefile |  3 ++-
 libexec/rc/rc.d/dnctl    | 27 +++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
index 63832505eade..5ead8a6fd9de 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -244,6 +244,9 @@ pflog_enable="NO"		# Set to YES to enable packet filter logging
 pflog_logfile="/var/log/pflog"	# where pflogd should store the logfile
 pflog_program="/sbin/pflogd"	# where the pflogd program lives
 pflog_flags=""			# additional flags for pflogd
+dnctl_enable="NO"
+dnctl_program="/sbin/dnctl"
+dnctl_rules="/etc/dnctl.conf"
 ftpproxy_enable="NO"		# Set to YES to enable ftp-proxy(8) for pf
 ftpproxy_flags=""		# additional flags for ftp-proxy(8)
 pfsync_enable="NO"		# Expose pf state to other hosts for syncing
diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile
index 36b86a6636d9..0e43b1cd94dc 100644
--- a/libexec/rc/rc.d/Makefile
+++ b/libexec/rc/rc.d/Makefile
@@ -216,7 +216,8 @@ CONFS+=	ipfilter \
 .endif
 
 .if ${MK_IPFW} != "no"
-CONFS+=		ipfw
+CONFS+=		ipfw \
+		dnctl
 .if ${MK_NETGRAPH} != "no"
 CONFS+=		ipfw_netflow
 .endif
diff --git a/libexec/rc/rc.d/dnctl b/libexec/rc/rc.d/dnctl
new file mode 100644
index 000000000000..b291864cc235
--- /dev/null
+++ b/libexec/rc/rc.d/dnctl
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: dnctl
+# BEFORE: pf ipfw
+# KEYWORD: nojailvnet
+
+. /etc/rc.subr
+
+name="dnctl"
+desc="Dummynet packet queuing and scheduling"
+rcvar="${name}_enable"
+load_rc_config $name
+start_cmd="${name}_start"
+required_files="$dnctl_rules"
+required_modules="dummynet"
+
+dnctl_start()
+{
+	startmsg -n "Enabling ${name}"
+	$dnctl_program "$dnctl_rules"
+	startmsg '.'
+}
+
+run_rc_command $*