xref: /freebsd-14.2/libexec/rc/rc.d/pfsync (revision d0b2dbfa)
1*0696600cSBjoern A. Zeeb#!/bin/sh
2*0696600cSBjoern A. Zeeb#
3*0696600cSBjoern A. Zeeb#
4*0696600cSBjoern A. Zeeb
5*0696600cSBjoern A. Zeeb# PROVIDE: pfsync
6*0696600cSBjoern A. Zeeb# REQUIRE: FILESYSTEMS netif
7*0696600cSBjoern A. Zeeb# KEYWORD: nojailvnet
8*0696600cSBjoern A. Zeeb
9*0696600cSBjoern A. Zeeb. /etc/rc.subr
10*0696600cSBjoern A. Zeeb
11*0696600cSBjoern A. Zeebname="pfsync"
12*0696600cSBjoern A. Zeebdesc="Packet filter state table sychronisation interface"
13*0696600cSBjoern A. Zeebrcvar="pfsync_enable"
14*0696600cSBjoern A. Zeebstart_precmd="pfsync_prestart"
15*0696600cSBjoern A. Zeebstart_cmd="pfsync_start"
16*0696600cSBjoern A. Zeebstop_cmd="pfsync_stop"
17*0696600cSBjoern A. Zeebrequired_modules="pf pfsync"
18*0696600cSBjoern A. Zeeb
19*0696600cSBjoern A. Zeebpfsync_prestart()
20*0696600cSBjoern A. Zeeb{
21*0696600cSBjoern A. Zeeb	case "$pfsync_syncdev" in
22*0696600cSBjoern A. Zeeb	'')
23*0696600cSBjoern A. Zeeb		warn "pfsync_syncdev is not set."
24*0696600cSBjoern A. Zeeb		return 1
25*0696600cSBjoern A. Zeeb		;;
26*0696600cSBjoern A. Zeeb	esac
27*0696600cSBjoern A. Zeeb	return 0
28*0696600cSBjoern A. Zeeb}
29*0696600cSBjoern A. Zeeb
30*0696600cSBjoern A. Zeebpfsync_start()
31*0696600cSBjoern A. Zeeb{
32*0696600cSBjoern A. Zeeb	local _syncpeer
33*0696600cSBjoern A. Zeeb
34*0696600cSBjoern A. Zeeb	echo "Enabling pfsync."
35*0696600cSBjoern A. Zeeb	if [ -n "${pfsync_syncpeer}" ]; then
36*0696600cSBjoern A. Zeeb		_syncpeer="syncpeer ${pfsync_syncpeer}"
37*0696600cSBjoern A. Zeeb	fi
38*0696600cSBjoern A. Zeeb	ifconfig pfsync0 $_syncpeer syncdev $pfsync_syncdev $pfsync_ifconfig up
39*0696600cSBjoern A. Zeeb}
40*0696600cSBjoern A. Zeeb
41*0696600cSBjoern A. Zeebpfsync_stop()
42*0696600cSBjoern A. Zeeb{
43*0696600cSBjoern A. Zeeb	echo "Disabling pfsync."
44*0696600cSBjoern A. Zeeb	ifconfig pfsync0 -syncdev -syncpeer down
45*0696600cSBjoern A. Zeeb}
46*0696600cSBjoern A. Zeeb
47*0696600cSBjoern A. Zeebload_rc_config $name
48*0696600cSBjoern A. Zeebrun_rc_command "$1"
49