From f16e4528816cb254b330e416285be9ec00b8da4e Mon Sep 17 00:00:00 2001 From: Joachim Desroches Date: Wed, 5 May 2021 17:44:39 +0200 Subject: [PATCH] Add __bird_radv type. --- type/__bird_radv/man.rst | 65 ++++++++++++++++ type/__bird_radv/manifest | 81 ++++++++++++++++++++ type/__bird_radv/parameter/optional_multiple | 3 + type/__bird_radv/parameter/required_multiple | 1 + 4 files changed, 150 insertions(+) create mode 100644 type/__bird_radv/man.rst create mode 100755 type/__bird_radv/manifest create mode 100644 type/__bird_radv/parameter/optional_multiple create mode 100644 type/__bird_radv/parameter/required_multiple diff --git a/type/__bird_radv/man.rst b/type/__bird_radv/man.rst new file mode 100644 index 0000000..118fd60 --- /dev/null +++ b/type/__bird_radv/man.rst @@ -0,0 +1,65 @@ +cdist-type__bird_radv(7) +======================== + +NAME +---- +cdist-type__bird_radv - Configure the Bird Internet Router Daemon to send RAdvs. + + +DESCRIPTION +----------- + +The Bird Internet Router Daemon knows about a bunch of internet routing +protocols. In particular, it can send Router Advertisements to help +autoconfigure IPv6 hosts, this type is a rudimentary implementation to generate +configuration for Bird to do so. + + +REQUIRED MULTIPLE PARAMETERS +---------------------------- +interface + The interfaces to activate the protocol on. RAs will be sent using the + prefixes configured on these interfaces. + + +OPTIONAL MULTIPLE PARAMETERS +---------------------------- +route + Routes to be added to the RA for hosts. + +ns + Recursive DNS servers given to the hosts through RAs. + +dnssl + Search domain to be given to the hosts through RAs. + + +EXAMPLES +-------- + +.. code-block:: sh + + __bird_radv datacenter \ + --interface eth1 \ + --route ::/0 \ + --ns 2001:DB8:cafe::4 \ + --ns 2001:DB8:cafe::14 \ + --dnssl "example.com" + + +SEE ALSO +-------- +`__bird_core(7)` + + +AUTHORS +------- +Joachim Desroches + + +COPYING +------- +Copyright \(C) 2021 Joachim Desroches. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/type/__bird_radv/manifest b/type/__bird_radv/manifest new file mode 100755 index 0000000..a95e88e --- /dev/null +++ b/type/__bird_radv/manifest @@ -0,0 +1,81 @@ +#!/bin/sh -e +# +# 2021 Joachim Desroches (joachim.desroches@epfl.ch) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +os=$(cat "${__global:?}/explorer/os") + +case "$os" in +'alpine'|'debian'|'ubuntu') + confdir='/etc/bird.d' +;; +*) + printf "Your operating system (%s) is currently not supported by __bird_radv\n" "$os" >&2 + printf "Please contribute an implementation for it if you can.\n" >&2 + exit 1 +;; +esac + +have_routes=no +if [ -f "${__object:?}/parameter/route" ]; +then + have_routes=yes +fi + +RDNS= +if [ -f "${__object:?}/parameter/ns" ]; +then + RDNS=$(cat << EOF + rdnss { +$(sed -e 's/^/\t\tns /' -e 's/$/;/' "${__object:?}/parameter/ns") + }; + +EOF +) +fi + +DNSSL= +if [ -f "${__object:?}/parameter/dnssl" ]; +then + DNSSL=$(sed -e 's/^/\tdnssl "/' -e 's/$/";/' "${__object:?}/parameter/dnssl") +fi + +__file "${confdir:?}/radv-${__object_id:?}.conf" \ + --mode 0640 --owner root --group bird \ + --source - << EOF +ipv6 table radv_routes; + +protocol static { + description "Routes advertised via RAs"; + ipv6 { table radv_routes; }; + +$(sed -e 's/^/\troute /' -e 's/$/ unreachable;/' "${__object:?}/parameter/route") +} + +protocol radv ${__object_id:?} { + propagate routes ${have_routes:?}; + ipv6 { table radv_routes; export all; }; + +$(sed -e 's/^/\tinterface "/' -e 's/$/";/' "${__object:?}/parameter/interface") + +$RDNS + +$DNSSL + +} +EOF diff --git a/type/__bird_radv/parameter/optional_multiple b/type/__bird_radv/parameter/optional_multiple new file mode 100644 index 0000000..d3e3505 --- /dev/null +++ b/type/__bird_radv/parameter/optional_multiple @@ -0,0 +1,3 @@ +dnssl +ns +route diff --git a/type/__bird_radv/parameter/required_multiple b/type/__bird_radv/parameter/required_multiple new file mode 100644 index 0000000..b529896 --- /dev/null +++ b/type/__bird_radv/parameter/required_multiple @@ -0,0 +1 @@ +interface