mirror of
https://github.com/bgp/stayrtr.git
synced 2024-05-06 15:54:54 +00:00
Merge pull request #84 from bgp/send_error_to_desync_clients
Bugfix: don't echo the router's session_id back to the router, instead report an error
This commit is contained in:
@ -78,6 +78,15 @@ func (e *DefaultRTREventHandler) RequestNewVersion(c *Client, sessionId uint16,
|
||||
if e.Log != nil {
|
||||
e.Log.Debugf("%v > Request New Version", c)
|
||||
}
|
||||
server_SessionId := e.vrpManager.GetSessionId()
|
||||
if sessionId != server_SessionId {
|
||||
c.SendCorruptData()
|
||||
if e.Log != nil {
|
||||
e.Log.Debugf("%v < Invalid request (client asked for session %d but server is at %d)", c, sessionId, server_SessionId)
|
||||
}
|
||||
c.Disconnect()
|
||||
return
|
||||
}
|
||||
serial, valid := e.vrpManager.GetCurrentSerial(sessionId)
|
||||
if !valid {
|
||||
c.SendNoDataError()
|
||||
@ -914,6 +923,14 @@ func (c *Client) SendNoDataError() {
|
||||
c.SendPDU(pdu)
|
||||
}
|
||||
|
||||
func (c *Client) SendCorruptData() {
|
||||
pdu := &PDUErrorReport{
|
||||
ErrorCode: PDU_ERROR_CORRUPTDATA,
|
||||
ErrorMsg: "Session ID mismatch: client is desynchronized",
|
||||
}
|
||||
c.SendPDU(pdu)
|
||||
}
|
||||
|
||||
func (c *Client) SendWrongVersionError() {
|
||||
pdu := &PDUErrorReport{
|
||||
ErrorCode: PDU_ERROR_BADPROTOVERSION,
|
||||
|
Reference in New Issue
Block a user