mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
server: handle over 4096 byte size message
send notification. Signed-off-by: FUJITA Tomonori <[email protected]>
This commit is contained in:
+2
-1
@@ -2584,7 +2584,8 @@ type BGPBody interface {
|
||||
}
|
||||
|
||||
const (
|
||||
BGP_HEADER_LENGTH = 19
|
||||
BGP_HEADER_LENGTH = 19
|
||||
BGP_MAX_MESSAGE_LENGTH = 4096
|
||||
)
|
||||
|
||||
type BGPHeader struct {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package bgp
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"github.com/osrg/gobgp/config"
|
||||
"net"
|
||||
"strconv"
|
||||
@@ -139,3 +140,12 @@ func ValidateFlags(t BGPAttrType, flags uint8) (bool, string) {
|
||||
}
|
||||
return true, ""
|
||||
}
|
||||
|
||||
func ValidateBGPMessage(m *BGPMessage) error {
|
||||
if m.Header.Len > BGP_MAX_MESSAGE_LENGTH {
|
||||
buf := make([]byte, 2)
|
||||
binary.BigEndian.PutUint16(buf, m.Header.Len)
|
||||
return NewMessageError(BGP_ERROR_MESSAGE_HEADER_ERROR, BGP_ERROR_SUB_BAD_MESSAGE_LENGTH, buf, "too long length")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -225,6 +225,9 @@ func (h *FSMHandler) recvMessageWithError() error {
|
||||
|
||||
var fmsg *fsmMsg
|
||||
m, err := bgp.ParseBGPBody(hd, bodyBuf)
|
||||
if err == nil {
|
||||
err = bgp.ValidateBGPMessage(m)
|
||||
}
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"Topic": "Peer",
|
||||
|
||||
Reference in New Issue
Block a user