Skip to content

Commit

Permalink
net/frr9: New major version 9.0.1 of FRRouting
Browse files Browse the repository at this point in the history
ChangeLog: https://frrouting.org/release/9.0.1/

PR:		273790
Reported by:	R. Christian McDonald <rcm@rcm.sh>
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Event:		Oslo Hackathon at Modirum
  • Loading branch information
ocochard committed Oct 5, 2023
1 parent b4b03c1 commit 182306a
Show file tree
Hide file tree
Showing 11 changed files with 644 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/Makefile
Expand Up @@ -176,6 +176,8 @@
SUBDIR += frr7-pythontools
SUBDIR += frr8
SUBDIR += frr8-pythontools
SUBDIR += frr9
SUBDIR += frr9-pythontools
SUBDIR += fspclient
SUBDIR += fspd
SUBDIR += fsplib
Expand Down
7 changes: 7 additions & 0 deletions net/frr9-pythontools/Makefile
@@ -0,0 +1,7 @@
COMMENT= Provide configuration reload functionality for FRR

PYTHONTOOLS= yes

MASTERDIR= ${.CURDIR}/../frr9

.include "${MASTERDIR}/Makefile"
3 changes: 3 additions & 0 deletions net/frr9-pythontools/pkg-plist
@@ -0,0 +1,3 @@
sbin/frr-reload.py
sbin/generate_support_bundle.py
%%ETCDIR%%/support_bundle_commands.conf
147 changes: 147 additions & 0 deletions net/frr9/Makefile
@@ -0,0 +1,147 @@
PORTNAME= frr
PORTVERSION= 9.0.1
DISTVERSIONPREFIX= frr-
CATEGORIES= net
.if defined(PYTHONTOOLS)
PKGNAMESUFFIX= 9-pythontools
.else
PKGNAMESUFFIX= 9
.endif

MAINTAINER= olivier@FreeBSD.org

COMMENT?= IP routing protocol suite including BGP, IS-IS, OSPF, BABEL and RIP
WWW= https://frrouting.org/

LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/COPYING

.if defined(PYTHONTOOLS)
RUN_DEPENDS= frr-reload:net/frr9

USES= python:run shebangfix

post-patch:
@${REINPLACE_CMD} -e 's|/etc/frr|${ETCDIR}|g' \
-e 's|/usr/bin|${PREFIX}/bin|g' \
-e 's|/usr/local/bin/tail|${TAIL}|g' \
${WRKSRC}/tools/frr-reload.py
@${REINPLACE_CMD} -e 's|/etc/frr|${ETCDIR}|g' \
${WRKSRC}/tools/generate_support_bundle.py

do-install:
${MKDIR} ${STAGEDIR}${ETCDIR}
${INSTALL_SCRIPT} ${WRKSRC}/tools/frr-reload.py ${STAGEDIR}/${PREFIX}/sbin/
${INSTALL_SCRIPT} ${WRKSRC}/tools/generate_support_bundle.py ${STAGEDIR}/${PREFIX}/sbin/
${INSTALL_DATA} ${WRKSRC}/tools/etc/frr/support_bundle_commands.conf ${STAGEDIR}${ETCDIR}/
.else

LIB_DEPENDS= libcares.so:dns/c-ares \
libjson-c.so:devel/json-c \
libpcre2-8.so:devel/pcre2 \
libprotobuf-c.so:devel/protobuf-c \
libyang.so.2:net/libyang2

USES= autoreconf bison compiler:c++11-lang gmake libtool makeinfo \
pkgconfig python:build readline shebangfix

BINARY_ALIAS= python=${PYTHON_VERSION}

CONFLICTS= frr[78] openbgpd openospfd quagga zebra

GNU_CONFIGURE= yes
INSTALL_TARGET= install-strip
USE_LDCONFIG= yes
.endif

USE_GITHUB= yes
GH_ACCOUNT= FRRouting

.if defined(PYTHONTOOLS)
NO_BUILD= yes
NO_ARCH= yes

SHEBANG_FILES= tools/frr-reload.py \
tools/generate_support_bundle.py
PLIST= ${.CURDIR}/pkg-plist
PKGMESSAGE= ""
.else
INFO= frr

