diff --git a/internal/birdfmt/bgp.go b/internal/birdfmt/bgp.go index 3676973..c9d83c2 100644 --- a/internal/birdfmt/bgp.go +++ b/internal/birdfmt/bgp.go @@ -73,7 +73,8 @@ type BGPPeerFromTemplateOptions struct { OverrideLocalASN uint32 } -// RenderProtocolBGPFromTemplate renders protocol bgp … from TEMPLATE { neighbor; multihop; source address; passive; }. +// RenderProtocolBGPFromTemplate renders protocol bgp … from TEMPLATE { neighbor; multihop; source address; strict bind; passive; }. +// strict bind дублируется и в шаблоне, и в каждом пире — явная фиксация на сессию. func RenderProtocolBGPFromTemplate(opts BGPPeerFromTemplateOptions) (string, error) { if strings.TrimSpace(opts.ProtocolName) == "" { return "", fmt.Errorf("birdfmt: protocol name is required") @@ -109,6 +110,7 @@ func RenderProtocolBGPFromTemplate(opts BGPPeerFromTemplateOptions) (string, err b.WriteString(" source address ") b.WriteString(strings.TrimSpace(opts.SourceAddress)) b.WriteString(";\n") + b.WriteString(" strict bind on;\n") b.WriteString(" passive;\n") b.WriteString("}\n") return b.String(), nil diff --git a/internal/birdfmt/bgp_test.go b/internal/birdfmt/bgp_test.go index c8c8101..5bf76d0 100644 --- a/internal/birdfmt/bgp_test.go +++ b/internal/birdfmt/bgp_test.go @@ -55,6 +55,9 @@ func TestRenderProtocolBGPFromTemplate_MultihopPassive(t *testing.T) { if !strings.Contains(got, "source address 77.232.38.173;") { t.Fatal(got) } + if !strings.Contains(got, "strict bind on;") { + t.Fatal(got) + } } func TestRenderProtocolBGPFromTemplate_OverrideLocal(t *testing.T) { diff --git a/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_peers.conf b/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_peers.conf index 8acc7a7..8208944 100644 --- a/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_peers.conf +++ b/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_peers.conf @@ -2,5 +2,6 @@ protocol bgp evobgp_peer_ci from bgp_template { neighbor 192.0.2.2 as 65002; multihop; source address 192.0.2.1; + strict bind on; passive; }