The custom stop killed whatever pid the pid file held, ignored whether that worked, removed the file and printed "Stopped cmm." On the gateway cmm was still running right after it. rc.subr's own start, stop and status (command=) send SIGTERM and wait for the exit, and only act on a pid file that names a running cmm. Tested through FreeBSD's rc.subr with a stand-in cmm that takes 2 seconds to exit, and with a stale pid file naming another process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
994 B
Bash
47 lines
994 B
Bash
#!/bin/sh
|
|
#
|
|
# PROVIDE: cmm
|
|
# REQUIRE: NETWORKING pf dpa_app
|
|
# KEYWORD: shutdown
|
|
#
|
|
# cmm — Connection Management Module.
|
|
# Monitors PF conntrack state changes and offloads flows to CDX
|
|
# via FCI for hardware-accelerated forwarding.
|
|
#
|
|
# cmm daemonizes itself and writes its pid file; rc.subr's stop sends it
|
|
# SIGTERM and waits until it has exited (it tears its flows down first),
|
|
# and status and stop check that the pid file names a running cmm.
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="cmm"
|
|
rcvar="cmm_enable"
|
|
desc="Connection Management Module for CDX offload"
|
|
|
|
command="/usr/local/sbin/${name}"
|
|
pidfile="/var/run/${name}.pid"
|
|
|
|
start_precmd="cmm_prestart"
|
|
|
|
cmm_prestart()
|
|
{
|
|
# Verify CDX module is loaded
|
|
if ! kldstat -q -m cdx; then
|
|
warn "cdx.ko not loaded — skipping cmm"
|
|
return 1
|
|
fi
|
|
|
|
# Verify FCI module is loaded
|
|
if ! kldstat -q -m fci; then
|
|
warn "fci.ko not loaded — skipping cmm"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
load_rc_config $name
|
|
|
|
: ${cmm_enable:="NO"}
|
|
: ${cmm_flags:="-d 1"}
|
|
|
|
run_rc_command "$1"
|