From 515e475c99d49c0bd916dbb44bf902300d9e162a Mon Sep 17 00:00:00 2001 From: Sergey Popov Date: Thu, 14 Sep 2017 16:44:00 +0300 Subject: [PATCH] Add ebuild for FRRouting - Quagga fork with some additional features --- net-misc/frr/Manifest | 2 + .../frr/files/frr-2.0-ipctl-forwarding.patch | 22 +++ net-misc/frr/files/frr.init | 43 ++++++ net-misc/frr/files/frr.pam | 26 ++++ net-misc/frr/files/systemd/bgpd.service | 16 +++ net-misc/frr/files/systemd/frr.conf | 1 + net-misc/frr/files/systemd/isisd.service | 16 +++ net-misc/frr/files/systemd/ldpd.service | 16 +++ net-misc/frr/files/systemd/nhrpd.service | 16 +++ net-misc/frr/files/systemd/ospf6d.service | 16 +++ net-misc/frr/files/systemd/ospfd.service | 16 +++ net-misc/frr/files/systemd/pimd.service | 17 +++ net-misc/frr/files/systemd/ripd.service | 16 +++ net-misc/frr/files/systemd/ripngd.service | 16 +++ net-misc/frr/files/systemd/zebra.service | 16 +++ net-misc/frr/frr-2.0.ebuild | 135 ++++++++++++++++++ net-misc/frr/metadata.xml | 41 ++++++ 17 files changed, 431 insertions(+) create mode 100644 net-misc/frr/Manifest create mode 100644 net-misc/frr/files/frr-2.0-ipctl-forwarding.patch create mode 100644 net-misc/frr/files/frr.init create mode 100644 net-misc/frr/files/frr.pam create mode 100644 net-misc/frr/files/systemd/bgpd.service create mode 100644 net-misc/frr/files/systemd/frr.conf create mode 100644 net-misc/frr/files/systemd/isisd.service create mode 100644 net-misc/frr/files/systemd/ldpd.service create mode 100644 net-misc/frr/files/systemd/nhrpd.service create mode 100644 net-misc/frr/files/systemd/ospf6d.service create mode 100644 net-misc/frr/files/systemd/ospfd.service create mode 100644 net-misc/frr/files/systemd/pimd.service create mode 100644 net-misc/frr/files/systemd/ripd.service create mode 100644 net-misc/frr/files/systemd/ripngd.service create mode 100644 net-misc/frr/files/systemd/zebra.service create mode 100644 net-misc/frr/frr-2.0.ebuild create mode 100644 net-misc/frr/metadata.xml diff --git a/net-misc/frr/Manifest b/net-misc/frr/Manifest new file mode 100644 index 0000000..88445a4 --- /dev/null +++ b/net-misc/frr/Manifest @@ -0,0 +1,2 @@ +DIST frr-2.0.tar.xz 2505972 SHA256 201567ddf9e89bb2f639c0ee6a8166a8c8e8458bc35d0cf5891982ec3b18d5bc SHA512 1b0aecd6c746afc16615baf2a8a66afe41050b4fffb434e55441287e3994c9197b3898a0362d4641a077981a8836c6b5592e995cd47218d695ec901c37f215ea WHIRLPOOL 186cb60f316b30cf9bafeb9a4017dc8102be1e0911a85650c09685c451d5b6d00dea0fa615f4f419b3c42bd904a2d2bff96ea58f388da9bc997ea3622ba4ff7c +DIST ht-20040304-classless-bgp.patch 1581 SHA256 39993890f9e31d662ed0564c732fb22392a901beb45b64261ffeadd9edf27887 SHA512 3df102d8ab88aaee1f109a2310602d6f734f2268252e5e42df752df7db7abeac526e969289481c4abfe905dcd41c35dee65196c48ac320fe9d083305451476e8 WHIRLPOOL cef99d64d52ab8c28bd672fb93dfbd8d716a31c76a5403496a6d104a5ff39531d6085134124d41fe4ff7adf895fa001cbe77b6e42846d849d6c108c81583d04e diff --git a/net-misc/frr/files/frr-2.0-ipctl-forwarding.patch b/net-misc/frr/files/frr-2.0-ipctl-forwarding.patch new file mode 100644 index 0000000..f6b726b --- /dev/null +++ b/net-misc/frr/files/frr-2.0-ipctl-forwarding.patch @@ -0,0 +1,22 @@ +Fix for missing definitions on some Hardened configurations +Gentoo bug: https://bugs.gentoo.org/show_bug.cgi?id=437292 + +diff -Naur quagga-0.99.16.orig/zebra/ipforward_sysctl.c quagga-0.99.16/zebra/ipforward_sysctl.c +--- quagga-0.99.16.orig/zebra/ipforward_sysctl.c 2010-03-11 12:11:32.000000000 -0500 ++++ quagga-0.99.16/zebra/ipforward_sysctl.c 2010-03-11 12:11:39.000000000 -0500 +@@ -31,6 +31,15 @@ + + #define MIB_SIZ 4 + ++/* Fix for recent (2.6.14) kernel headers */ ++#ifndef IPCTL_FORWARDING ++ #define IPCTL_FORWARDING NET_IPV4_FORWARD ++#endif ++ ++#ifndef IP6CTL_FORWARDING ++ #define IP6CTL_FORWARDING NET_IPV6_FORWARDING ++#endif ++ + extern struct zebra_privs_t zserv_privs; + + /* IPv4 forwarding control MIB. */ diff --git a/net-misc/frr/files/frr.init b/net-misc/frr/files/frr.init new file mode 100644 index 0000000..be0d54a --- /dev/null +++ b/net-misc/frr/files/frr.init @@ -0,0 +1,43 @@ +#!/sbin/openrc-run +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +: ${CFGFILE:=/etc/frr/${SVCNAME}.conf} + +pidfile=/run/frr/${SVCNAME}.pid + +command=/usr/sbin/${SVCNAME} +command_args="-d -f ${CFGFILE} ${EXTRA_OPTS} --pid_file ${pidfile}" + +get_service_config() { + [ -e "$CFGFILE" ] || return + + awk '$1 == "'$1'" { s=$2 } END { print s }' "$CFGFILE" +} + +depend() { + config "$CFGFILE" + + [ ${SVCNAME} = "zebra" ] && need net || need zebra + + [ "$(get_service_config log)" = "syslog" ] && \ + use logger +} + +start_pre() { + if [ ! -e "${CFGFILE}" ] ; then + eerror "Before starting ${SVCNAME} you have to configure it, by creating" + eerror "a ${CFGFILE} file." + eerror "" + eerror "A sample file has been installed in `echo /usr/share/doc/frr-*/samples/${SVCNAME}.conf.sample*`" + return 1 + fi + + checkpath -d -m 0750 -o quagga:quagga /run/frr + + if [ ${SVCNAME} = "zebra" ]; then + ebegin "Cleaning up stale zebra routes..." + ip route flush proto zebra + eend $? + fi +} diff --git a/net-misc/frr/files/frr.pam b/net-misc/frr/files/frr.pam new file mode 100644 index 0000000..5cef5d9 --- /dev/null +++ b/net-misc/frr/files/frr.pam @@ -0,0 +1,26 @@ +#%PAM-1.0 +# + +##### if running frr as root: +# Only allow root (and possibly wheel) to use this because enable access +# is unrestricted. +auth sufficient pam_rootok.so + +# Uncomment the following line to implicitly trust users in the "wheel" group. +#auth sufficient pam_wheel.so trust use_uid +# Uncomment the following line to require a user to be in the "wheel" group. +#auth required pam_wheel.so use_uid +########################################################### + +# If using frr privileges and with a seperate group for vty access, then +# access can be controlled via the vty access group, and pam can simply +# check for valid user/password, eg: +# +# only allow local users. +#auth required pam_securetty.so +#auth include system-auth +#auth required pam_nologin.so +#account include system-auth +#password include system-auth +#session include system-auth +#session optional pam_console.so diff --git a/net-misc/frr/files/systemd/bgpd.service b/net-misc/frr/files/systemd/bgpd.service new file mode 100644 index 0000000..c25d652 --- /dev/null +++ b/net-misc/frr/files/systemd/bgpd.service @@ -0,0 +1,16 @@ +[Unit] +Description=BGP routing daemon +Documentation=man:bgpd(8) man:zebra(8) +BindsTo=zebra.service +After=network.target zebra.service +ConditionPathExists=/etc/frr/bgpd.conf + +[Service] +Type=forking +PIDFile=/run/frr/bgpd.pid +ExecStart=/usr/sbin/bgpd -d +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/files/systemd/frr.conf b/net-misc/frr/files/systemd/frr.conf new file mode 100644 index 0000000..cab5e8f --- /dev/null +++ b/net-misc/frr/files/systemd/frr.conf @@ -0,0 +1 @@ +d /run/frr 0750 quagga quagga diff --git a/net-misc/frr/files/systemd/isisd.service b/net-misc/frr/files/systemd/isisd.service new file mode 100644 index 0000000..b77c717 --- /dev/null +++ b/net-misc/frr/files/systemd/isisd.service @@ -0,0 +1,16 @@ +[Unit] +Description=IS-IS routing daemon +Documentation=man:isis(8) man:zebra(8) +BindsTo=zebra.service +After=network.target zebra.service +ConditionPathExists=/etc/frr/isisd.conf + +[Service] +Type=forking +PIDFile=/run/frr/isisd.pid +ExecStart=/usr/sbin/isisd -d +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/files/systemd/ldpd.service b/net-misc/frr/files/systemd/ldpd.service new file mode 100644 index 0000000..06150df --- /dev/null +++ b/net-misc/frr/files/systemd/ldpd.service @@ -0,0 +1,16 @@ +[Unit] +Description=LDP daemon +Documentation=man:ldpd(8) man:zebra(8) +BindsTo=zebra.service +After=network.target zebra.service +ConditionPathExists=/etc/frr/ldpd.conf + +[Service] +Type=forking +PIDFile=/run/frr/ldpd.pid +ExecStart=/usr/sbin/ldpd -d +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/files/systemd/nhrpd.service b/net-misc/frr/files/systemd/nhrpd.service new file mode 100644 index 0000000..8374f83 --- /dev/null +++ b/net-misc/frr/files/systemd/nhrpd.service @@ -0,0 +1,16 @@ +[Unit] +Description=NHRP daemon +Documentation=man:nhrpd(8) man:zebra(8) +BindsTo=zebra.service +After=network.target zebra.service +ConditionPathExists=/etc/frr/nhrpd.conf + +[Service] +Type=forking +PIDFile=/run/frr/nhrpd.pid +ExecStart=/usr/sbin/nhrpd -d +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/files/systemd/ospf6d.service b/net-misc/frr/files/systemd/ospf6d.service new file mode 100644 index 0000000..d6a98dd --- /dev/null +++ b/net-misc/frr/files/systemd/ospf6d.service @@ -0,0 +1,16 @@ +[Unit] +Description=OSPF routing daemon for IPv6 +Documentation=man:ospfd(8) man:zebra(8) +BindsTo=zebra.service +After=network.target zebra.service +ConditionPathExists=/etc/frr/ospf6d.conf + +[Service] +Type=forking +PIDFile=/run/frr/ospf6d.pid +ExecStart=/usr/sbin/ospf6d -d +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/files/systemd/ospfd.service b/net-misc/frr/files/systemd/ospfd.service new file mode 100644 index 0000000..b7daec3 --- /dev/null +++ b/net-misc/frr/files/systemd/ospfd.service @@ -0,0 +1,16 @@ +[Unit] +Description=OSPF routing daemon +Documentation=man:ospfd(8) man:zebra(8) +BindsTo=zebra.service +After=network.target zebra.service +ConditionPathExists=/etc/frr/ospfd.conf + +[Service] +Type=forking +PIDFile=/run/frr/ospfd.pid +ExecStart=/usr/sbin/ospfd -d +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/files/systemd/pimd.service b/net-misc/frr/files/systemd/pimd.service new file mode 100644 index 0000000..e93f737 --- /dev/null +++ b/net-misc/frr/files/systemd/pimd.service @@ -0,0 +1,17 @@ +[Unit] +Description=PIM-SSM routing daemon +Documentation=man:zebra(8) +BindsTo=zebra.service +After=network.target zebra.service +ConditionPathExists=/etc/frr/pimd.conf + +[Service] +Type=forking +PIDFile=/run/frr/pimd.pid +ExecStart=/usr/sbin/pimd -d +ExecReload=/bin/kill -HUP $MAINPID +SuccessExitStatus=1 +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/files/systemd/ripd.service b/net-misc/frr/files/systemd/ripd.service new file mode 100644 index 0000000..cd18eac --- /dev/null +++ b/net-misc/frr/files/systemd/ripd.service @@ -0,0 +1,16 @@ +[Unit] +Description=RIP routing daemon +Documentation=man:ripd(8) man:zebra(8) +BindsTo=zebra.service +After=network.target zebra.service +ConditionPathExists=/etc/frr/ripd.conf + +[Service] +Type=forking +PIDFile=/run/frr/ripd.pid +ExecStart=/usr/sbin/ripd -d +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/files/systemd/ripngd.service b/net-misc/frr/files/systemd/ripngd.service new file mode 100644 index 0000000..b9e10a1 --- /dev/null +++ b/net-misc/frr/files/systemd/ripngd.service @@ -0,0 +1,16 @@ +[Unit] +Description=RIP routing daemon for IPv6 +Documentation=man:ripngd(8) man:zebra(8) +BindsTo=zebra.service +After=network.target zebra.service +ConditionPathExists=/etc/frr/ripngd.conf + +[Service] +Type=forking +PIDFile=/run/frr/ripngd.pid +ExecStart=/usr/sbin/ripngd -d +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/files/systemd/zebra.service b/net-misc/frr/files/systemd/zebra.service new file mode 100644 index 0000000..44b538a --- /dev/null +++ b/net-misc/frr/files/systemd/zebra.service @@ -0,0 +1,16 @@ +[Unit] +Description=GNU Zebra routing manager +Documentation=man:zebra(8) +After=network.target +ConditionPathExists=/etc/frr/zebra.conf + +[Service] +Type=forking +PIDFile=/run/frr/zebra.pid +ExecStartPre=/bin/ip route flush proto zebra +ExecStart=/usr/sbin/zebra -d +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/net-misc/frr/frr-2.0.ebuild b/net-misc/frr/frr-2.0.ebuild new file mode 100644 index 0000000..456e4a8 --- /dev/null +++ b/net-misc/frr/frr-2.0.ebuild @@ -0,0 +1,135 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +CLASSLESS_BGP_PATCH=ht-20040304-classless-bgp.patch + +inherit autotools eutils flag-o-matic multilib pam readme.gentoo-r1 systemd tmpfiles user + +DESCRIPTION="Free Range Routing Protocol Suite, fork of Quagga" +HOMEPAGE="https://frrouting.org/" +SRC_URI="https://github.com/FRRouting/frr/releases/download/${P}/${P}.tar.xz + bgpclassless? ( http://hasso.linux.ee/stuff/patches/quagga/${CLASSLESS_BGP_PATCH} )" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +IUSE="bgpclassless caps fpm doc elibc_glibc ipv6 multipath nhrpd ospfapi pam protobuf +readline snmp tcp-zebra" + +COMMON_DEPEND=" + !!net-misc/quagga + dev-libs/json-c:0= + caps? ( sys-libs/libcap ) + nhrpd? ( net-dns/c-ares:0= ) + protobuf? ( dev-libs/protobuf-c:0= ) + readline? ( + sys-libs/readline:0= + pam? ( sys-libs/pam ) + ) + snmp? ( net-analyzer/net-snmp ) + !elibc_glibc? ( dev-libs/libpcre )" +DEPEND="${COMMON_DEPEND} + sys-apps/gawk + sys-devel/libtool:2" +RDEPEND="${COMMON_DEPEND} + sys-apps/iproute2" + +PATCHES=( + "${FILESDIR}/${PN}-2.0-ipctl-forwarding.patch" +) + +DISABLE_AUTOFORMATTING=1 +DOC_CONTENTS="Sample configuration files can be found in /usr/share/doc/${PF}/samples +You have to create config files in /etc/frr before +starting one of the daemons. + +You can pass additional options to the daemon by setting the EXTRA_OPTS +variable in their respective file in /etc/conf.d" + +pkg_setup() { + enewgroup quagga + enewuser quagga -1 -1 /var/empty quagga +} + +src_prepare() { + # Classless prefixes for BGP + # http://hasso.linux.ee/doku.php/english:network:quagga + use bgpclassless && eapply -p0 "${DISTDIR}/${CLASSLESS_BGP_PATCH}" + + eapply "${PATCHES[@]}" + eapply_user + eautoreconf +} + +src_configure() { + append-flags -fno-strict-aliasing + + # do not build PDF docs + export ac_cv_prog_PDFLATEX=no + export ac_cv_prog_LATEXMK=no + + econf \ + --enable-exampledir=/usr/share/doc/${PF}/samples \ + --enable-irdp \ + --enable-isisd \ + --enable-ldpd \ + --enable-pimd \ + --enable-user=quagga \ + --enable-group=quagga \ + --enable-vty-group=quagga \ + --with-pkg-extra-version="-gentoo" \ + --sysconfdir=/etc/frr \ + --localstatedir=/run/frr \ + --disable-static \ + $(use_enable caps capabilities) \ + $(usex snmp '--enable-snmp' '' '' '') \ + $(use_enable !elibc_glibc pcreposix) \ + $(use_enable fpm) \ + $(use_enable tcp-zebra) \ + $(use_enable doc) \ + $(usex multipath $(use_enable multipath) '' '=0' '') \ + $(usex ospfapi '--enable-opaque-lsa --enable-ospf-te --enable-ospfclient' '' '' '') \ + $(use_enable readline vtysh) \ + $(use_with pam libpam) \ + $(use_enable nhrpd) \ + $(use_enable protobuf) \ + $(use_enable ipv6 ripngd) \ + $(use_enable ipv6 ospf6d) \ + $(use_enable ipv6 rtadv) +} + +src_install() { + default + prune_libtool_files + readme.gentoo_create_doc + + keepdir /etc/frr + fowners root:quagga /etc/frr + fperms 0770 /etc/frr + + # Install systemd-related stuff, bug #553136 + dotmpfiles "${FILESDIR}/systemd/frr.conf" + systemd_dounit "${FILESDIR}/systemd/zebra.service" + + # install zebra as a file, symlink the rest + newinitd "${FILESDIR}"/frr.init zebra + + for service in bgpd isisd ospfd ldpd pimd ripd $(use ipv6 && echo ospf6d ripngd) $(use nhrpd && echo nhrpd); do + dosym zebra /etc/init.d/${service} + systemd_dounit "${FILESDIR}/systemd/${service}.service" + done + + use readline && use pam && newpamd "${FILESDIR}/frr.pam" frr + + insinto /etc/logrotate.d + newins redhat/frr.logrotate frr +} + +pkg_postinst() { + # Path for PIDs before first reboot should be created here, bug #558194 + tmpfiles_process frr.conf + + readme.gentoo_print_elog +} diff --git a/net-misc/frr/metadata.xml b/net-misc/frr/metadata.xml new file mode 100644 index 0000000..4ee9e24 --- /dev/null +++ b/net-misc/frr/metadata.xml @@ -0,0 +1,41 @@ + + + + + admin@pinkbyte.ru + Sergey Popov + + + + Apply unofficial patch to enable classless prefixes for BGP. Patch and information to be found + at http://hasso.linux.ee/doku.php/english:network:quagga + + + Enable Forwarding Plane Manager support + + + Enable multipath routes support for any number of routes + + + Build Next Hop Resolution Protocol daemon + + + Enable OSPFAPI support for client applications accessing the OSPF link state database + + + Add support for PAM (via sys-libs/pam) to the Quagga Virtual Terminal Interface + Shell (vtysh); if the readline USE flag is disabled, this flag is ignored + + + Enable support for dev-libs/protobuf + + + Enable support for sys-libs/readline to provide the Quagga Virtual Terminal + Interface Shell (vtysh) + + + Enable TCP zserv interface on port 2600 for Zebra/protocol-daemon communication. Unix domain + sockets are chosen otherwise + + +