[PATCH v2] conf: only offer bfd in bgp if bfd protocol is enabled
Yuri Honegger
yuri.honegger at icloud.com
Fri May 24 14:54:03 CEST 2024
When trying to build bird with bfd support disabled (e.g. ./configure --with-protocols=bgp,static), it fails since the bgp configuration code expects bfd to be around.
This patch makes the bfd option in the bgp protocol unavailable using some preprocessor logic if we are building without bfd.
I'm currently trying to port bird to mac os x and the bfd module continues to cause trouble. Disabling it would therefore be useful.
Sorry, with the first patch I accidentally managed to include the patch file itself. Here is a clean one.
---
conf/Makefile | 4 +++-
nest/config.Y | 2 ++
proto/bgp/config.Y | 3 ++-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/conf/Makefile b/conf/Makefile
index 19db9c2c..0fa6749a 100644
--- a/conf/Makefile
+++ b/conf/Makefile
@@ -14,8 +14,10 @@ $(o)cf-parse.y: $(s)gen_parser.m4
$(o)keywords.h: $(s)gen_keywords.m4
$(o)commands.h: $(s)gen_commands.m4
+enabled_protocols_m4_defines = $(foreach protocol,$(protocols),-D PROTOCOL_$(protocol)_ENABLED)
+
$(conf-y-targets): $(s)confbase.Y $(s)flowspec.Y
- $(M4) $(M4FLAGS) -P $(if $(word 2,$(filter %.m4,$^)),$(error "Too many M4 scripts for one target"),$(filter %.m4,$^)) $(filter %.Y,$^) >$@
+ $(M4) $(M4FLAGS) -P $(enabled_protocols_m4_defines) $(if $(word 2,$(filter %.m4,$^)),$(error "Too many M4 scripts for one target"),$(filter %.m4,$^)) $(filter %.Y,$^) >$@
$(o)cf-parse.tab.h: $(o)cf-parse.tab.c
diff --git a/nest/config.Y b/nest/config.Y
index 62b28072..a560a12f 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -603,6 +603,7 @@ password_item_end:
/* BFD options */
+m4_ifdef([[PROTOCOL_bfd_ENABLED]],[[
bfd_item:
INTERVAL expr_us { this_bfd_opts->min_rx_int = this_bfd_opts->min_tx_int = $2; }
@@ -647,6 +648,7 @@ bfd_opts_end:
bfd_opts:
bfd_opts_start '{' bfd_items '}' bfd_opts_end
;
+]])
/* Core commands */
diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y
index 4ce06488..f15cbad3 100644
--- a/proto/bgp/config.Y
+++ b/proto/bgp/config.Y
@@ -220,11 +220,12 @@ bgp_proto:
| bgp_proto CHECK LINK bool ';' { BGP_CFG->check_link = $4; }
| bgp_proto BFD bool ';' { if ($3) init_bfd_opts(&BGP_CFG->bfd); else BGP_CFG->bfd = NULL; }
| bgp_proto BFD GRACEFUL ';' { init_bfd_opts(&BGP_CFG->bfd); BGP_CFG->bfd->mode = BGP_BFD_GRACEFUL; }
- | bgp_proto BFD { open_bfd_opts(&BGP_CFG->bfd); } bfd_opts { close_bfd_opts(); } ';'
| bgp_proto ENFORCE FIRST AS bool ';' { BGP_CFG->enforce_first_as = $5; }
| bgp_proto LOCAL ROLE bgp_role_name ';' { BGP_CFG->local_role = $4; }
| bgp_proto REQUIRE ROLES bool ';' { BGP_CFG->require_roles = $4; }
| bgp_proto DISABLE RX bool ';' { BGP_CFG->disable_rx = $4; }
+ /* Since BFD is optional, only add the BFD option when building with BFD enabled */
+ m4_ifdef([[PROTOCOL_bfd_ENABLED]],[[ | bgp_proto BFD { open_bfd_opts(&BGP_CFG->bfd); } bfd_opts { close_bfd_opts(); } ';']])
;
bgp_afi:
--
2.39.3 (Apple Git-146)
More information about the Bird-users
mailing list