lib: respect --disable-daemon flags in route_types.h

* remove pre-generation of route_types.h from configure

  This change is a partial revert of commit 306ed6816. This is a little
  drawback, but at least "make lib/libfrr.la", mentioned in the commit,
  still works because route_types.h is forced to be built in f1b32b2e5.

* add "enabled" field to route_types.txt to track which daemon should
  be enabled to add the routing protocol to "show ip route" header and
  to redistribution list

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2020-09-30 16:04:50 +03:00
parent 38b7c566eb
commit b3b4dfa5ae
4 changed files with 98 additions and 48 deletions

View File

@ -2460,19 +2460,6 @@ AC_CONFIG_FILES([tools/watchfrr.sh], [chmod +x tools/watchfrr.sh])
AC_CONFIG_FILES([tools/frrinit.sh], [chmod +x tools/frrinit.sh])
AC_CONFIG_FILES([tools/frrcommon.sh])
AC_CONFIG_COMMANDS([lib/route_types.h], [
dst="${ac_abs_top_builddir}/lib/route_types.h"
${PERL} "${ac_abs_top_srcdir}/lib/route_types.pl" \
< "${ac_abs_top_srcdir}/lib/route_types.txt" \
> "${dst}.tmp"
test -f "$dst" \
&& diff "${dst}.tmp" "${dst}" >/dev/null 2>/dev/null \
&& rm "${dst}.tmp" \
|| mv "${dst}.tmp" "${dst}"
], [
PERL="$PERL"
])
AS_IF([test "$with_pkg_git_version" = "yes"], [
AC_CONFIG_COMMANDS([lib/gitversion.h], [
dst="${ac_abs_top_builddir}/lib/gitversion.h"

View File

@ -29,6 +29,7 @@
##
use strict;
use Getopt::Long;
# input processing
#
@ -37,6 +38,11 @@ my %protodetail;
my %daemons;
my @enabled;
GetOptions ("enabled=s" => \@enabled);
@enabled = split(/,/,join(',',@enabled));
while (<STDIN>) {
# skip comments and empty lines
next if (/^\s*(#|$)/);
@ -56,7 +62,7 @@ while (<STDIN>) {
# else: 8-field line
my @f = split(/,/, $_);
unless (@f == 8 || @f == 9) {
unless (@f == 9 || @f == 10) {
die "invalid input on route_types line $.\n";
}
@ -74,7 +80,8 @@ while (<STDIN>) {
"ipv6" => int($f[5]),
"redist" => int($f[6]),
"shorthelp" => $f[7],
"restrict2" => $f[8],
"enabled" => $f[8],
"restrict2" => $f[9],
};
push @protos, $proto;
$daemons{$f[2]} = {
@ -109,6 +116,7 @@ sub codelist {
my (@lines) = ();
my $str = " \"Codes: ";
for my $p (@protos) {
next unless (grep $_ eq $protodetail{$p}->{"enabled"}, @enabled);
my $s = sprintf("%s - %s, ",
$protodetail{$p}->{"char"},
$protodetail{$p}->{"shorthelp"});
@ -141,6 +149,7 @@ sub collect {
next if ($protodetail{$p}->{"restrict2"} ne "" &&
$protodetail{$p}->{"restrict2"} ne $daemon);
next if ($protodetail{$p}->{"redist"} eq 0);
next unless (grep $_ eq $protodetail{$p}->{"enabled"}, @enabled);
next unless (($ipv4 && $protodetail{$p}->{"ipv4"})
|| ($ipv6 && $protodetail{$p}->{"ipv6"}));
push @names, $protodetail{$p}->{"cname"};

View File

@ -45,48 +45,48 @@
# If you add a new routing protocol here, make sure you also update
# meta_queue_map in zebra_rib.c
#
## type cname daemon C 4 6 Redist short help Restrictions
ZEBRA_ROUTE_SYSTEM, system, NULL, 'X', 0, 0, 0, "Reserved"
ZEBRA_ROUTE_KERNEL, kernel, zebra, 'K', 1, 1, 1, "kernel route"
ZEBRA_ROUTE_CONNECT, connected, zebra, 'C', 1, 1, 1, "connected"
ZEBRA_ROUTE_STATIC, static, zebra, 'S', 1, 1, 1, "static"
ZEBRA_ROUTE_RIP, rip, ripd, 'R', 1, 0, 1, "RIP"
ZEBRA_ROUTE_RIPNG, ripng, ripngd, 'R', 0, 1, 1, "RIPng"
ZEBRA_ROUTE_OSPF, ospf, ospfd, 'O', 1, 0, 1, "OSPF"
ZEBRA_ROUTE_OSPF6, ospf6, ospf6d, 'O', 0, 1, 1, "OSPFv3"
ZEBRA_ROUTE_ISIS, isis, isisd, 'I', 1, 1, 1, "IS-IS"
ZEBRA_ROUTE_BGP, bgp, bgpd, 'B', 1, 1, 1, "BGP"
ZEBRA_ROUTE_PIM, pim, pimd, 'P', 0, 0, 0, "PIM"
ZEBRA_ROUTE_EIGRP, eigrp, eigrpd, 'E', 1, 0, 1, "EIGRP"
ZEBRA_ROUTE_NHRP, nhrp, nhrpd, 'N', 1, 1, 1, "NHRP"
## type cname daemon C 4 6 Redist short help Enabled Restrictions
ZEBRA_ROUTE_SYSTEM, system, NULL, 'X', 0, 0, 0, "Reserved", none
ZEBRA_ROUTE_KERNEL, kernel, zebra, 'K', 1, 1, 1, "kernel route", zebra
ZEBRA_ROUTE_CONNECT, connected, zebra, 'C', 1, 1, 1, "connected", zebra
ZEBRA_ROUTE_STATIC, static, zebra, 'S', 1, 1, 1, "static", zebra
ZEBRA_ROUTE_RIP, rip, ripd, 'R', 1, 0, 1, "RIP", ripd
ZEBRA_ROUTE_RIPNG, ripng, ripngd, 'R', 0, 1, 1, "RIPng", ripngd
ZEBRA_ROUTE_OSPF, ospf, ospfd, 'O', 1, 0, 1, "OSPF", ospfd
ZEBRA_ROUTE_OSPF6, ospf6, ospf6d, 'O', 0, 1, 1, "OSPFv3", ospf6d
ZEBRA_ROUTE_ISIS, isis, isisd, 'I', 1, 1, 1, "IS-IS", isisd
ZEBRA_ROUTE_BGP, bgp, bgpd, 'B', 1, 1, 1, "BGP", bgpd
ZEBRA_ROUTE_PIM, pim, pimd, 'P', 0, 0, 0, "PIM", pimd
ZEBRA_ROUTE_EIGRP, eigrp, eigrpd, 'E', 1, 0, 1, "EIGRP", eigrpd
ZEBRA_ROUTE_NHRP, nhrp, nhrpd, 'N', 1, 1, 1, "NHRP", nhrpd
# HSLS and OLSR both are AFI independent (so: 1, 1), however
# we want to disable for them for general Quagga distribution.
# This at least makes it trivial for users of these protocols
# to 'switch on' redist support (direct numeric entry remaining
# possible).
ZEBRA_ROUTE_HSLS, hsls, hslsd, 'H', 0, 0, 0, "HSLS"
ZEBRA_ROUTE_OLSR, olsr, olsrd, 'o', 0, 0, 0, "OLSR"
ZEBRA_ROUTE_TABLE, table, zebra, 'T', 1, 1, 1, "Table"
ZEBRA_ROUTE_LDP, ldp, ldpd, 'L', 0, 0, 0, "LDP"
ZEBRA_ROUTE_HSLS, hsls, hslsd, 'H', 0, 0, 0, "HSLS", hslsd
ZEBRA_ROUTE_OLSR, olsr, olsrd, 'o', 0, 0, 0, "OLSR", olsrd
ZEBRA_ROUTE_TABLE, table, zebra, 'T', 1, 1, 1, "Table", zebra
ZEBRA_ROUTE_LDP, ldp, ldpd, 'L', 0, 0, 0, "LDP", ldpd
#vnc when sent to zebra
ZEBRA_ROUTE_VNC, vnc, NULL, 'v', 1, 1, 1, "VNC"
ZEBRA_ROUTE_VNC, vnc, NULL, 'v', 1, 1, 1, "VNC", bgpd-vnc
# vnc when sent to bgp
ZEBRA_ROUTE_VNC_DIRECT, vnc-direct,NULL, 'V', 1, 1, 1, "VNC-Direct", bgpd
ZEBRA_ROUTE_VNC_DIRECT, vnc-direct,NULL, 'V', 1, 1, 1, "VNC-Direct", bgpd-vnc, bgpd
# vnc when sent to bgp (resolve NVE mode)
ZEBRA_ROUTE_VNC_DIRECT_RH, vnc-rn, NULL, 'V', 0, 0, 0, "VNC-RN"
ZEBRA_ROUTE_VNC_DIRECT_RH, vnc-rn, NULL, 'V', 0, 0, 0, "VNC-RN", bgpd-vnc
# bgp unicast -> vnc
ZEBRA_ROUTE_BGP_DIRECT, bgp-direct, NULL, 'b', 0, 0, 0, "BGP-Direct"
ZEBRA_ROUTE_BGP_DIRECT, bgp-direct, NULL, 'b', 0, 0, 0, "BGP-Direct", bgpd-vnc
# bgp unicast -> vnc
ZEBRA_ROUTE_BGP_DIRECT_EXT, bgp-direct-to-nve-groups, NULL, 'e', 0, 0, 0, "BGP2VNC"
ZEBRA_ROUTE_BABEL, babel, babeld, 'A', 1, 1, 1, "Babel"
ZEBRA_ROUTE_SHARP, sharp, sharpd, 'D', 1, 1, 1, "SHARP"
ZEBRA_ROUTE_PBR, pbr, pbrd, 'F', 1, 1, 0, "PBR"
ZEBRA_ROUTE_BFD, bfd, bfdd, '-', 0, 0, 0, "BFD"
ZEBRA_ROUTE_OPENFABRIC, openfabric, fabricd, 'f', 1, 1, 1, "OpenFabric"
ZEBRA_ROUTE_VRRP, vrrp, vrrpd, '-', 0, 0, 0, "VRRP"
ZEBRA_ROUTE_NHG, zebra, none, '-', 0, 0, 0, "Nexthop Group"
ZEBRA_ROUTE_SRTE, srte, none, '-', 0, 0, 0, "SR-TE"
ZEBRA_ROUTE_ALL, wildcard, none, '-', 0, 0, 0, "-"
ZEBRA_ROUTE_BGP_DIRECT_EXT, bgp-direct-to-nve-groups, NULL, 'e', 0, 0, 0, "BGP2VNC", bgpd-vnc
ZEBRA_ROUTE_BABEL, babel, babeld, 'A', 1, 1, 1, "Babel", babeld
ZEBRA_ROUTE_SHARP, sharp, sharpd, 'D', 1, 1, 1, "SHARP", sharpd
ZEBRA_ROUTE_PBR, pbr, pbrd, 'F', 1, 1, 0, "PBR", pbrd
ZEBRA_ROUTE_BFD, bfd, bfdd, '-', 0, 0, 0, "BFD", bfdd
ZEBRA_ROUTE_OPENFABRIC, openfabric, fabricd, 'f', 1, 1, 1, "OpenFabric", fabricd
ZEBRA_ROUTE_VRRP, vrrp, vrrpd, '-', 0, 0, 0, "VRRP", vrrpd
ZEBRA_ROUTE_NHG, zebra, none, '-', 0, 0, 0, "Nexthop Group", none
ZEBRA_ROUTE_SRTE, srte, none, '-', 0, 0, 0, "SR-TE", none
ZEBRA_ROUTE_ALL, wildcard, none, '-', 0, 0, 0, "-", none
## help strings

View File

@ -465,8 +465,62 @@ lib/clippy-command_parse.$(OBJEXT): lib/command_lex.h
lib/lib_clippy-command_lex.$(OBJEXT): lib/command_parse.h
lib/lib_clippy-command_parse.$(OBJEXT): lib/command_lex.h
rt_enabled =
if BABELD
rt_enabled += --enabled babeld
endif
if BFDD
rt_enabled += --enabled bfdd
endif
if BGPD
rt_enabled += --enabled bgpd
if ENABLE_BGP_VNC
rt_enabled += --enabled bgpd-vnc
endif
endif
if EIGRPD
rt_enabled += --enabled eigrpd
endif
if ISISD
rt_enabled += --enabled isisd
endif
if FABRICD
rt_enabled += --enabled fabricd
endif
if LDPD
rt_enabled += --enabled ldpd
endif
if NHRPD
rt_enabled += --enabled nhrpd
endif
if OSPFD
rt_enabled += --enabled ospfd
endif
if OSPF6D
rt_enabled += --enabled ospf6d
endif
if PBRD
rt_enabled += --enabled pbrd
endif
if PIMD
rt_enabled += --enabled pimd
endif
if RIPD
rt_enabled += --enabled ripd
endif
if RIPNGD
rt_enabled += --enabled ripngd
endif
if SHARPD
rt_enabled += --enabled sharpd
endif
if ZEBRA
rt_enabled += --enabled zebra
endif
lib/route_types.h: $(top_srcdir)/lib/route_types.txt $(top_srcdir)/lib/route_types.pl
$(PERL) $(top_srcdir)/lib/route_types.pl < $(top_srcdir)/lib/route_types.txt > $@
$(PERL) $(top_srcdir)/lib/route_types.pl $(rt_enabled) < $(top_srcdir)/lib/route_types.txt > $@
DISTCLEANFILES += lib/route_types.h
if GIT_VERSION