summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--pkg/packet/bgp/bgp.go9
-rw-r--r--pkg/packet/bgp/bgp_test.go1
2 files changed, 7 insertions, 3 deletions
diff --git a/pkg/packet/bgp/bgp.go b/pkg/packet/bgp/bgp.go
index cb28bd7f..af0656d3 100644
--- a/pkg/packet/bgp/bgp.go
+++ b/pkg/packet/bgp/bgp.go
@@ -6298,9 +6298,12 @@ func (l *LsTLVIgpRouterID) DecodeFromBytes(data []byte) error {
}
// https://tools.ietf.org/html/rfc7752#section-3.2.1.4
- // 6, 7, and 8 are the only valid values.
- if len(value) < 6 || len(value) > 8 {
- return malformedAttrListErr("Incorrect IGP Router ID length")
+ // 4, 6, 7, and 8 are the only valid values.
+ switch len(value) {
+ case 4, 6, 7, 8:
+ break
+ default:
+ return malformedAttrListErr(fmt.Sprintf("Incorrect IGP Router ID length: %d", len(value)))
}
l.RouterID = value
diff --git a/pkg/packet/bgp/bgp_test.go b/pkg/packet/bgp/bgp_test.go
index ad313247..0e53293c 100644
--- a/pkg/packet/bgp/bgp_test.go
+++ b/pkg/packet/bgp/bgp_test.go
@@ -1836,6 +1836,7 @@ func Test_LsTLVIgpRouterID(t *testing.T) {
want string
err bool
}{
+ {[]byte{0x02, 0x03, 0x00, 0x04, 0x01, 0x02, 0x03, 0x04}, `{"type":515,"igp_router_id":"[1 2 3 4]"}`, false},
{[]byte{0x02, 0x03, 0x00, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06}, `{"type":515,"igp_router_id":"[1 2 3 4 5 6]"}`, false},
{[]byte{0x02, 0x03, 0x00, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, `{"type":515,"igp_router_id":"[1 2 3 4 5 6 7]"}`, false},
{[]byte{0x02, 0x03, 0x00, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, `{"type":515,"igp_router_id":"[1 2 3 4 5 6 7 8]"}`, false},