summaryrefslogtreecommitdiffhomepage
path: root/pkg/packet/bgp
diff options
context:
space:
mode:
authorKirill Smorodinnikov <shaitan@yandex-team.ru>2021-02-24 14:59:31 +0300
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2021-03-01 22:23:39 +0900
commit1d80152c34f367cad5a467187d574bfa3b1f2d1a (patch)
treeb2996cab9b70a2e7e366a14985fdf54ade8de4f1 /pkg/packet/bgp
parentf33148428ac2c035e526303742983db8428236b1 (diff)
Fix LsTLVIgpRouterID.DecodeFromBytes
According to https://tools.ietf.org/html/rfc7752#section-3.2.1.4, IGPRouterID could be 4-octet for OSPFv2 or OSPFv3 non-pseudonode.
Diffstat (limited to 'pkg/packet/bgp')
-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},