summaryrefslogtreecommitdiffhomepage
path: root/packet
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-26 19:04:58 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-26 19:04:58 +0900
commit7925a63bc54536b0a39ed72666cd49d1c0cbddc2 (patch)
tree953594d2ed826e374232fca07ad55a5c9f014816 /packet
parent7b1ed59ef2191c232752f0eb841f19b10ec0937a (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')
-rw-r--r--packet/bgp.go10
-rw-r--r--packet/bgp_test.go4
2 files changed, 11 insertions, 3 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
diff --git a/packet/bgp_test.go b/packet/bgp_test.go
index 8fd734eb..f5023dae 100644
--- a/packet/bgp_test.go
+++ b/packet/bgp_test.go
@@ -104,8 +104,8 @@ func update() *BGPMessage {
NewPathAttributeMpReachNLRI("fe80::", mp_nlri3),
NewPathAttributeMpReachNLRI("129.1.1.1", mp_nlri4),
NewPathAttributeMpUnreachNLRI(mp_nlri),
- NewPathAttributeMpReachNLRI("112.22.2.0", []AddrPrefixInterface{}),
- NewPathAttributeMpUnreachNLRI([]AddrPrefixInterface{}),
+ //NewPathAttributeMpReachNLRI("112.22.2.0", []AddrPrefixInterface{}),
+ //NewPathAttributeMpUnreachNLRI([]AddrPrefixInterface{}),
&PathAttributeUnknown{
PathAttribute: PathAttribute{
Flags: BGP_ATTR_FLAG_TRANSITIVE,