OPTIONS_DEFINE= BACKTRACE CONFIGROLLBACKS DATACENTER FPM LDPD MANPAGES \
MULTIPATH PAM RPKI SHARPD SHELLACCESS SNMP TCMALLOC
OPTIONS_DEFAULT= BACKTRACE FPM MANPAGES RPKI
OPTIONS_SUB= yes

BACKTRACE_DESC= Enable backtrace
CONFIGROLLBACKS_DESC= Enable configuration rollback support
DATACENTER_DESC= Use reduced BGP timers
FPM_DESC= Enable Forwarding Plane Manager support
LDPD_DESC= Build ldpd
MULTIPATH_DESC= Allow 64 multipath routes (16 default)
PAM_DESC= Use libpam for PAM support in vtysh
RPKI_DESC= Add BGP RPKI (RFC 6810) support
SHARPD_DESC= Build sharpd
SHELLACCESS_DESC= Allow users to access shell/telnet/ssh
SNMP_DESC= SNMP support
TCMALLOC_DESC= Use tcmalloc

USERS= frr
GROUPS= frr frrvty

CPPFLAGS+= -I${LOCALBASE}/include
LDFLAGS+= -L${LOCALBASE}/lib

# PIMD and PBRD compile but doesn't work on FreeBSD
CONFIGURE_ARGS= --enable-user=frr \
--enable-group=frr \
--enable-vty-group=frrvty \
--enable-vtysh \
--disable-doc-html \
--sysconfdir=${ETCDIR} \
--localstatedir=/var/run/frr \
--disable-nhrpd \
--disable-pathd \
--disable-ospfclient \
--disable-pimd \
--disable-pbrd \
--with-vtysh-pager=cat

BACKTRACE_LIB_DEPENDS= libunwind.so:devel/libunwind
BACKTRACE_CONFIGURE_ENABLE= backtrace
CONFIGROLLBACKS_LIB_DEPENDS= libsqlite3.so:databases/sqlite3
CONFIGROLLBACKS_CONFIGURE_ENABLE= config-rollbacks
DATACENTER_CONFIGURE_ENABLE= datacenter
FPM_CONFIGURE_ENABLE= fpm
LDPD_CONFIGURE_ENABLE= ldpd
MANPAGES_BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}sphinx>=0,1:textproc/py-sphinx@${PY_FLAVOR}
MANPAGES_CONFIGURE_OFF= --disable-doc
MULTIPATH_CONFIGURE_ON= --enable-multipath=64
PAM_CONFIGURE_WITH= libpam
RPKI_CONFIGURE_ENABLE= rpki
RPKI_LIB_DEPENDS= librtr.so:net-mgmt/rtrlib \
libssh.so:security/libssh
SHARPD_CONFIGURE_ENABLE= sharpd
SHELLACCESS_CONFIGURE_ENABLE= shell-access
SNMP_CONFIGURE_ENABLE= snmp
SNMP_LIB_DEPENDS= libnetsnmp.so:net-mgmt/net-snmp
SNMP_USES= ssl
TCMALLOC_CONFIGURE_ENABLE= tcmalloc
TCMALLOC_LIB_DEPENDS= libtcmalloc.so:devel/google-perftools

USE_RC_SUBR= frr watchfrr

SHEBANG_FILES= yang/embedmodel.py

post-patch:
@${REINPLACE_CMD} -e 's|/etc/frr|${ETCDIR}|g' \
-e 's|/usr/lib/|${PREFIX}/lib/|g' \
-e 's|frr-pythontools|frr9-pythontools|g' \
${WRKSRC}/tools/frr-reload

post-install:
${MKDIR} ${STAGEDIR}/var/run/frr
${INSTALL_SCRIPT} ${WRKSRC}/tools/frr-reload ${STAGEDIR}${PREFIX}/sbin
.endif

