Skip to content

Commit 452a09f

Browse files
committed
net/frr: watchfrr service handling
1 parent a5fdb9c commit 452a09f

File tree

4 files changed

+52
-10
lines changed

4 files changed

+52
-10
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
# Service wrapper for restarting frr service
3+
# This wrapper is needed to react on specific service interactions through watchfrr.
4+
# Startup details with watchfrr enabled (default):
5+
# 1. "service frr start" calls "service frr start watchfrr"
6+
# 2. watchfrr once started calls "service frr restart all"
7+
# 3. "restart all" need to loop the list of $frr_daemons to start each
8+
# of then
9+
# 4. vtysh -b is executed to load boot startup configuration
10+
11+
/usr/sbin/service frr restart $1
12+
13+
# If started service is ospfd, e.g. process error
14+
if [ "$1" = "ospfd" ]; then
15+
logger -t frr_wrapper "WATCHFRR - OSPFD - Starting CARP event handler now"
16+
/usr/local/opnsense/scripts/frr/carp_event_handler
17+
fi
18+
# If frr starts up
19+
if [ "$1" = "all" ]; then
20+
(
21+
/usr/bin/logger -t frr_wrapper "WATCHFRR - STARTUP - Starting CARP event handler now"
22+
/usr/local/opnsense/scripts/frr/carp_event_handler
23+
) &
24+
fi
25+
exit $?
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
# Service wrapper for starting frr service
3+
# This wrapper is needed to react on specific service interactions through watchfrr.
4+
# Startup details with watchfrr enabled (default):
5+
# 1. "service frr start" calls "service frr start watchfrr"
6+
# 2. watchfrr once started calls "service frr restart all"
7+
# 3. "restart all" need to loop the list of $frr_daemons to start each
8+
# of then
9+
# 4. vtysh -b is executed to load boot startup configuration
10+
11+
/usr/sbin/service frr start $1
12+
13+
# If started service is ospfd, e.g. process error
14+
if [ "$1" = "ospfd" ]; then
15+
logger -t frr_wrapper "WATCHFRR - OSPFD - Starting CARP event handler now"
16+
/usr/local/opnsense/scripts/frr/carp_event_handler
17+
fi
18+
# If frr starts up
19+
if [ "$1" = "all" ]; then
20+
(
21+
/usr/bin/logger -t frr_wrapper "WATCHFRR - STARTUP - Starting CARP event handler now"
22+
/usr/local/opnsense/scripts/frr/carp_event_handler
23+
) &
24+
fi
25+
exit $?

net/frr/src/opnsense/service/conf/actions.d/actions_quagga.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ message:restarting frr
1818
description:Restart FRR
1919

2020
[reload]
21-
command:service frr reload
21+
command:service frr reload && /usr/local/opnsense/scripts/frr/carp_event_handler
2222
parameters:
2323
type:script
2424
message:reloading frr

net/frr/src/opnsense/service/templates/OPNsense/Quagga/frr

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ frr_carp_demote="{%
1818
if not helpers.empty('OPNsense.quagga.ospf.carp_demote') %} ospfd{% endif %}{%
1919
if not helpers.empty('OPNsense.quagga.ospf6.carp_demote') %} ospf6d{% endif
2020
%}"
21-
start_postcmd='
22-
# XXX rc.d/frr declares its own post command we need to hook first
23-
start_postcmd
24-
# XXX rc.d/frr iterates through daemons so we need to hook last one
25-
if [ "${frr_daemons}" != "${frr_daemons% ${name}}" ]; then
26-
echo "Starting CARP event handler now"
27-
/usr/local/opnsense/scripts/frr/carp_event_handler
28-
fi
29-
'
21+
watchfrr_flags="-r /usr/local/opnsense/scripts/frr/frr_restart.shbB%s -s /usr/local/opnsense/scripts/frr/frr_start.shbB%s -k /usr/sbin/servicebBfrrbBstopbB%s -b bB -t 30"
3022
{% if OPNsense.quagga.general.enablesnmp == '1' %}
3123
zebra_flags="${zebra_flags} -M snmp"
3224
bgpd_flags="${bgpd_flags} -M snmp"

0 commit comments

Comments
 (0)