diff options
-rw-r--r-- | packet/bgp.go | 5 | ||||
-rw-r--r-- | packet/bgp_test.go | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index 5131a284..a5fd715c 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -1134,6 +1134,7 @@ func (p *PathAttribute) getType() BGPAttrType { } func (p *PathAttribute) DecodeFromBytes(data []byte) error { + odata := data eCode := uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR) eSubCode := uint8(BGP_ERROR_SUB_ATTRIBUTE_LENGTH_ERROR) if len(data) < 2 { @@ -1160,6 +1161,10 @@ func (p *PathAttribute) DecodeFromBytes(data []byte) error { } p.Value = data[:p.Length] + ok, eMsg := ValidateFlags(p.Type, p.Flags) + if !ok { + return NewMessageError(eCode, BGP_ERROR_SUB_ATTRIBUTE_FLAGS_ERROR, odata[:p.Len()], eMsg) + } return nil } diff --git a/packet/bgp_test.go b/packet/bgp_test.go index 5b2e1736..8fd734eb 100644 --- a/packet/bgp_test.go +++ b/packet/bgp_test.go @@ -108,7 +108,7 @@ func update() *BGPMessage { NewPathAttributeMpUnreachNLRI([]AddrPrefixInterface{}), &PathAttributeUnknown{ PathAttribute: PathAttribute{ - Flags: 1, + Flags: BGP_ATTR_FLAG_TRANSITIVE, Type: 100, Value: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, }, |