diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-26 19:04:58 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-26 19:04:58 +0900 |
commit | 7925a63bc54536b0a39ed72666cd49d1c0cbddc2 (patch) | |
tree | 953594d2ed826e374232fca07ad55a5c9f014816 /packet/bgp.go | |
parent | 7b1ed59ef2191c232752f0eb841f19b10ec0937a (diff) |
packet: fix PathAttributeMpUnreachNLRI's DecodeFromBytes
return properly an error. Also check route family.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r-- | packet/bgp.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index a5fd715c..e94b2a86 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -1887,6 +1887,10 @@ func (p *PathAttributeMpReachNLRI) DecodeFromBytes(data []byte) error { safi := value[2] p.AFI = afi p.SAFI = safi + _, err = routeFamilyPrefix(afi, safi) + if err != nil { + return NewMessageError(eCode, BGP_ERROR_SUB_ATTRIBUTE_FLAGS_ERROR, data[:p.PathAttribute.Len()], err.Error()) + } nexthopLen := value[3] if len(value) < 4+int(nexthopLen) { return NewMessageError(eCode, eSubCode, value, "mpreach nexthop length is short") @@ -1998,7 +2002,7 @@ type PathAttributeMpUnreachNLRI struct { func (p *PathAttributeMpUnreachNLRI) DecodeFromBytes(data []byte) error { err := p.PathAttribute.DecodeFromBytes(data) if err != nil { - return nil + return err } eCode := uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR) eSubCode := uint8(BGP_ERROR_SUB_ATTRIBUTE_LENGTH_ERROR) @@ -2009,6 +2013,10 @@ func (p *PathAttributeMpUnreachNLRI) DecodeFromBytes(data []byte) error { } afi := binary.BigEndian.Uint16(value[0:2]) safi := value[2] + _, err = routeFamilyPrefix(afi, safi) + if err != nil { + return NewMessageError(eCode, BGP_ERROR_SUB_ATTRIBUTE_FLAGS_ERROR, data[:p.PathAttribute.Len()], err.Error()) + } value = value[3:] p.AFI = afi p.SAFI = safi |