Skip to content

Commit

Permalink
bgp
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrizhu committed Sep 17, 2024
1 parent 9941d72 commit ac5d494
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 55 deletions.
29 changes: 20 additions & 9 deletions bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,11 @@ func prefixesInit() (prefixes []*Prefix) {
PrefixLen: uint32(prefixLen),
})

a1, _ := apb.New(&api.OriginAttribute{
Origin: 0,
})
a2, _ := apb.New(&api.NextHopAttribute{
NextHop: "0.0.0.0",
})
attrs := []*apb.Any{a1, a2}

newPrefix := Prefix{
prefix: prefix,
pathObj: &api.Path{
Family: &api.Family{Afi: api.Family_AFI_IP, Safi: api.Family_SAFI_UNICAST},
Nlri: nlri,
Pattrs: attrs,
},
lastAdvSite: nil,
}
Expand Down Expand Up @@ -146,6 +137,26 @@ func (p *Prefix) bgpAnnounce(site *ConfigSite) {
return
}

a1, _ := apb.New(&api.OriginAttribute{
Origin: 0,
})
a2, _ := apb.New(&api.NextHopAttribute{
NextHop: "0.0.0.0",
})

adminSet := Config.ASN
if Config.ASN > 65535 {
adminSet = 65535
}

comm := (adminSet << uint32(16)) | uint32(site.Id)

c, _ := apb.New(&api.CommunitiesAttribute{
Communities: []uint32{comm},
})

p.pathObj.Pattrs = []*apb.Any{a1, a2, c}

