1
0
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:
Job Snijders
2023-02-03 21:44:50 +00:00
committed by GitHub

View File

@ -78,6 +78,15 @@ func (e *DefaultRTREventHandler) RequestNewVersion(c *Client, sessionId uint16,
if e.Log != nil { if e.Log != nil {
e.Log.Debugf("%v > Request New Version", c) 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) serial, valid := e.vrpManager.GetCurrentSerial(sessionId)
if !valid { if !valid {
c.SendNoDataError() c.SendNoDataError()
@ -914,6 +923,14 @@ func (c *Client) SendNoDataError() {
c.SendPDU(pdu) 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() { func (c *Client) SendWrongVersionError() {
pdu := &PDUErrorReport{ pdu := &PDUErrorReport{
ErrorCode: PDU_ERROR_BADPROTOVERSION, ErrorCode: PDU_ERROR_BADPROTOVERSION,