Skip to content

Commit

Permalink
The count makes little sense as a return value. Especially since it d…
Browse files Browse the repository at this point in the history
…oes not include the vap and bgpsec keys.

As a result reloadFromCurrentState() gets utterly confused and creates new versions when there is no change.
Fix for bgp#114
  • Loading branch information
cjeker authored and netixx committed Feb 29, 2024
1 parent 834eb64 commit 1af8453
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/stayrtr/stayrtr.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func isValidPrefixLength(prefix netip.Prefix, maxLength uint8) bool {
// Will return a deduped slice, as well as total VRPs, IPv4 VRPs, IPv6 VRPs, BGPsec Keys and ASPA records
func processData(vrplistjson []prefixfile.VRPJson,
brklistjson []prefixfile.BgpSecKeyJson,
aspajson []prefixfile.VAPJson) /*Export*/ ([]rtr.VRP, []rtr.BgpsecKey, []rtr.VAP, int, int, int) {
aspajson []prefixfile.VAPJson) /*Export*/ ([]rtr.VRP, []rtr.BgpsecKey, []rtr.VAP, int, int) {
filterDuplicates := make(map[string]struct{})

// It may be tempting to change this to a simple time.Since() but that will
Expand Down Expand Up @@ -338,7 +338,7 @@ func processData(vrplistjson []prefixfile.VRPJson,
})
}

return vrplist, brklist, aspalist, countv4 + countv6, countv4, countv6
return vrplist, brklist, aspalist, countv4, countv6
}

type IdenticalFile struct {
Expand Down Expand Up @@ -387,7 +387,8 @@ func (s *state) updateFromNewState() error {
vrpsjson, aspajson, bgpsecjson = s.slurm.FilterAssert(vrpsjson, aspajson, bgpsecjson, log.StandardLogger())
}

vrps, brks, vaps, count, countv4, countv6 := processData(vrpsjson, bgpsecjson, aspajson)
vrps, brks, vaps, countv4, countv6 := processData(vrpsjson, bgpsecjson, aspajson)
count := len(vrps) + len(brks) + len(vaps)

log.Infof("New update (%v uniques, %v total prefixes, %v vaps, %v router keys).", len(vrps), count, len(vaps), len(brks))
return s.applyUpdateFromNewState(vrps, brks, vaps, sessid, vrpsjson, bgpsecjson, aspajson, countv4, countv6)
Expand Down Expand Up @@ -429,7 +430,8 @@ func (s *state) reloadFromCurrentState() error {
vrpsjson, aspajson, bgpsecjson = s.slurm.FilterAssert(vrpsjson, aspajson, bgpsecjson, log.StandardLogger())
}

vrps, brks, vaps, count, countv4, countv6 := processData(vrpsjson, bgpsecjson, aspajson)
vrps, brks, vaps, countv4, countv6 := processData(vrpsjson, bgpsecjson, aspajson)
count := len(vrps) + len(brks) + len(vaps)
if s.server.CountSDs() != count {
log.Infof("New update to old state (%v uniques, %v total prefixes). (old %v - new %v)", len(vrps), count, s.server.CountSDs(), count)
return s.applyUpdateFromNewState(vrps, brks, vaps, sessid, vrpsjson, bgpsecjson, aspajson, countv4, countv6)
Expand Down

0 comments on commit 1af8453

Please sign in to comment.