Skip to content

Commit ec8632d

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 1d7aaf0 + 6c71ba2 commit ec8632d

File tree

4 files changed

+56
-45
lines changed

4 files changed

+56
-45
lines changed

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ module github.com/natesales/pathvector
33
go 1.18
44

55
require (
6-
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be
7-
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
86
github.com/creasty/defaults v1.5.2
97
github.com/go-ping/ping v0.0.0-20211014180314-6e2b003bffdd
108
github.com/go-playground/validator/v10 v10.9.0
@@ -13,7 +11,6 @@ require (
1311
github.com/spf13/cobra v1.2.1
1412
github.com/stretchr/testify v1.7.0
1513
golang.org/x/mod v0.4.2
16-
golang.org/x/text v0.3.6
1714
gopkg.in/yaml.v2 v2.4.0
1815
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
1916
)
@@ -32,4 +29,5 @@ require (
3229
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
3330
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
3431
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 // indirect
32+
golang.org/x/text v0.3.6 // indirect
3533
)

go.sum

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,15 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
3939
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
4040
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
4141
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
42-
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
43-
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
4442
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
4543
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
4644
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
4745
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
4846
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
4947
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
5048
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
51-
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
5249
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
53-
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
5450
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
55-
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
5651
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
5752
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
5853
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=

pkg/config/config.go

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,42 @@ type Peer struct {
1313
Disabled *bool `yaml:"disabled" description:"Should the sessions be disabled?" default:"false"`
1414

1515
// BGP Attributes
16-
ASN *int `yaml:"asn" description:"Local ASN" validate:"required" default:"0"`
17-
NeighborIPs *[]string `yaml:"neighbors" description:"List of neighbor IPs" validate:"required,ip" default:"-"`
18-
Prepends *int `yaml:"prepends" description:"Number of times to prepend local AS on export" default:"0"`
19-
PrependPath *[]uint32 `yaml:"prepend-path" description:"List of ASNs to prepend" default:"-"`
20-
ClearPath *bool `yaml:"clear-path" description:"Remove all ASNs from path (before prepends and prepend-path)" default:"false"`
21-
LocalPref *int `yaml:"local-pref" description:"BGP local preference" default:"100"`
22-
SetLocalPref *bool `yaml:"set-local-pref" description:"Should an explicit local pref be set?" default:"true"`
23-
Multihop *bool `yaml:"multihop" description:"Should BGP multihop be enabled? (255 max hops)" default:"false"`
24-
Listen4 *string `yaml:"listen4" description:"IPv4 BGP listen address" default:"-"`
25-
Listen6 *string `yaml:"listen6" description:"IPv6 BGP listen address" default:"-"`
26-
LocalASN *int `yaml:"local-asn" description:"Local ASN as defined in the global ASN field" default:"-"`
27-
LocalPort *int `yaml:"local-port" description:"Local TCP port" default:"179"`
28-
NeighborPort *int `yaml:"neighbor-port" description:"Neighbor TCP port" default:"179"`
29-
Passive *bool `yaml:"passive" description:"Should we listen passively?" default:"false"`
30-
Direct *bool `yaml:"direct" description:"Specify that the neighbor is directly connected" default:"false"`
31-
NextHopSelf *bool `yaml:"next-hop-self" description:"Should BGP next-hop-self be enabled?" default:"false"`
32-
BFD *bool `yaml:"bfd" description:"Should BFD be enabled?" default:"false"`
33-
Password *string `yaml:"password" description:"BGP MD5 password" default:"-"`
34-
RSClient *bool `yaml:"rs-client" description:"Should this peer be a route server client?" default:"false"`
35-
RRClient *bool `yaml:"rr-client" description:"Should this peer be a route reflector client?" default:"false"`
36-
RemovePrivateASNs *bool `yaml:"remove-private-asns" description:"Should private ASNs be removed from path before exporting?" default:"true"`
37-
MPUnicast46 *bool `yaml:"mp-unicast-46" description:"Should this peer be configured with multiprotocol IPv4 and IPv6 unicast?" default:"false"`
38-
AllowLocalAS *bool `yaml:"allow-local-as" description:"Should routes originated by the local ASN be accepted?" default:"false"`
39-
AddPathTx *bool `yaml:"add-path-tx" description:"Enable BGP additional paths on export?" default:"false"`
40-
AddPathRx *bool `yaml:"add-path-rx" description:"Enable BGP additional paths on import?" default:"false"`
41-
ImportNextHop *string `yaml:"import-next-hop" description:"Rewrite the BGP next hop before importing routes learned from this peer" default:"-"`
42-
ExportNextHop *string `yaml:"export-next-hop" description:"Rewrite the BGP next hop before announcing routes to this peer" default:"-"`
43-
Confederation *int `yaml:"confederation" description:"BGP confederation (RFC 5065)" default:"-"`
44-
ConfederationMember *bool `yaml:"confederation-member" description:"Should this peer be a member of the local confederation?" default:"false"`
45-
TTLSecurity *bool `yaml:"ttl-security" description:"RFC 5082 Generalized TTL Security Mechanism" default:"false"`
46-
InterpretCommunities *bool `yaml:"interpret-communities" description:"Should well-known BGP communities be interpreted by their intended action?" default:"true"`
47-
DefaultLocalPref *int `yaml:"default-local-pref" description:"Default value for local preference" default:"-"`
48-
AdvertiseHostname *bool `yaml:"advertise-hostname" description:"Advertise hostname capability" default:"false"`
49-
DisableAfterError *bool `yaml:"disable-after-error" description:"Disable peer after error" default:"false"`
50-
PreferOlderRoutes *bool `yaml:"prefer-older-routes" description:"Prefer older routes instead of comparing router IDs (RFC 5004)" default:"false"`
16+
ASN *int `yaml:"asn" description:"Local ASN" validate:"required" default:"0"`
17+
NeighborIPs *[]string `yaml:"neighbors" description:"List of neighbor IPs" validate:"required,ip" default:"-"`
18+
Prepends *int `yaml:"prepends" description:"Number of times to prepend local AS on export" default:"0"`
19+
PrependPath *[]uint32 `yaml:"prepend-path" description:"List of ASNs to prepend" default:"-"`
20+
ClearPath *bool `yaml:"clear-path" description:"Remove all ASNs from path (before prepends and prepend-path)" default:"false"`
21+
LocalPref *int `yaml:"local-pref" description:"BGP local preference" default:"100"`
22+
SetLocalPref *bool `yaml:"set-local-pref" description:"Should an explicit local pref be set?" default:"true"`
23+
Multihop *bool `yaml:"multihop" description:"Should BGP multihop be enabled? (255 max hops)" default:"false"`
24+
Listen4 *string `yaml:"listen4" description:"IPv4 BGP listen address" default:"-"`
25+
Listen6 *string `yaml:"listen6" description:"IPv6 BGP listen address" default:"-"`
26+
LocalASN *int `yaml:"local-asn" description:"Local ASN as defined in the global ASN field" default:"-"`
27+
LocalPort *int `yaml:"local-port" description:"Local TCP port" default:"179"`
28+
NeighborPort *int `yaml:"neighbor-port" description:"Neighbor TCP port" default:"179"`
29+
Passive *bool `yaml:"passive" description:"Should we listen passively?" default:"false"`
30+
Direct *bool `yaml:"direct" description:"Specify that the neighbor is directly connected" default:"false"`
31+
NextHopSelf *bool `yaml:"next-hop-self" description:"Should BGP next-hop-self be enabled?" default:"false"`
32+
BFD *bool `yaml:"bfd" description:"Should BFD be enabled?" default:"false"`
33+
Password *string `yaml:"password" description:"BGP MD5 password" default:"-"`
34+
RSClient *bool `yaml:"rs-client" description:"Should this peer be a route server client?" default:"false"`
35+
RRClient *bool `yaml:"rr-client" description:"Should this peer be a route reflector client?" default:"false"`
36+
RemovePrivateASNs *bool `yaml:"remove-private-asns" description:"Should private ASNs be removed from path before exporting?" default:"true"`
37+
MPUnicast46 *bool `yaml:"mp-unicast-46" description:"Should this peer be configured with multiprotocol IPv4 and IPv6 unicast?" default:"false"`
38+
AllowLocalAS *bool `yaml:"allow-local-as" description:"Should routes originated by the local ASN be accepted?" default:"false"`
39+
AddPathTx *bool `yaml:"add-path-tx" description:"Enable BGP additional paths on export?" default:"false"`
40+
AddPathRx *bool `yaml:"add-path-rx" description:"Enable BGP additional paths on import?" default:"false"`
41+
ImportNextHop *string `yaml:"import-next-hop" description:"Rewrite the BGP next hop before importing routes learned from this peer" default:"-"`
42+
ExportNextHop *string `yaml:"export-next-hop" description:"Rewrite the BGP next hop before announcing routes to this peer" default:"-"`
43+
Confederation *int `yaml:"confederation" description:"BGP confederation (RFC 5065)" default:"-"`
44+
ConfederationMember *bool `yaml:"confederation-member" description:"Should this peer be a member of the local confederation?" default:"false"`
45+
TTLSecurity *bool `yaml:"ttl-security" description:"RFC 5082 Generalized TTL Security Mechanism" default:"false"`
46+
InterpretCommunities *bool `yaml:"interpret-communities" description:"Should well-known BGP communities be interpreted by their intended action?" default:"true"`
47+
DefaultLocalPref *int `yaml:"default-local-pref" description:"Default value for local preference" default:"-"`
48+
AdvertiseHostname *bool `yaml:"advertise-hostname" description:"Advertise hostname capability" default:"false"`
49+
DisableAfterError *bool `yaml:"disable-after-error" description:"Disable peer after error" default:"false"`
50+
PreferOlderRoutes *bool `yaml:"prefer-older-routes" description:"Prefer older routes instead of comparing router IDs (RFC 5004)" default:"false"`
51+
IRRAcceptChildPrefixes *bool `yaml:"irr-accept-child-prefixes" description:"Accept prefixes up to /24 and /48 from covering parent IRR objects" default:"false"`
5152

5253
ImportCommunities *[]string `yaml:"add-on-import" description:"List of communities to add to all imported routes" default:"-"`
5354
ExportCommunities *[]string `yaml:"add-on-export" description:"List of communities to add to all exported routes" default:"-"`

pkg/irr/irr.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,28 @@ func Update(peerData *config.Peer, irrServer string, queryTimeout uint, bgpqArgs
8585
hasNeighbor4 = true
8686
} else if strings.Contains(n, ":") {
8787
hasNeighbor6 = true
88+
} else {
89+
log.Fatalf("Invalid neighbor IP %s", n)
8890
}
8991
}
9092
}
9193

