From 825dc52aef7d0902fc49e5f0a7c9001895130fa9 Mon Sep 17 00:00:00 2001 From: Dennis de Houx Date: Sat, 13 Apr 2024 21:56:53 +0200 Subject: [PATCH 01/10] Reset this branche --- .gitignore | 6 +++++- docs/docs/configuration.md | 34 +++++++++++++++++++++++++++++++++ go.mod | 6 +++--- go.sum | 12 ++++++------ pkg/config/config.go | 5 +++++ pkg/embed/templates/global.tmpl | 7 +++++++ pkg/embed/templates/peer.tmpl | 23 ++++++++++++++++++++++ pkg/embed/templates/vrrp.tmpl | 9 +++++++++ 8 files changed, 92 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 4bb670da..842196a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ # Binary pathvector +# Test Build +build-test.sh +pathvector-test + # Output files output/* @@ -29,4 +33,4 @@ test-cache/ test-conf.yml nohup.out coverage.txt -tests/bird-matrix/v* \ No newline at end of file +tests/bird-matrix/v* diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index 60737933..f2bcd91a 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -165,6 +165,14 @@ List of communities to add to all exported routes |------|---------|------------| | []string | | | +### `show-warning-message` + +Show warning message on autogenrated config files + +| Type | Default | Validation | +|------|---------|------------| +| bool | true | | + ### `hostname` Router hostname (default system hostname) @@ -663,6 +671,14 @@ Configuration template |------|---------|------------| | string | | | +### `comments` + +Extra comments in configuration file + +| Type | Default | Validation | +|------|---------|------------| +| []string | | | + ### `description` Peer description @@ -775,6 +791,15 @@ Should an explicit local pref be set? |------|---------|------------| | bool | true | | +### `bgp-med` + +BGP default bgp_med +Value of the Multiple Exit Discriminator to be used during route selection when the MED attribute is missing. Default: 0. + +| Type | Default | Validation | +|------|---------|------------| +| int | 0 | | + ### `multihop` Should BGP multihop be enabled? (255 max hops) @@ -783,6 +808,15 @@ Should BGP multihop be enabled? (255 max hops) |------|---------|------------| | bool | false | | +### `interface` + +Interface of BGP listen address + +| Type | Default | Validation | +|------|---------|------------| +| string | | | + + ### `listen4` IPv4 BGP listen address diff --git a/go.mod b/go.mod index 267c514e..edb8655e 100644 --- a/go.mod +++ b/go.mod @@ -29,9 +29,9 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/crypto v0.14.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index b65cb857..04f9a9c0 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= @@ -74,12 +74,12 @@ golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/config/config.go b/pkg/config/config.go index ef435e5c..1d948999 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -94,6 +94,7 @@ type Peer struct { Template *string `yaml:"template" description:"Configuration template" default:"-"` Description *string `yaml:"description" description:"Peer description" default:"-"` + Comments *[]string `yaml:"comments" comment:"Comments in file" default:"-"` Tags *[]string `yaml:"tags" description:"Peer tags" default:"-"` Disabled *bool `yaml:"disabled" description:"Should the sessions be disabled?" default:"false"` @@ -111,6 +112,7 @@ type Peer struct { LocalPref6 *int `yaml:"local-pref6" description:"IPv6 BGP local preference (overrides local-pref, not included in optimizer)" default:"-"` SetLocalPref *bool `yaml:"set-local-pref" description:"Should an explicit local pref be set?" default:"true"` Multihop *bool `yaml:"multihop" description:"Should BGP multihop be enabled? (255 max hops)" default:"false"` + Interface *string `yaml:"interface" description:"Interface of BGP listen address" default:"-"` Listen4 *string `yaml:"listen4" description:"IPv4 BGP listen address" default:"-"` Listen6 *string `yaml:"listen6" description:"IPv6 BGP listen address" default:"-"` LocalASN *int `yaml:"local-asn" description:"Local ASN as defined in the global ASN field" default:"-"` @@ -137,6 +139,7 @@ type Peer struct { TTLSecurity *bool `yaml:"ttl-security" description:"RFC 5082 Generalized TTL Security Mechanism" default:"false"` InterpretCommunities *bool `yaml:"interpret-communities" description:"Should well-known BGP communities be interpreted by their intended action?" default:"true"` DefaultLocalPref *int `yaml:"default-local-pref" description:"Default value for local preference" default:"-"` + DefaultBgpMed *int `yaml:"bgp-med" description:"Value of the Multiple Exit Discriminator to be used during route selection when the MED attribute is missing." default:"0"` AdvertiseHostname *bool `yaml:"advertise-hostname" description:"Advertise hostname capability" default:"false"` DisableAfterError *bool `yaml:"disable-after-error" description:"Disable peer after error" default:"false"` PreferOlderRoutes *bool `yaml:"prefer-older-routes" description:"Prefer older routes instead of comparing router IDs (RFC 5004)" default:"false"` @@ -348,6 +351,8 @@ type Config struct { ImportCommunities []string `yaml:"add-on-import" description:"List of communities to add to all imported routes" default:"-"` ExportCommunities []string `yaml:"add-on-export" description:"List of communities to add to all exported routes" default:"-"` + ShowWarningMessage bool `yaml:"show-warning-messsage" description:"Show warning message on autogenerated files" default:"true"` + Hostname string `yaml:"hostname" description:"Router hostname (default system hostname)" default:""` ASN int `yaml:"asn" description:"Autonomous System Number" validate:"required" default:"0"` diff --git a/pkg/embed/templates/global.tmpl b/pkg/embed/templates/global.tmpl index 646045e8..0c1f70c1 100644 --- a/pkg/embed/templates/global.tmpl +++ b/pkg/embed/templates/global.tmpl @@ -1,3 +1,10 @@ +{{ if BoolDeref .ShowWarningMessage }} +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!! +# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDEN ON NEXT GENERATION !!! +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +{{ end }} + # Update time: {{ Timestamp "unix" }} define ASN = {{ .ASN }}; diff --git a/pkg/embed/templates/peer.tmpl b/pkg/embed/templates/peer.tmpl index 88a04c72..b263fc35 100644 --- a/pkg/embed/templates/peer.tmpl +++ b/pkg/embed/templates/peer.tmpl @@ -1,6 +1,27 @@ {{ $peer := .Peer }}{{ $peerName := .Name }}{{ $global := .Config }} +{{ if BoolDeref .ShowWarningMessage }} +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!! +# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDEN ON NEXT GENERATION !!! +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +{{ end }} + + +{{ if not (Empty $peer.Comments) }} +##### +# BGP Session: {{ .Name }} AS{{ $peer.ASN }} +# +{{ range $i, $comment := $peer.Comments }} +# {{ StrDeref $comment }} +{{ end }} +# +##### +{{ else }} # {{ .Name }} AS{{ $peer.ASN }} +# Update time: {{ Timestamp "unix" }} +{{ end }} + define AS{{ $peer.ASN }}_{{ $peer.ProtocolName }}_IMPORT_v4 = {{ $peer.ImportLimit4 }}; define AS{{ $peer.ASN }}_{{ $peer.ProtocolName }}_IMPORT_v6 = {{ $peer.ImportLimit6 }}; @@ -37,6 +58,7 @@ define AS{{ $peer.ASN }}_{{ $peer.ProtocolName }}_AS_SET_MEMBERS = [ {{ $neighborNoIface := SplitFirst $neighbor "%" }} protocol bgp {{ UniqueProtocolName $peer.ProtocolName $peerName $af $peer.ASN $peer.Tags }} { local{{ if eq $af "4" }}{{ if $peer.Listen4 }} {{ $peer.Listen4 }}{{ end }}{{ else }}{{ if $peer.Listen6 }} {{ $peer.Listen6 }}{{ end }}{{ end }} as {{ if IntDeref $peer.LocalASN }}{{ IntDeref $peer.LocalASN }}{{ else }}ASN{{ end }}{{ if $peer.LocalPort }} port {{ $peer.LocalPort }}{{ end }}; + {{ if StrDeref $peer.Interface }}interface "{{ StrDeref $peer.Interface }}";{{ end }} neighbor {{ $neighbor }} as {{ $peer.ASN }}{{ if $peer.NeighborPort }} port {{ $peer.NeighborPort }}{{ end }}; {{ if StrDeref $peer.Description }}description "{{ StrDeref $peer.Description }}";{{ end }} {{ if BoolDeref $peer.Disabled }}disabled;{{ end }} @@ -56,6 +78,7 @@ protocol bgp {{ UniqueProtocolName $peer.ProtocolName $peerName $af $peer.ASN $p {{ if not (BoolDeref $peer.InterpretCommunities) }}interpret communities off;{{ end }} {{ if IntDeref $peer.Confederation }}confederation {{ IntDeref $peer.Confederation }};{{ end }} {{ if IntDeref $peer.DefaultLocalPref }}default bgp_local_pref {{ IntDeref $peer.DefaultLocalPref }};{{ end }} + {{ if IntDeref $peer.DefaultBgpMed }}default bgp_med {{ IntDeref $peer.DefaultBgpMed }};{{ end }} {{ StrDeref $peer.SessionGlobal }} {{ $protocols := MakeSlice }} {{ if BoolDeref $peer.MPUnicast46 }} diff --git a/pkg/embed/templates/vrrp.tmpl b/pkg/embed/templates/vrrp.tmpl index 94dc5d29..082bd1a3 100644 --- a/pkg/embed/templates/vrrp.tmpl +++ b/pkg/embed/templates/vrrp.tmpl @@ -1,3 +1,12 @@ +{{ if BoolDeref .ShowWarningMessage }} +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!! +# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDEN ON NEXT GENERATION !!! +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +{{ end }} + +# Update time: {{ Timestamp "unix" }} + {{- range $instanceId, $instance := . -}} vrrp_instance VRRP{{ $instanceId }} { state {{ .State }} From dbebf3e49912e1e40e28a5bc7a3573f8fa7c1643 Mon Sep 17 00:00:00 2001 From: Dennis de Houx Date: Thu, 18 Apr 2024 06:15:18 +0200 Subject: [PATCH 02/10] Feature to restart, reload, enable or disable protocols --- cmd/protocol.go | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 cmd/protocol.go diff --git a/cmd/protocol.go b/cmd/protocol.go new file mode 100755 index 00000000..419fadc7 --- /dev/null +++ b/cmd/protocol.go @@ -0,0 +1,95 @@ +package cmd + +import ( + "fmt" + "strings" + + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "github.com/natesales/pathvector/pkg/bird" +) + +var ( + allowCommands []string + commentMessage string +) + +func init() { + protocolCmd.Flags().StringVarP(&commentMessage, "message", "m", "", "enable/disable custom message") + rootCmd.AddCommand(protocolCmd) +} + +var protocolCmd = &cobra.Command{ + Use: "protocol <(r)estart|re(l)oad|(e)nable|(d)isable> ", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + log.Fatal("requires a command ") + } else if allowCommand(args[0]) == false { + log.Fatal("This command is not allowed: ", args[0]) + } else if len(args) < 2 { + log.Fatal("requires protocol name") + } + return nil + }, + Aliases: []string{"p", "protocols"}, + Short: "Protocol command (restart, reload, enable or disable protocol sessions)", + Long: "With this command you can restart, reload, enable or disable a protocol, if you want you can use \"all\" as the protocol name to for example restart all protocol sessions.", + Run: func(cmd *cobra.Command, args []string) { + c, err := loadConfig() + if err != nil { + log.Warnf("Error loading config, falling back to no-config output parsing: %s", err) + } + + log.Infof("Starting bird protocol command") + + commandOutput, _, err := bird.RunCommand(runCMD(args, commentMessage), c.BIRDSocket) + if err != nil { + log.Fatal(err) + } else if strings.Contains(commandOutput, "syntax error") || strings.Contains(commandOutput, "unexpected CF_SYM_UNDEFINED") || strings.Contains(commandOutput, "expecting END or CF_SYM_KNOWN or TEXT") { + log.Fatal("The protocol name was not found!") + } + log.Debugf("Command Output: %s", commandOutput) + + fmt.Printf("Command %s succeeded for protocol: %s\n", args[0], args[1]) + }, +} + +// allowCommand check if this command is allowed to run +func allowCommand(cmd string) bool { + allowCommands := []string{"restart", "reload", "enable", "disable", "r", "l", "e", "d"} + for _, allowed := range allowCommands { + if allowed == cmd { + return true + } + } + return false +} + +// runCMD generate the run command +func runCMD(args []string, message string) string { + switch args[0] { + case "d": + args[0] = "disable" + break + case "e": + args[0] = "enable" + break + case "r": + args[0] = "restart" + break + case "l": + args[0] = "reload" + break + } + + if args[0] == "disable" && message != "" { + return args[0] + " " + args[1] + " \"" + message + "\"" + } else if args[0] == "enable" && message != "" { + return args[0] + " " + args[1] + " \"" + message + "\"" + } else if args[0] == "disable" { + return args[0] + " " + args[1] + " \"Protocol manually " + args[0] + "d by pathvector\"" + } + + return args[0] + " " + args[1] +} \ No newline at end of file From 9d8f5b411e416c3b5932b64d8942b18faed12359 Mon Sep 17 00:00:00 2001 From: Dennis de Houx <152706174+Dennis-de-Houx@users.noreply.github.com> Date: Fri, 19 Apr 2024 03:06:07 +0200 Subject: [PATCH 03/10] Create protocol_test.go --- cmd/protocol_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cmd/protocol_test.go diff --git a/cmd/protocol_test.go b/cmd/protocol_test.go new file mode 100644 index 00000000..6c6b0aa4 --- /dev/null +++ b/cmd/protocol_test.go @@ -0,0 +1,14 @@ +package cmd + +import "testing" + +func TestProtocol(t *testing.T) { + rootCmd.SetArgs([]string{ + "protocol", + "reload", + "device1", + }) + if err := rootCmd.Execute(); err != nil { + t.Error(err) + } +} From 04003c5c08e8970e3a60bbe74c3509d9a62337a7 Mon Sep 17 00:00:00 2001 From: Dennis de Houx <152706174+Dennis-de-Houx@users.noreply.github.com> Date: Fri, 19 Apr 2024 03:08:25 +0200 Subject: [PATCH 04/10] Update .gitignore --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index 842196a7..ca9c7ac8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,6 @@ # Binary pathvector -# Test Build -build-test.sh -pathvector-test - # Output files output/* @@ -33,4 +29,3 @@ test-cache/ test-conf.yml nohup.out coverage.txt -tests/bird-matrix/v* From ae94d985fb4de8e4b68216817e68e68dfcb390b6 Mon Sep 17 00:00:00 2001 From: Dennis de Houx <152706174+Dennis-de-Houx@users.noreply.github.com> Date: Fri, 19 Apr 2024 03:09:36 +0200 Subject: [PATCH 05/10] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ca9c7ac8..80eac27a 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ test-cache/ test-conf.yml nohup.out coverage.txt +tests/bird-matrix/v* From c3f6b1fd49ef3fb369b3a0c0ac9b52e7aca2d8ed Mon Sep 17 00:00:00 2001 From: Dennis de Houx <152706174+Dennis-de-Houx@users.noreply.github.com> Date: Fri, 19 Apr 2024 03:13:31 +0200 Subject: [PATCH 06/10] Update configuration.md --- docs/docs/configuration.md | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index f2bcd91a..60737933 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -165,14 +165,6 @@ List of communities to add to all exported routes |------|---------|------------| | []string | | | -### `show-warning-message` - -Show warning message on autogenrated config files - -| Type | Default | Validation | -|------|---------|------------| -| bool | true | | - ### `hostname` Router hostname (default system hostname) @@ -671,14 +663,6 @@ Configuration template |------|---------|------------| | string | | | -### `comments` - -Extra comments in configuration file - -| Type | Default | Validation | -|------|---------|------------| -| []string | | | - ### `description` Peer description @@ -791,15 +775,6 @@ Should an explicit local pref be set? |------|---------|------------| | bool | true | | -### `bgp-med` - -BGP default bgp_med -Value of the Multiple Exit Discriminator to be used during route selection when the MED attribute is missing. Default: 0. - -| Type | Default | Validation | -|------|---------|------------| -| int | 0 | | - ### `multihop` Should BGP multihop be enabled? (255 max hops) @@ -808,15 +783,6 @@ Should BGP multihop be enabled? (255 max hops) |------|---------|------------| | bool | false | | -### `interface` - -Interface of BGP listen address - -| Type | Default | Validation | -|------|---------|------------| -| string | | | - - ### `listen4` IPv4 BGP listen address From fbadb2352ed8a3e6ceadaa525fa0d4a8f9a2eb1c Mon Sep 17 00:00:00 2001 From: Dennis de Houx <152706174+Dennis-de-Houx@users.noreply.github.com> Date: Fri, 19 Apr 2024 03:15:27 +0200 Subject: [PATCH 07/10] Update config.go --- pkg/config/config.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 1d948999..ef435e5c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -94,7 +94,6 @@ type Peer struct { Template *string `yaml:"template" description:"Configuration template" default:"-"` Description *string `yaml:"description" description:"Peer description" default:"-"` - Comments *[]string `yaml:"comments" comment:"Comments in file" default:"-"` Tags *[]string `yaml:"tags" description:"Peer tags" default:"-"` Disabled *bool `yaml:"disabled" description:"Should the sessions be disabled?" default:"false"` @@ -112,7 +111,6 @@ type Peer struct { LocalPref6 *int `yaml:"local-pref6" description:"IPv6 BGP local preference (overrides local-pref, not included in optimizer)" default:"-"` SetLocalPref *bool `yaml:"set-local-pref" description:"Should an explicit local pref be set?" default:"true"` Multihop *bool `yaml:"multihop" description:"Should BGP multihop be enabled? (255 max hops)" default:"false"` - Interface *string `yaml:"interface" description:"Interface of BGP listen address" default:"-"` Listen4 *string `yaml:"listen4" description:"IPv4 BGP listen address" default:"-"` Listen6 *string `yaml:"listen6" description:"IPv6 BGP listen address" default:"-"` LocalASN *int `yaml:"local-asn" description:"Local ASN as defined in the global ASN field" default:"-"` @@ -139,7 +137,6 @@ type Peer struct { TTLSecurity *bool `yaml:"ttl-security" description:"RFC 5082 Generalized TTL Security Mechanism" default:"false"` InterpretCommunities *bool `yaml:"interpret-communities" description:"Should well-known BGP communities be interpreted by their intended action?" default:"true"` DefaultLocalPref *int `yaml:"default-local-pref" description:"Default value for local preference" default:"-"` - DefaultBgpMed *int `yaml:"bgp-med" description:"Value of the Multiple Exit Discriminator to be used during route selection when the MED attribute is missing." default:"0"` AdvertiseHostname *bool `yaml:"advertise-hostname" description:"Advertise hostname capability" default:"false"` DisableAfterError *bool `yaml:"disable-after-error" description:"Disable peer after error" default:"false"` PreferOlderRoutes *bool `yaml:"prefer-older-routes" description:"Prefer older routes instead of comparing router IDs (RFC 5004)" default:"false"` @@ -351,8 +348,6 @@ type Config struct { ImportCommunities []string `yaml:"add-on-import" description:"List of communities to add to all imported routes" default:"-"` ExportCommunities []string `yaml:"add-on-export" description:"List of communities to add to all exported routes" default:"-"` - ShowWarningMessage bool `yaml:"show-warning-messsage" description:"Show warning message on autogenerated files" default:"true"` - Hostname string `yaml:"hostname" description:"Router hostname (default system hostname)" default:""` ASN int `yaml:"asn" description:"Autonomous System Number" validate:"required" default:"0"` From 9f93466fe33ec37fb20282d3913cb547d7b3e4c0 Mon Sep 17 00:00:00 2001 From: Dennis de Houx <152706174+Dennis-de-Houx@users.noreply.github.com> Date: Fri, 19 Apr 2024 03:16:11 +0200 Subject: [PATCH 08/10] Update global.tmpl --- pkg/embed/templates/global.tmpl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/embed/templates/global.tmpl b/pkg/embed/templates/global.tmpl index 0c1f70c1..646045e8 100644 --- a/pkg/embed/templates/global.tmpl +++ b/pkg/embed/templates/global.tmpl @@ -1,10 +1,3 @@ -{{ if BoolDeref .ShowWarningMessage }} -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!! -# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDEN ON NEXT GENERATION !!! -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -{{ end }} - # Update time: {{ Timestamp "unix" }} define ASN = {{ .ASN }}; From c92ad67d16cc901c3c5e02b20d4277285f8e2c6f Mon Sep 17 00:00:00 2001 From: Dennis de Houx <152706174+Dennis-de-Houx@users.noreply.github.com> Date: Fri, 19 Apr 2024 03:17:54 +0200 Subject: [PATCH 09/10] Update peer.tmpl --- pkg/embed/templates/peer.tmpl | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/pkg/embed/templates/peer.tmpl b/pkg/embed/templates/peer.tmpl index 57420581..f8e7b011 100644 --- a/pkg/embed/templates/peer.tmpl +++ b/pkg/embed/templates/peer.tmpl @@ -1,27 +1,6 @@ {{ $peer := .Peer }}{{ $peerName := .Name }}{{ $global := .Config }} -{{ if BoolDeref .ShowWarningMessage }} -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!! -# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDEN ON NEXT GENERATION !!! -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -{{ end }} - - -{{ if not (Empty $peer.Comments) }} -##### -# BGP Session: {{ .Name }} AS{{ $peer.ASN }} -# -{{ range $i, $comment := $peer.Comments }} -# {{ StrDeref $comment }} -{{ end }} -# -##### -{{ else }} # {{ .Name }} AS{{ $peer.ASN }} -# Update time: {{ Timestamp "unix" }} -{{ end }} - define AS{{ $peer.ASN }}_{{ $peer.ProtocolName }}_IMPORT_v4 = {{ $peer.ImportLimit4 }}; define AS{{ $peer.ASN }}_{{ $peer.ProtocolName }}_IMPORT_v6 = {{ $peer.ImportLimit6 }}; @@ -58,7 +37,6 @@ define AS{{ $peer.ASN }}_{{ $peer.ProtocolName }}_AS_SET_MEMBERS = [ {{ $neighborNoIface := SplitFirst $neighbor "%" }} protocol bgp {{ UniqueProtocolName $peer.ProtocolName $peerName $af $peer.ASN $peer.Tags }} { local{{ if eq $af "4" }}{{ if $peer.Listen4 }} {{ $peer.Listen4 }}{{ end }}{{ else }}{{ if $peer.Listen6 }} {{ $peer.Listen6 }}{{ end }}{{ end }} as {{ if IntDeref $peer.LocalASN }}{{ IntDeref $peer.LocalASN }}{{ else }}ASN{{ end }}{{ if $peer.LocalPort }} port {{ $peer.LocalPort }}{{ end }}; - {{ if StrDeref $peer.Interface }}interface "{{ StrDeref $peer.Interface }}";{{ end }} neighbor {{ $neighbor }} as {{ $peer.ASN }}{{ if $peer.NeighborPort }} port {{ $peer.NeighborPort }}{{ end }}; {{ if StrDeref $peer.Description }}description "{{ StrDeref $peer.Description }}";{{ end }} {{ if BoolDeref $peer.Disabled }}disabled;{{ end }} @@ -78,7 +56,6 @@ protocol bgp {{ UniqueProtocolName $peer.ProtocolName $peerName $af $peer.ASN $p {{ if not (BoolDeref $peer.InterpretCommunities) }}interpret communities off;{{ end }} {{ if IntDeref $peer.Confederation }}confederation {{ IntDeref $peer.Confederation }};{{ end }} {{ if IntDeref $peer.DefaultLocalPref }}default bgp_local_pref {{ IntDeref $peer.DefaultLocalPref }};{{ end }} - {{ if IntDeref $peer.DefaultBgpMed }}default bgp_med {{ IntDeref $peer.DefaultBgpMed }};{{ end }} {{ StrDeref $peer.SessionGlobal }} {{ $protocols := MakeSlice }} {{ if BoolDeref $peer.MPUnicast46 }} From 046cb20840253d84eff5732fd69f13c8b8b8eb1d Mon Sep 17 00:00:00 2001 From: Dennis de Houx <152706174+Dennis-de-Houx@users.noreply.github.com> Date: Fri, 19 Apr 2024 03:18:22 +0200 Subject: [PATCH 10/10] Update vrrp.tmpl --- pkg/embed/templates/vrrp.tmpl | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkg/embed/templates/vrrp.tmpl b/pkg/embed/templates/vrrp.tmpl index 082bd1a3..94dc5d29 100644 --- a/pkg/embed/templates/vrrp.tmpl +++ b/pkg/embed/templates/vrrp.tmpl @@ -1,12 +1,3 @@ -{{ if BoolDeref .ShowWarningMessage }} -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!! -# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDEN ON NEXT GENERATION !!! -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -{{ end }} - -# Update time: {{ Timestamp "unix" }} - {{- range $instanceId, $instance := . -}} vrrp_instance VRRP{{ $instanceId }} { state {{ .State }}