summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorMichael Lechner <lechner@netography.com>2020-01-10 16:33:59 -0500
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2020-01-13 19:49:52 +0900
commitc899a95b274906d83c0c272e723d557259c86f20 (patch)
tree9a22d21aa8dd1c03072e36a8053a4b0cc6ce1ce7 /pkg
parent05a7e0e993de741a6a674305ed93562e93532ec4 (diff)
Parse BMP Stats Report messages with unknown Stat Types
Diffstat (limited to 'pkg')
-rw-r--r--pkg/packet/bmp/bmp.go15
-rw-r--r--pkg/packet/bmp/bmp_test.go6
2 files changed, 20 insertions, 1 deletions
diff --git a/pkg/packet/bmp/bmp.go b/pkg/packet/bmp/bmp.go
index 780d77ca..d111d251 100644
--- a/pkg/packet/bmp/bmp.go
+++ b/pkg/packet/bmp/bmp.go
@@ -344,8 +344,21 @@ func (body *BMPStatisticsReport) ParseBody(msg *BMPMessage, data []byte) error {
s = &BMPStatsTLV64{BMPStatsTLV: tl}
case BMP_STAT_TYPE_PER_AFI_SAFI_ADJ_RIB_IN, BMP_STAT_TYPE_PER_AFI_SAFI_LOC_RIB:
s = &BMPStatsTLVPerAfiSafi64{BMPStatsTLV: tl}
- default:
+ case BMP_STAT_TYPE_REJECTED, BMP_STAT_TYPE_DUPLICATE_PREFIX,
+ BMP_STAT_TYPE_DUPLICATE_WITHDRAW, BMP_STAT_TYPE_INV_UPDATE_DUE_TO_CLUSTER_LIST_LOOP,
+ BMP_STAT_TYPE_INV_UPDATE_DUE_TO_AS_PATH_LOOP, BMP_STAT_TYPE_INV_UPDATE_DUE_TO_ORIGINATOR_ID,
+ BMP_STAT_TYPE_INV_UPDATE_DUE_TO_AS_CONFED_LOOP, BMP_STAT_TYPE_WITHDRAW_UPDATE,
+ BMP_STAT_TYPE_WITHDRAW_PREFIX, BMP_STAT_TYPE_DUPLICATE_UPDATE:
s = &BMPStatsTLV32{BMPStatsTLV: tl}
+ default:
+ switch tl.Length {
+ case 4:
+ s = &BMPStatsTLV32{BMPStatsTLV: tl}
+ case 8:
+ s = &BMPStatsTLV64{BMPStatsTLV: tl}
+ default:
+ return fmt.Errorf("value length %d is not known for unknown stat type %d", tl.Length, tl.Type)
+ }
}
if err := s.ParseValue(data); err != nil {
return err
diff --git a/pkg/packet/bmp/bmp_test.go b/pkg/packet/bmp/bmp_test.go
index be99b687..66150418 100644
--- a/pkg/packet/bmp/bmp_test.go
+++ b/pkg/packet/bmp/bmp_test.go
@@ -103,3 +103,9 @@ func Test_BogusHeader(t *testing.T) {
assert.Nil(t, h)
assert.NotNil(t, err)
}
+
+func Test_RouteMonitoringUnknownType(t *testing.T) {
+ data := []byte{0x03, 0x00, 0x00, 0x00, 0xe4, 0x01, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x04, 0x70, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1b, 0x1b, 0xd8, 0xda, 0xfc, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2b, 0xb5, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2b, 0xb5, 0x7f, 0xff, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe8, 0x80, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xeb, 0x80, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xeb, 0x80, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x80, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x54, 0x80, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x80, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xa0}
+ _, err := ParseBMPMessage(data)
+ require.NoError(t, err)
+}