92-
prefixesFromIRR4, err := PrefixSet(*peerData.ASSet, 4, irrServer, queryTimeout, bgpqArgs)
94+
// Handle acceptChildPrefixes
95+
bgpqArgs4 := bgpqArgs
96+
bgpqArgs6 := bgpqArgs
97+
if peerData.IRRAcceptChildPrefixes != nil && *peerData.IRRAcceptChildPrefixes {
98+
if bgpqArgs4 != "" {
99+
bgpqArgs4 += " "
100+
}
101+
bgpqArgs4 += "-R 24"
102+
103+
if bgpqArgs6 != "" {
104+
bgpqArgs6 += " "
105+
}
106+
bgpqArgs6 += "-R 48"
107+
}
108+
109+
prefixesFromIRR4, err := PrefixSet(*peerData.ASSet, 4, irrServer, queryTimeout, bgpqArgs4)
93110
if err != nil {
94111
return fmt.Errorf("unable to get IPv4 IRR prefix list from %s: %s", *peerData.ASSet, err)
95112
}
@@ -102,7 +119,7 @@ func Update(peerData *config.Peer, irrServer string, queryTimeout uint, bgpqArgs
102119
log.Warnf("peer has IPv4 session(s) but no IPv4 prefixes")
103120
}
104121

105-
prefixesFromIRR6, err := PrefixSet(*peerData.ASSet, 6, irrServer, queryTimeout, bgpqArgs)
122+
prefixesFromIRR6, err := PrefixSet(*peerData.ASSet, 6, irrServer, queryTimeout, bgpqArgs6)
106123
if err != nil {
107124
return fmt.Errorf("unable to get IPv6 IRR prefix list from %s: %s", *peerData.ASSet, err)
108125
}

0 commit comments

Comments
 (0)