Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Binary
pathvector

# Test Build
build-test.sh
pathvector-test

# Output files
output/*

Expand Down Expand Up @@ -29,4 +33,4 @@ test-cache/
test-conf.yml
nohup.out
coverage.txt
tests/bird-matrix/v*
tests/bird-matrix/v*
34 changes: 34 additions & 0 deletions docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -663,6 +671,14 @@ Configuration template
|------|---------|------------|
| string | | |

### `comments`

Extra comments in configuration file

| Type | Default | Validation |
|------|---------|------------|
| []string | | |

### `description`

Peer description
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand All @@ -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:"-"`
Expand All @@ -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"`
Expand Down Expand Up @@ -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"`
Expand Down
7 changes: 7 additions & 0 deletions pkg/embed/templates/global.tmpl
Original file line number Diff line number Diff line change
@@ -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 }};
Expand Down
24 changes: 24 additions & 0 deletions pkg/embed/templates/peer.tmpl
Original file line number Diff line number Diff line change
@@ -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 }};
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down
9 changes: 9 additions & 0 deletions pkg/embed/templates/vrrp.tmpl
Original file line number Diff line number Diff line change
@@ -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 }}
Expand Down