Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions net/frr/src/etc/rc.syshook.d/start/50-frr
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
#!/bin/sh
#!/usr/local/bin/php
<?php

# XXX this should not be strictly needed
/usr/local/etc/rc.d/frr start
/*
* Copyright (C) 2018 Franco Fichtner <[email protected]>
* Copyright (C) 2004 Scott Ullrich <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

require_once('config.inc');
require_once('util.inc');
require_once('plugins.inc.d/frr.inc');

if (frr_enabled()) {
shell_exec('/usr/local/opnsense/scripts/frr/carp_event_handler');
}
55 changes: 55 additions & 0 deletions net/frr/src/opnsense/scripts/frr/frr_wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh

# Copyright (c) 2025 Andy Binder <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.

# Service wrapper for starting/restarting frr service
# This wrapper is needed to react on specific service interactions through watchfrr.
# Startup details with watchfrr enabled (default):
# 1. "service frr start" calls "service frr start watchfrr"
# 2. watchfrr once started calls "service frr restart all"
# 3. "restart all" need to loop the list of $frr_daemons to start each
# of then
# 4. vtysh -b is executed to load boot startup configuration

ACTION="$1"
COMMAND="$2"

/usr/sbin/service frr "$ACTION" "$COMMAND"
SERVICE_EXIT_CODE=$?

# If frr starts/restarts ospfd, e.g. on process error (parameter: start/restart ospfd)
if [ "$2" = "ospfd" ]; then
logger -t frr_wrapper "WATCHFRR - OSPFD - Starting CARP event handler now"
/usr/local/opnsense/scripts/frr/carp_event_handler
fi
# If frr starts up (parameter: restart all)
if [ "$2" = "all" ]; then
(
/usr/bin/logger -t frr_wrapper "WATCHFRR - STARTUP - Starting CARP event handler now"
/usr/local/opnsense/scripts/frr/carp_event_handler
) &
fi
exit $SERVICE_EXIT_CODE
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ message:restarting frr
description:Restart FRR

[reload]
command:service frr reload
command:service frr reload; /usr/local/opnsense/scripts/frr/carp_event_handler
parameters:
type:script
message:reloading frr
Expand Down
10 changes: 1 addition & 9 deletions net/frr/src/opnsense/service/templates/OPNsense/Quagga/frr
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ frr_carp_demote="{%
if not helpers.empty('OPNsense.quagga.ospf.carp_demote') %} ospfd{% endif %}{%
if not helpers.empty('OPNsense.quagga.ospf6.carp_demote') %} ospf6d{% endif
%}"
start_postcmd='
# XXX rc.d/frr declares its own post command we need to hook first
start_postcmd
# XXX rc.d/frr iterates through daemons so we need to hook last one
if [ "${frr_daemons}" != "${frr_daemons% ${name}}" ]; then
echo "Starting CARP event handler now"
/usr/local/opnsense/scripts/frr/carp_event_handler
fi
'
watchfrr_flags="-r /usr/local/opnsense/scripts/frr/frr_wrapper.shbBrestartbB%s -s /usr/local/opnsense/scripts/frr/frr_wrapper.shbBstartbB%s -k /usr/sbin/servicebBfrrbBstopbB%s -b bB -t 30"
{% if OPNsense.quagga.general.enablesnmp == '1' %}
zebra_flags="${zebra_flags} -M snmp"
bgpd_flags="${bgpd_flags} -M snmp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Local syslog-ng configuration filter definition [FRR].
###################################################################
filter f_local_routing_frr {
program("bgpd") or program("ospfd") or program("ospf6d") or program("ripd") or program("zebra") or program("frr_carp");
program("bgpd") or program("ospfd") or program("ospf6d") or program("ripd") or program("zebra") or program("frr_carp") or program("frr_wrapper");
};