Comments (2)
updateFromNewState() gets called unconditionally after first hit by updateFile() during startup. If updateFile() errors out, s.lastdata doesn't get populated. This nil pointer gets dereferenced and then crashes. This does not appear affect already running scenario because s.lastdata would have been populated or crashed on first run and error checking is in place that ensures the pointer is not changed if there is an error retrieving or deserializing.
Frame 4: ./stayrtr.go:258 (PC: a242a4)
253: // Update the state based on the current slurm file and data.
254: func (s *state) updateFromNewState() error {
255: sessid, _ := s.server.GetSessionId(nil)
256:
257: if s.checktime {
=> 258: buildtime, err := time.Parse(time.RFC3339, s.lastdata.Metadata.Buildtime)
259: if err != nil {
260: return err
261: }
262: notafter := buildtime.Add(time.Hour * 24)
263: if time.Now().UTC().After(notafter) {
(dlv) print s.lastdata
*github.com/bgp/stayrtr/prefixfile.VRPList nil
Fundamentally, this defect can be fixed either by:
- Initializing a placeholder (empty?) structure or
- explicitly handling nil pointer scenario and ensure that other uninitialized components (s.lasthash, s.lastchange) are also not problematic
In case # 1, the empty structure could be an empty VRPList. On initialization of a server object, an empty VRPList is created and pointed to via lastdata. Because updatefile() relies on the hash provided in lasthash and the comparison function is bytes.Compare, the empty []byte slice will never compare as equal (until later populated). This results in routineUpdate() retrying based on its existing timers.
In case # 2, updateFromNewState() would check for nil s.lastdata pointer and return an error. This would leave the pointer alone until updateFile() finally gets the file correctly. Other places in code would need to be aware of the possibility of nil-ity to avoid future problems.
To avoid changing more than required and reduce silliness of forgetting nil pointers, I'll use # 1 by instantiating an empty VRPList in the state.lastdata member. It is probably possible to simply change the lastdata to not be a pointer to resolve this issue, but it requires more reading and thinking to be sure of side effects.
from stayrtr.
Issue was fixed, but also see now that the refresh time is really too long to wait. By default, it is 1 hour. While it will probably work in an hour, this should probably complete a bit faster.
Since s.lastchange.IsZero() will only be true prior to fetch, check this value and set the refresh to 30 seconds when true.
from stayrtr.
Related Issues (20)
- Expose better file fetch metrics
- Add draft-ietf-sidrops-8210bis-10 (RTR version 2) support
- Add released version as a tag for the released docker image
- Please consider to send "Cache Reset" when client Serial Number is too old (CSCvp8228716) HOT 10
- Ensure session ID uniqueness HOT 4
- stayrtr-0.4.0-1.x86_64.rpm install failing on centos7.9 HOT 3
- Load testing tool?
- Error Response message not sent HOT 4
- Stayrtr throws rtrlib.SendableData is *rtrlib.BgpsecKey, not *rtrlib.VRP HOT 9
- Duplicate VRP served out HOT 6
- Detect BGPsec Router Key corruption in JSON input HOT 3
- stayrtr services crashes: panic: interface conversion: rtrlib.SendableData is *rtrlib.VAP, not *rtrlib.VRP HOT 3
- stayrtr and Juniper 19.4 HOT 5
- Update ASPA-SLURM to -01
- Unable to create Debian Package HOT 3
- Use compression for transfer of JSON HOT 2
- add serial back to json output
- serial is updated but FetchFile returns 304 for objects and slurm is local and not changed HOT 16
- Does rtrdump actually downgrade the version? HOT 3
- -version doesn't expose version HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stayrtr.