Skip to content

Commit 9ccaa4e

Browse files
committed
Merge PR natesales#227 (main)
2 parents b11cd26 + c3b4a1c commit 9ccaa4e

6 files changed

Lines changed: 83 additions & 0 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Binary
22
pathvector
33

4+
# Test Build
5+
build-test.sh
6+
pathvector-test
7+
48
# Output files
59
output/*
610

docs/docs/configuration.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ List of communities to add to all exported routes
165165
|------|---------|------------|
166166
| []string | | |
167167

168+
### `show-warning-message`
169+
170+
Show warning message on autogenrated config files
171+
172+
| Type | Default | Validation |
173+
|------|---------|------------|
174+
| bool | true | |
175+
168176
### `hostname`
169177

170178
Router hostname (default system hostname)
@@ -663,6 +671,14 @@ Configuration template
663671
|------|---------|------------|
664672
| string | | |
665673

674+
### `comments`
675+
676+
Extra comments in configuration file
677+
678+
| Type | Default | Validation |
679+
|------|---------|------------|
680+
| []string | | |
681+
666682
### `description`
667683

668684
Peer description
@@ -775,6 +791,15 @@ Should an explicit local pref be set?
775791
|------|---------|------------|
776792
| bool | true | |
777793

794+
### `bgp-med`
795+
796+
BGP default bgp_med
797+
Value of the Multiple Exit Discriminator to be used during route selection when the MED attribute is missing. Default: 0.
798+
799+
| Type | Default | Validation |
800+
|------|---------|------------|
801+
| int | 0 | |
802+
778803
### `multihop`
779804

780805
Should BGP multihop be enabled? (255 max hops)
@@ -783,6 +808,15 @@ Should BGP multihop be enabled? (255 max hops)
783808
|------|---------|------------|
784809
| bool | false | |
785810

811+
### `interface`
812+
813+
Interface of BGP listen address
814+
815+
| Type | Default | Validation |
816+
|------|---------|------------|
817+
| string | | |
818+
819+
786820
### `listen4`
787821

788822
IPv4 BGP listen address

pkg/config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ type Peer struct {
9494
Template *string `yaml:"template" description:"Configuration template" default:"-"`
9595

9696
Description *string `yaml:"description" description:"Peer description" default:"-"`
97+
Comments *[]string `yaml:"comments" description:"Comments in file" default:"-"`
9798
Tags *[]string `yaml:"tags" description:"Peer tags" default:"-"`
9899
Disabled *bool `yaml:"disabled" description:"Should the sessions be disabled?" default:"false"`
99100

@@ -111,6 +112,7 @@ type Peer struct {
111112
LocalPref6 *int `yaml:"local-pref6" description:"IPv6 BGP local preference (overrides local-pref, not included in optimizer)" default:"-"`
112113
SetLocalPref *bool `yaml:"set-local-pref" description:"Should an explicit local pref be set?" default:"true"`
113114
Multihop *bool `yaml:"multihop" description:"Should BGP multihop be enabled? (255 max hops)" default:"false"`
115+
Interface *string `yaml:"interface" description:"Interface for link-local BGP IPv6 sessions" default:"-"`
114116
Listen4 *string `yaml:"listen4" description:"IPv4 BGP listen address" default:"-"`
115117
Listen6 *string `yaml:"listen6" description:"IPv6 BGP listen address" default:"-"`
116118
LocalASN *int `yaml:"local-asn" description:"Local ASN as defined in the global ASN field" default:"-"`
@@ -137,6 +139,7 @@ type Peer struct {
137139
TTLSecurity *bool `yaml:"ttl-security" description:"RFC 5082 Generalized TTL Security Mechanism" default:"false"`
138140
InterpretCommunities *bool `yaml:"interpret-communities" description:"Should well-known BGP communities be interpreted by their intended action?" default:"true"`
139141
DefaultLocalPref *int `yaml:"default-local-pref" description:"Default value for local preference" default:"-"`
142+
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"`
140143
AdvertiseHostname *bool `yaml:"advertise-hostname" description:"Advertise hostname capability" default:"false"`
141144
DisableAfterError *bool `yaml:"disable-after-error" description:"Disable peer after error" default:"false"`
142145
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 {
348351
ImportCommunities []string `yaml:"add-on-import" description:"List of communities to add to all imported routes" default:"-"`
349352
ExportCommunities []string `yaml:"add-on-export" description:"List of communities to add to all exported routes" default:"-"`
350353

354+
ShowWarningMessage bool `yaml:"show-warning-messsage" description:"Show warning message on autogenerated files" default:"true"`
355+
351356
Hostname string `yaml:"hostname" description:"Router hostname (default system hostname)" default:""`
352357

353358
ASN int `yaml:"asn" description:"Autonomous System Number" validate:"required" default:"0"`

pkg/embed/templates/global.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
{{ if BoolDeref .ShowWarningMessage }}
2+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3+
# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!!
4+
# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDEN ON NEXT GENERATION !!!
5+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
{{ end }}
7+
18
# Update time: {{ Timestamp "unix" }}
29

310
define ASN = {{ .ASN }};

pkg/embed/templates/peer.tmpl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
{{ $peer := .Peer }}{{ $peerName := .Name }}{{ $global := .Config }}
22

3+
{{ if BoolDeref .ShowWarningMessage }}
4+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5+
# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!!
6+
# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDDEN ON NEXT GENERATION !!!
7+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8+
{{ end }}
9+
10+
11+
{{ if not (Empty $peer.Comments) }}
12+
#####
13+
# BGP Session: {{ .Name }} AS{{ $peer.ASN }}
14+
# Update time: {{ Timestamp "unix" }}
15+
#
16+
{{ range $i, $comment := $peer.Comments }}
17+
# {{ StrDeref $comment }}
18+
{{ end }}
19+
#
20+
#####
21+
{{ else }}
322
# {{ .Name }} AS{{ $peer.ASN }}
23+
# Update time: {{ Timestamp "unix" }}
24+
{{ end }}
25+
426

527
define AS{{ $peer.ASN }}_{{ $peer.ProtocolName }}_IMPORT_v4 = {{ $peer.ImportLimit4 }};
628
define AS{{ $peer.ASN }}_{{ $peer.ProtocolName }}_IMPORT_v6 = {{ $peer.ImportLimit6 }};
@@ -37,6 +59,7 @@ define AS{{ $peer.ASN }}_{{ $peer.ProtocolName }}_AS_SET_MEMBERS = [
3759
{{ $neighborNoIface := SplitFirst $neighbor "%" }}
3860
protocol bgp {{ UniqueProtocolName $peer.ProtocolName $peerName $af $peer.ASN $peer.Tags }} {
3961
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 }};
62+
{{ if StrDeref $peer.Interface }}interface "{{ StrDeref $peer.Interface }}";{{ end }}
4063
neighbor {{ $neighbor }} as {{ $peer.ASN }}{{ if $peer.NeighborPort }} port {{ $peer.NeighborPort }}{{ end }};
4164
{{ if StrDeref $peer.Description }}description "{{ StrDeref $peer.Description }}";{{ end }}
4265
{{ if BoolDeref $peer.Disabled }}disabled;{{ end }}
@@ -57,6 +80,7 @@ protocol bgp {{ UniqueProtocolName $peer.ProtocolName $peerName $af $peer.ASN $p
5780
{{ if IntDeref $peer.Confederation }}confederation {{ IntDeref $peer.Confederation }};{{ end }}
5881
{{ if IntDeref $peer.DefaultLocalPref }}default bgp_local_pref {{ IntDeref $peer.DefaultLocalPref }};{{ end }}
5982
{{ if BoolDeref $peer.AdvertiseHostname }}advertise hostname on;{{ end }}
83+
{{ if IntDeref $peer.DefaultBgpMed }}default bgp_med {{ IntDeref $peer.DefaultBgpMed }};{{ end }}
6084
{{ StrDeref $peer.SessionGlobal }}
6185
{{ $protocols := MakeSlice }}
6286
{{ if BoolDeref $peer.MPUnicast46 }}

pkg/embed/templates/vrrp.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
{{ if BoolDeref .ShowWarningMessage }}
2+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3+
# !!! THIS FILE IS AUTOGENERATED BY PATHVECTOR !!!
4+
# !!! DO NOT EDIT THIS FILE, CHANGES WILL BE OVERRIDEN ON NEXT GENERATION !!!
5+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
{{ end }}
7+
8+
# Update time: {{ Timestamp "unix" }}
9+
110
{{- range $instanceId, $instance := . -}}
211
vrrp_instance VRRP{{ $instanceId }} {
312
state {{ .State }}

0 commit comments

Comments
 (0)