.include <bsd.port.mk>
3 changes: 3 additions & 0 deletions net/frr9/distinfo
@@ -0,0 +1,3 @@
TIMESTAMP = 1694701143
SHA256 (FRRouting-frr-frr-9.0.1_GH0.tar.gz) = 3a371ece41cdf334b070811287f6733acabbadb442c8e693f8b66ec517592db7
SIZE (FRRouting-frr-frr-9.0.1_GH0.tar.gz) = 10334150
168 changes: 168 additions & 0 deletions net/frr9/files/frr.in
@@ -0,0 +1,168 @@
#!/bin/sh

# PROVIDE: frr dynamicrouting
# REQUIRE: netif routing
# KEYWORD: nojailvnet shutdown

# Add the following line to /etc/rc.conf to enable frr:
# frr_enable="YES"
#
# You may also wish to use the following variables to fine-tune startup:
# Enable Integrated configuration mode (using the single configuration file
# frr.conf in place of one file for each dameon)
# frr_vtysh_boot="YES"
# Selecting limited set of daemons to run
# frr_daemons="zebra mgmtd babeld bfdd bgpd eigrpd fabricd isisd ospfd ospf6d ripd ripngd staticd"
# Global tuning
# frr_flags=""
# Per daemon tuning may be done with daemon_name_flags
# zebra_flags="-P 0"
# bgpd_flags="-nrP 0" and so on
# If you want to give the routing daemons a chance to catchup before
# continuing, set frr_wait_for to a "default" or certain prefix.
# frr_wait_for="default"
# Set the time limit for the wait.
# frr_wait_seconds="90"
#
# If the frr daemons require additional shared libraries to start,
# use the following variable to run ldconfig(8) in advance:
# frr_extralibs_path="/usr/local/lib ..."
#
# This RC script was adapted from the net/quagga port

. /etc/rc.subr

name=frr
rcvar=${name}_enable

start_postcmd=start_postcmd
stop_postcmd="rm -f $pidfile"
configtest_cmd=check_config
extra_commands=configtest
command_args="-d"

load_rc_config $name
: ${frr_enable:="NO"}
: ${frr_flags:=""}
: ${frr_daemons:="zebra mgmtd babeld bfdd bgpd eigrpd fabricd isisd ospfd ospf6d ripd ripngd staticd"}
: ${frr_vtysh_boot:="NO"}
: ${frr_wait_for:=""}
: ${frr_wait_seconds:="90"}

check_config()
{
echo "Checking $daemon.conf"
# pimd doesn't support -C
if [ "$daemon" = "pimd" ]; then
echo "Ignored"
else
$command $daemon_flags -C
result=$?
if [ "$result" -eq "0" ]; then
echo "OK"
else
echo "FAILED"
exit
fi
fi
}

start_postcmd()
{
local waited_for
waited_for=0
# Wait only when last daemon has started.
if [ "${frr_daemons}" = "${frr_daemons% ${name}}" ]; then
return;
fi
if [ -n "${frr_wait_for}" ]; then
echo Waiting for ${frr_wait_for} route...
while [ ${waited_for} -lt ${frr_wait_seconds} ]; do
/sbin/route -n get ${frr_wait_for} >/dev/null 2>&1 && break;
waited_for=$((waited_for+1))
sleep 1;
done
[ ${waited_for} -lt ${frr_wait_seconds} ] || echo Giving up...
fi
}

