-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust handling of version-session_id-serial touple #110
Conversation
So we were not reading the RFC carefully enough all this time? I guess this mitigates the problem I outlined to some degree? |
Yes but too be honest it did not really matter until now since nothing uses router keys which was the data addition in v1. I'm not surprised; the RTR RFC are IMO sub-standard since stuff is hidden in unrelated sections that people just glance over. Also a lot is left out giving implementations too much wiggle room for unexpected behaviour. |
And it has some choices where the reason may have been abundantly clear when written if you went through the process, but are vague now. This is one. When I read this originally another idea came up though: if you can extract a (session, revision) tuple in the metadata of an RP, you can have multiple rtr servers be in sync when using the same data as input. |
Even if the Tu run with a fixed One could argue that the |
@@ -829,7 +823,7 @@ func run() error { | |||
|
|||
if *Bind != "" { | |||
go func() { | |||
sessid := server.GetSessionId() | |||
sessid := server.GetSessionId(protoverToLib[*RTRVersion]) | |||
log.Infof("StayRTR Server started (sessionID:%d, refresh:%d, retry:%d, expire:%d)", sessid, sc.RefreshInterval, sc.RetryInterval, sc.ExpireInterval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sessionID per version should be printed in the log.Info()
line
It does move the problem: But you can have n instances reading their
I think this is a legitimate improvement, LGTM. |
sessids := make([]uint16, 0, int(configuration.ProtocolVersion) + 1) | ||
s := GenerateSessionId() | ||
for i := 0; i <= int(configuration.ProtocolVersion); i++ { | ||
sessids = append(sessids, s + uint16(100 * i)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't this overflow if s
for example is 0xFFFF
? I guess this is an explicit property of Go, right? https://stackoverflow.com/questions/34704843/on-purpose-int-overflow/34704898#34704898
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overflow is handled as expected since we use uint16 as type for all session ids variables.
When you run the code below the output is:
65280
65380
65480
44
144
244
Code
package main
import "fmt"
func main() {
s := uint16(0xff00)
for i := 0; i < 6; i++ {
n := s + uint16(100 * i)
fmt.Println(n)
}
}
@cjeker can you rebase? |
0740af9
to
63e6034
Compare
Rand is randomly initalized on startup so no need to reshuffle it. Surprised this code did not xor the PID into the seed for more profit
Just because there are slices and maps you don't need to use them for something as simple (myserial - theirserial) to know which delta to send.
63e6034
to
aaf389b
Compare
The version-session_id-serial touple defines the cache state. When a client connects with a different version its cache is no longer in sync and this is the simplest way to enforce this.
aaf389b
to
6dab8b6
Compare
Too tired to rebase without fail. I double check in the morning but I think this is the right bits. |
Rechecked the rebase and all is fine in the last version. |
RFC 8210 has this in Section 5.1
This changes the code to create session ids and spacing them 100 apart from each other.
With this the
Serial Query
will fail for a system that does a session down/upgrade.