if _, err := s.AddPath(ctx, &api.AddPathRequest{
Path: p.pathObj,
VrfId: site.Name,
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ConfigPrefix struct {
ASN int `koanf:"asn"`
}
type ConfigSite struct {
Id int `koanf:"id"`
Name string `koanf:"name"`
Neighbor string `koanf:"neighbor"`
ASN int `konaf:"asn"`
Expand Down
96 changes: 50 additions & 46 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,57 @@ listen_port = 1709
listen_addr = [ "0.0.0.0" ]

prefixes = [
{ prefix = "184.164.250.0/24", asn = 47065 },
{ prefix = "184.164.251.0/24", asn = 47065 },
{ id = 1, prefix = "184.164.250.0/24", asn = 47065 },
{ id = 2, prefix = "184.164.251.0/24", asn = 47065 },
]

sites = [
{ name = "amsterdam01", neighbor = "100.69.128.1", asn = 47065 },
{ name = "clemson01", neighbor = "100.80.128.1", asn = 47065 },
{ name = "gatech01", neighbor = "100.70.128.1", asn = 47065 },
{ name = "grnet01", neighbor = "100.73.128.1", asn = 47065 },
{ name = "isi01", neighbor = "100.66.128.1", asn = 47065 },
{ name = "neu01", neighbor = "100.78.128.1", asn = 47065 },
{ name = "saopaulo01", neighbor = "100.83.128.1", asn = 47065 },
{ name = "seattle01", neighbor = "100.65.128.1", asn = 47065 },
{ name = "ufmg01", neighbor = "100.71.128.1", asn = 47065 },
{ name = "utah01", neighbor = "100.81.128.1", asn = 47065 },
{ name = "uw01", neighbor = "100.74.128.1", asn = 47065 },
{ name = "vtramsterdam", neighbor = "100.89.128.1", asn = 47065 },
{ name = "vtratlanta", neighbor = "100.88.128.1", asn = 47065 },
{ name = "vtrbangalore", neighbor = "100.104.128.1", asn = 47065 },
{ name = "vtrchicago", neighbor = "100.94.128.1", asn = 47065 },
{ name = "vtrdallas", neighbor = "100.99.128.1", asn = 47065 },
{ name = "vtrdelhi", neighbor = "100.105.128.1", asn = 47065 },
{ name = "vtrfrankfurt", neighbor = "100.92.128.1", asn = 47065 },
{ name = "vtrhonolulu", neighbor = "100.118.128.1", asn = 47065 },
{ name = "vtrjohannesburg", neighbor = "100.113.128.1", asn = 47065 },
{ name = "vtrlondon", neighbor = "100.108.128.1", asn = 47065 },
{ name = "vtrlosangelas", neighbor = "100.106.128.1", asn = 47065 },
{ name = "vtrmadrid", neighbor = "100.102.128.1", asn = 47065 },
{ name = "vtrmanchester", neighbor = "100.116.128.1", asn = 47065 },
{ name = "vtrmelbourne", neighbor = "100.111.128.1", asn = 47065 },
{ name = "vtrmexico", neighbor = "100.100.128.1", asn = 47065 },
{ name = "vtrmiami", neighbor = "100.87.128.1", asn = 47065 },
{ name = "vtrmumbai", neighbor = "100.109.128.1", asn = 47065 },
{ name = "vtrnewyork", neighbor = "100.98.128.1", asn = 47065 },
{ name = "vtrosaka", neighbor = "100.114.128.1", asn = 47065 },
{ name = "vtrparis", neighbor = "100.95.128.1", asn = 47065 },
{ name = "vtrsantiago", neighbor = "100.115.128.1", asn = 47065 },
{ name = "vtrsaopaulo", neighbor = "100.112.128.1", asn = 47065 },
{ name = "vtrseattle", neighbor = "100.93.128.1", asn = 47065 },
{ name = "vtrseoul", neighbor = "100.110.128.1", asn = 47065 },
{ name = "vtrsilicon", neighbor = "100.107.128.1", asn = 47065 },
{ name = "vtrsingapore", neighbor = "100.96.128.1", asn = 47065 },
{ name = "vtrstockholm", neighbor = "100.103.128.1", asn = 47065 },
{ name = "vtrsydney", neighbor = "100.91.128.1", asn = 47065 },
{ name = "vtrtelaviv", neighbor = "100.117.128.1", asn = 47065 },
{ name = "vtrtokyo", neighbor = "100.90.128.1", asn = 47065 },
{ name = "vtrtoronto", neighbor = "100.101.128.1", asn = 47065 },
{ name = "vtrwarsaw", neighbor = "100.97.128.1", asn = 47065 },
{ name = "wisc01", neighbor = "100.75.128.1", asn = 47065 },
{ id = 5, name = "amsterdam01", neighbor = "100.69.128.1", asn = 47065 },
{ id = 16, name = "clemson01", neighbor = "100.80.128.1", asn = 47065 },
{ id = 6, name = "gatech01", neighbor = "100.70.128.1", asn = 47065 },
]
h = [
{ id = 9, name = "grnet01", neighbor = "100.73.128.1", asn = 47065 },
{ id = 2, name = "isi01", neighbor = "100.66.128.1", asn = 47065 },
{ id = 14, name = "neu01", neighbor = "100.78.128.1", asn = 47065 },
{ id = 2, name = "isi01", neighbor = "100.66.128.1", asn = 47065 },
{ id = 14, name = "neu01", neighbor = "100.78.128.1", asn = 47065 },
{ id = 19, name = "saopaulo01", neighbor = "100.83.128.1", asn = 47065 },
{ id = 1, name = "seattle01", neighbor = "100.65.128.1", asn = 47065 },
{ id = 7, name = "ufmg01", neighbor = "100.71.128.1", asn = 47065 },
{ id = 17, name = "utah01", neighbor = "100.81.128.1", asn = 47065 },
{ id = 10, name = "uw01", neighbor = "100.74.128.1", asn = 47065 },
{ id = 25, name = "vtramsterdam", neighbor = "100.89.128.1", asn = 47065 },
{ id = 24, name = "vtratlanta", neighbor = "100.88.128.1", asn = 47065 },
{ id = 40, name = "vtrbangalore", neighbor = "100.104.128.1", asn = 47065 },
{ id = 30, name = "vtrchicago", neighbor = "100.94.128.1", asn = 47065 },
{ id = 35, name = "vtrdallas", neighbor = "100.99.128.1", asn = 47065 },
{ id = 41, name = "vtrdelhi", neighbor = "100.105.128.1", asn = 47065 },
{ id = 28, name = "vtrfrankfurt", neighbor = "100.92.128.1", asn = 47065 },
{ id = 54, name = "vtrhonolulu", neighbor = "100.118.128.1", asn = 47065 },
{ id = 49, name = "vtrjohannesburg", neighbor = "100.113.128.1", asn = 47065 },
{ id = 44, name = "vtrlondon", neighbor = "100.108.128.1", asn = 47065 },
{ id = 42, name = "vtrlosangelas", neighbor = "100.106.128.1", asn = 47065 },
{ id = 38, name = "vtrmadrid", neighbor = "100.102.128.1", asn = 47065 },
{ id = 52, name = "vtrmanchester", neighbor = "100.116.128.1", asn = 47065 },
{ id = 47, name = "vtrmelbourne", neighbor = "100.111.128.1", asn = 47065 },
{ id = 36, name = "vtrmexico", neighbor = "100.100.128.1", asn = 47065 },
{ id = 23, name = "vtrmiami", neighbor = "100.87.128.1", asn = 47065 },
{ id = 45, name = "vtrmumbai", neighbor = "100.109.128.1", asn = 47065 },
{ id = 34, name = "vtrnewyork", neighbor = "100.98.128.1", asn = 47065 },
{ id = 50, name = "vtrosaka", neighbor = "100.114.128.1", asn = 47065 },
{ id = 31, name = "vtrparis", neighbor = "100.95.128.1", asn = 47065 },
{ id = 51, name = "vtrsantiago", neighbor = "100.115.128.1", asn = 47065 },
{ id = 48, name = "vtrsaopaulo", neighbor = "100.112.128.1", asn = 47065 },
{ id = 29, name = "vtrseattle", neighbor = "100.93.128.1", asn = 47065 },
{ id = 46, name = "vtrseoul", neighbor = "100.110.128.1", asn = 47065 },
{ id = 43, name = "vtrsilicon", neighbor = "100.107.128.1", asn = 47065 },
{ id = 32, name = "vtrsingapore", neighbor = "100.96.128.1", asn = 47065 },
{ id = 39, name = "vtrstockholm", neighbor = "100.103.128.1", asn = 47065 },
{ id = 27, name = "vtrsydney", neighbor = "100.91.128.1", asn = 47065 },
{ id = 53, name = "vtrtelaviv", neighbor = "100.117.128.1", asn = 47065 },
{ id = 26, name = "vtrtokyo", neighbor = "100.90.128.1", asn = 47065 },
{ id = 37, name = "vtrtoronto", neighbor = "100.101.128.1", asn = 47065 },
{ id = 33, name = "vtrwarsaw", neighbor = "100.97.128.1", asn = 47065 },
{ id = 11, name = "wisc01", neighbor = "100.75.128.1", asn = 47065 },
]
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ prom exporter.

this is meant to be in conjunction with peeringmon_exporter and a prom server
to monitor bgp routes for the peering testbed.

each announcement has the site's configured id value injected in the community
to test for zombie routes

0 comments on commit ac5d494

Please sign in to comment.