do_cmd()
{
local ret
ret=0
frr_cmd=$1
if checkyesno frr_vtysh_boot && ( [ ${frr_cmd} = "restart" ] || [ ${frr_cmd} = "start" ] ); then
echo "Checking intergrated config..."
daemon="vtysh"
daemon_flags=""
command=%%PREFIX%%/bin/${daemon}
if ! [ -f %%ETCDIR%%/vtysh.conf ]; then
touch %%ETCDIR%%/vtysh.conf
fi
check_config
fi
for daemon in ${frr_daemons}; do
command=%%PREFIX%%/sbin/${daemon}
pidfile=/var/run/frr/${daemon}.pid
if ! checkyesno frr_vtysh_boot; then
required_files=%%ETCDIR%%/${daemon}.conf
if [ ${frr_cmd} = "restart" ] || [ ${frr_cmd} = "start" ]; then
check_config
fi
if [ ${frr_cmd} = "start" ] && ! [ -f ${required_files} ]; then
continue
fi
fi
if [ ${frr_cmd} = "stop" ] && [ -z "$(check_process ${command})" ]; then
continue
fi
eval flags=\$\{${daemon}_flags:-\"${frr_flags}\"\}
name=${daemon}
_rc_restart_done=false
run_rc_command "$1" || ret=1
done
if checkyesno frr_vtysh_boot && ( [ ${frr_cmd} = "restart" ] || [ ${frr_cmd} = "start" ] ); then
echo "Booting for integrated-vtysh-config..."
%%PREFIX%%/bin/vtysh -b
fi
return ${ret}
}

frr_cmd=$1

case "$1" in
force*)
frr_cmd=${frr_cmd#force}
;;
fast*)
frr_cmd=${frr_cmd#fast}
;;
esac
shift

if [ $# -ge 1 -a "$1" != "all" ]; then
frr_daemons="$*"
fi

case "${frr_cmd}" in
start|quietstart)
if [ -n "${frr_extralibs_path}" ]; then
/sbin/ldconfig -m ${frr_extralibs_path}
fi
# Why should I need to add this check ?
checkyesno frr_enable && do_cmd "start"
;;
stop)
frr_daemons=$(reverse_list ${frr_daemons})
do_cmd "stop"
;;
restart)
frr_daemons=$(reverse_list ${frr_daemons})
do_cmd "stop"
frr_daemons=$(reverse_list ${frr_daemons})
checkyesno frr_enable && do_cmd "start"
;;
*)
do_cmd "${frr_cmd}"
;;
esac
11 changes: 11 additions & 0 deletions net/frr9/files/patch-Makefile.am
@@ -0,0 +1,11 @@
--- Makefile.am.orig 2021-11-08 12:44:24.000000000 +0900
+++ Makefile.am 2021-12-23 09:23:13.400659000 +0900
@@ -168,7 +168,7 @@
include qpb/subdir.am
include fpm/subdir.am
include grpc/subdir.am
-include tools/subdir.am
+# include tools/subdir.am

include bgpd/subdir.am
include bgpd/rfp-example/librfp/subdir.am
30 changes: 30 additions & 0 deletions net/frr9/files/watchfrr.in
@@ -0,0 +1,30 @@
#!/bin/sh

# PROVIDE: watchfrr
# REQUIRE: NETWORKING frr
# KEYWORD: nojailvtnet shutdown

# Add the following line to /etc/rc.conf to enable watchfrr:
# watchfrr_enable="YES"
#
# You may also wish to use the following variables to fine-tune startup:
# watchfrr_flags
# Example of flags usage:
# watchfrr_flags=" -d -r /usr/sbin/servicebBfrrbBrestartbB%s -s /usr/sbin/servicebBfrrbBstartbB%s -k /usr/sbin/servicebBfrrbBstopbB%s -b bB -t 30 zebra ripd ripngd ospfd ospf6d bgpd isisd eigrpd babeld bfdd staticd"

. /etc/rc.subr

name=watchfrr
rcvar=${name}_enable

load_rc_config $name

stop_postcmd="rm -f $pidfile"

watchfrr_enable=${watchfrr_enable:-"NO"}
watchfrr_flags=${watchfrr_flags:-"-d -r /usr/sbin/servicebBfrrbBrestartbB%s -s /usr/sbin/servicebBfrrbBstartbB%s -k /usr/sbin/servicebBfrrbBstopbB%s -b bB -t 30 zebra babeld bfdd bgpd eigrpd fabricd isisd ospfd ospf6d ripd ripngd staticd"}

command=%%PREFIX%%/sbin/watchfrr
pidfile=/var/run/frr/watchfrr.pid

run_rc_command "$1"
3 changes: 3 additions & 0 deletions net/frr9/pkg-descr
@@ -0,0 +1,3 @@
FRRouting (FRR) is an IP routing protocol suite for Linux and Unix platforms
which includes protocol daemons for BGP, IS-IS, OSPF and RIP. FRR has its roots
in the Quagga project.

0 comments on commit 182306a

Please sign in to comment.