From 133ea93e8346fd1ecf6c49bce4b78318e8992835 Mon Sep 17 00:00:00 2001 From: Denozordec Date: Mon, 6 Apr 2026 12:37:15 +0700 Subject: [PATCH] feat: update BGP template configuration and OpenAPI documentation. Change import settings from 'all' to 'none' in BGP templates, and add hold and keepalive time parameters. Enhance OpenAPI description for bird_bgp_source_ipv4 to provide additional context for MikroTik configuration. --- docs/openapi.yaml | 4 +++- internal/birdfmt/bgp.go | 8 ++++++-- .../standard_layout/bird.d/evobgp_bgp_template.conf | 8 ++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 3f3ec89..525f619 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -719,7 +719,9 @@ components: type: integer bird_bgp_source_ipv4: type: string - description: Исходящий IPv4 для `source address` у пиров; также задаёт `router id`, если указан. + description: | + Исходящий IPv4 для `source address` у пиров; также задаёт `router id`, если указан. + На стороне MikroTik в BGP Connection поле **Remote address** должно совпадать с этим адресом (или с тем, с которого реально устанавливается TCP-сессия к 179/tcp), иначе сессия не поднимется. bird_bgp_source_ipv6: type: string description: Исходящий IPv6 для `source address` у пиров IPv6. diff --git a/internal/birdfmt/bgp.go b/internal/birdfmt/bgp.go index a634a4d..42d3b08 100644 --- a/internal/birdfmt/bgp.go +++ b/internal/birdfmt/bgp.go @@ -36,20 +36,24 @@ func RenderBGPTemplates(opts BGPTemplatesOptions) (string, error) { fmt.Fprintf(&b, "template bgp %s {\n", BGPTemplateNameV4) fmt.Fprintf(&b, " local as %d;\n", opts.LocalASN) b.WriteString(" ipv4 {\n") - b.WriteString(" import all;\n") + b.WriteString(" import none;\n") b.WriteString(" export ") b.WriteString(exp4) b.WriteString(";\n") b.WriteString(" };\n") + b.WriteString(" hold time 90;\n") + b.WriteString(" keepalive time 30;\n") b.WriteString("}\n\n") fmt.Fprintf(&b, "template bgp %s {\n", BGPTemplateNameV6) fmt.Fprintf(&b, " local as %d;\n", opts.LocalASN) b.WriteString(" ipv6 {\n") - b.WriteString(" import all;\n") + b.WriteString(" import none;\n") b.WriteString(" export ") b.WriteString(exp6) b.WriteString(";\n") b.WriteString(" };\n") + b.WriteString(" hold time 90;\n") + b.WriteString(" keepalive time 30;\n") b.WriteString("}\n") return b.String(), nil } diff --git a/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_bgp_template.conf b/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_bgp_template.conf index 5930b6e..72f51e9 100644 --- a/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_bgp_template.conf +++ b/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_bgp_template.conf @@ -1,15 +1,19 @@ template bgp bgp_template { local as 65001; ipv4 { - import all; + import none; export filter evobgp_export_v4; }; + hold time 90; + keepalive time 30; } template bgp bgp_template_v6 { local as 65001; ipv6 { - import all; + import none; export filter evobgp_export_v6; }; + hold time 90; + keepalive time 30; }