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/pkg/config/config.go b/pkg/config/config.go index ef435e5c..e6c30002 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" description:"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 for link-local BGP IPv6 sessions" 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..3061aec7 100644 --- a/pkg/embed/templates/peer.tmpl +++ b/pkg/embed/templates/peer.tmpl @@ -1,6 +1,28 @@ {{ $peer := .Peer }}{{ $peerName := .Name }}{{ $global := .Config }} +{{ if BoolDeref .ShowWarningMessage }} +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!! +# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDDEN ON NEXT GENERATION !!! +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +{{ end }} + + +{{ if not (Empty $peer.Comments) }} +##### +# BGP Session: {{ .Name }} AS{{ $peer.ASN }} +# Update time: {{ Timestamp "unix" }} +# +{{ 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 +59,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 +79,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 }}