summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/zebra/zapi_test.go
diff options
context:
space:
mode:
authorHitoshi Irino <irino@sfc.wide.ad.jp>2019-07-21 15:08:23 +0900
committerHitoshi Irino <irino@sfc.wide.ad.jp>2019-07-21 15:25:50 +0900
commit7284d4cf8b3f9ecd03068dfa3ab3d433860b5089 (patch)
treea3e65926529501e19a33a8181fa4e14cd17d792b /internal/pkg/zebra/zapi_test.go
parent426709893303ecd0ff189cfe0b24eda89edef95e (diff)
Avoid panic by receiving vpnv6 prefixes with zebra reported in issue #2113
- Additionally bug fix which avoid panic caused by displaying vpnv6 prefixes using gobgp vrf rib - Supporting FRRouting 7.1.x
Diffstat (limited to 'internal/pkg/zebra/zapi_test.go')
-rw-r--r--internal/pkg/zebra/zapi_test.go60
1 files changed, 30 insertions, 30 deletions
diff --git a/internal/pkg/zebra/zapi_test.go b/internal/pkg/zebra/zapi_test.go
index 9454a8a0..b75421c2 100644
--- a/internal/pkg/zebra/zapi_test.go
+++ b/internal/pkg/zebra/zapi_test.go
@@ -127,12 +127,12 @@ func Test_InterfaceUpdateBody(t *testing.T) {
pos += 1
}
b := &InterfaceUpdateBody{}
- err := b.DecodeFromBytes(buf, v)
+ err := b.DecodeFromBytes(buf, v, "")
assert.Equal(nil, err)
assert.Equal("01:23:45:67:89:ab", b.HardwareAddr.String())
buf = make([]byte, INTERFACE_NAMSIZ+32) //size mismatch
b = &InterfaceUpdateBody{}
- err = b.DecodeFromBytes(buf, v)
+ err = b.DecodeFromBytes(buf, v, "")
assert.NotEqual(nil, err)
}
}
@@ -159,7 +159,7 @@ func Test_InterfaceAddressUpdateBody(t *testing.T) {
copy(buf[pos:pos+4], []byte(dst))
b := &InterfaceAddressUpdateBody{}
- err := b.DecodeFromBytes(buf, v)
+ err := b.DecodeFromBytes(buf, v, "")
require.NoError(t, err)
assert.Equal(uint32(0), b.Index)
@@ -172,7 +172,7 @@ func Test_InterfaceAddressUpdateBody(t *testing.T) {
buf[5] = 0x4
pos += 1
b = &InterfaceAddressUpdateBody{}
- err = b.DecodeFromBytes(buf, v)
+ err = b.DecodeFromBytes(buf, v, "")
assert.NotEqual(nil, err)
}
}
@@ -192,7 +192,7 @@ func Test_RouterIDUpdateBody(t *testing.T) {
buf[pos] = byte(32)
b := &RouterIDUpdateBody{}
- err := b.DecodeFromBytes(buf, v)
+ err := b.DecodeFromBytes(buf, v, "")
assert.Equal(nil, err)
assert.Equal("192.168.100.1", b.Prefix.String())
assert.Equal(uint8(32), b.Length)
@@ -201,7 +201,7 @@ func Test_RouterIDUpdateBody(t *testing.T) {
buf[0] = 0x4
pos += 1
b = &RouterIDUpdateBody{}
- err = b.DecodeFromBytes(buf, v)
+ err = b.DecodeFromBytes(buf, v, "")
assert.NotEqual(nil, err)
}
}
@@ -294,7 +294,7 @@ func Test_IPRouteBody_IPv4(t *testing.T) {
binary.BigEndian.PutUint32(buf[pos:], 1) // mtu
pos += 4
r := &IPRouteBody{Api: command[v]}
- err := r.DecodeFromBytes(buf, v)
+ err := r.DecodeFromBytes(buf, v, "")
assert.Equal(nil, err)
assert.Equal("192.168.100.0", r.Prefix.Prefix.String())
assert.Equal(uint8(0x18), r.Prefix.PrefixLen)
@@ -311,7 +311,7 @@ func Test_IPRouteBody_IPv4(t *testing.T) {
assert.Equal(uint32(1), r.Mtu)
//Serialize
- buf, err = r.Serialize(v)
+ buf, err = r.Serialize(v, "")
assert.Equal(nil, err)
switch v {
case 2, 3:
@@ -416,7 +416,7 @@ func Test_IPRouteBody_IPv4(t *testing.T) {
pos += 4
r = &IPRouteBody{Api: command[v]}
- err = r.DecodeFromBytes(buf, v)
+ err = r.DecodeFromBytes(buf, v, "")
switch v {
case 2, 3, 4:
assert.Equal("MESSAGE_METRIC message length invalid pos:14 rest:14", err.Error())
@@ -461,7 +461,7 @@ func Test_IPRouteBody_IPv4(t *testing.T) {
binary.BigEndian.PutUint32(buf[pos:], 0) //metric
pos += 4
r = &IPRouteBody{Api: command[v]}
- err = r.DecodeFromBytes(buf, v)
+ err = r.DecodeFromBytes(buf, v, "")
assert.Equal(nil, err)
}
}
@@ -560,7 +560,7 @@ func Test_IPRouteBody_IPv6(t *testing.T) {
binary.BigEndian.PutUint32(buf[pos:], 1) // mtu
pos += 4
r := &IPRouteBody{Api: command[v]}
- err := r.DecodeFromBytes(buf, v)
+ err := r.DecodeFromBytes(buf, v, "")
assert.Equal(nil, err)
assert.Equal("2001:db8:0:f101::", r.Prefix.Prefix.String())
assert.Equal(uint8(64), r.Prefix.PrefixLen)
@@ -577,7 +577,7 @@ func Test_IPRouteBody_IPv6(t *testing.T) {
assert.Equal(uint32(1), r.Mtu)
//Serialize
- buf, err = r.Serialize(v)
+ buf, err = r.Serialize(v, "")
assert.Equal(nil, err)
switch v {
case 2, 3:
@@ -683,7 +683,7 @@ func Test_IPRouteBody_IPv6(t *testing.T) {
pos += 4
r = &IPRouteBody{Api: command[v]}
- err = r.DecodeFromBytes(buf, v)
+ err = r.DecodeFromBytes(buf, v, "")
switch v {
case 2, 3, 4:
assert.Equal("message length invalid pos:39 rest:46", err.Error())
@@ -726,7 +726,7 @@ func Test_IPRouteBody_IPv6(t *testing.T) {
buf[pos] = 1 //distance
binary.BigEndian.PutUint32(buf[pos:], 0) //metic
r = &IPRouteBody{Api: command[v]}
- err = r.DecodeFromBytes(buf, v)
+ err = r.DecodeFromBytes(buf, v, "")
assert.Equal(nil, err)
}
}
@@ -754,7 +754,7 @@ func Test_NexthopLookupBody(t *testing.T) {
binary.BigEndian.PutUint32(buf[pos:], 3)
b := &NexthopLookupBody{Api: IPV4_NEXTHOP_LOOKUP}
- err := b.DecodeFromBytes(buf, 2)
+ err := b.DecodeFromBytes(buf, 2, "")
assert.Equal(nil, err)
assert.Equal("192.168.50.0", b.Addr.String())
assert.Equal(uint32(10), b.Metric)
@@ -763,7 +763,7 @@ func Test_NexthopLookupBody(t *testing.T) {
assert.Equal("172.16.1.101", b.Nexthops[0].Gate.String())
//Serialize
- buf, err = b.Serialize(2)
+ buf, err = b.Serialize(2, "")
ip = net.ParseIP("192.168.50.0").To4()
assert.Equal(nil, err)
assert.Equal([]byte(ip)[0:4], buf[0:4])
@@ -771,7 +771,7 @@ func Test_NexthopLookupBody(t *testing.T) {
// length invalid
buf = make([]byte, 3)
b = &NexthopLookupBody{Api: IPV4_NEXTHOP_LOOKUP}
- err = b.DecodeFromBytes(buf, 2)
+ err = b.DecodeFromBytes(buf, 2, "")
assert.NotEqual(nil, err)
//ipv6
@@ -793,7 +793,7 @@ func Test_NexthopLookupBody(t *testing.T) {
binary.BigEndian.PutUint32(buf[pos:], 3)
b = &NexthopLookupBody{Api: IPV6_NEXTHOP_LOOKUP}
- err = b.DecodeFromBytes(buf, 2)
+ err = b.DecodeFromBytes(buf, 2, "")
assert.Equal(nil, err)
assert.Equal("2001:db8:0:f101::", b.Addr.String())
assert.Equal(uint32(10), b.Metric)
@@ -802,7 +802,7 @@ func Test_NexthopLookupBody(t *testing.T) {
assert.Equal("2001:db8:0:1111::1", b.Nexthops[0].Gate.String())
//Serialize
- buf, err = b.Serialize(2)
+ buf, err = b.Serialize(2, "")
ip = net.ParseIP("2001:db8:0:f101::").To16()
assert.Equal(nil, err)
assert.Equal([]byte(ip)[0:16], buf[0:16])
@@ -810,7 +810,7 @@ func Test_NexthopLookupBody(t *testing.T) {
// length invalid
buf = make([]byte, 15)
b = &NexthopLookupBody{Api: IPV6_NEXTHOP_LOOKUP}
- err = b.DecodeFromBytes(buf, 2)
+ err = b.DecodeFromBytes(buf, 2, "")
assert.NotEqual(nil, err)
}
@@ -836,7 +836,7 @@ func Test_ImportLookupBody(t *testing.T) {
binary.BigEndian.PutUint32(buf[pos:], 3)
b := &ImportLookupBody{Api: IPV4_IMPORT_LOOKUP}
- err := b.DecodeFromBytes(buf, 2)
+ err := b.DecodeFromBytes(buf, 2, "")
assert.Equal(nil, err)
assert.Equal("192.168.50.0", b.Addr.String())
assert.Equal(uint32(10), b.Metric)
@@ -846,7 +846,7 @@ func Test_ImportLookupBody(t *testing.T) {
//Serialize
b.PrefixLength = uint8(24)
- buf, err = b.Serialize(2)
+ buf, err = b.Serialize(2, "")
ip = net.ParseIP("192.168.50.0").To4()
assert.Equal(nil, err)
assert.Equal(uint8(24), buf[0])
@@ -855,7 +855,7 @@ func Test_ImportLookupBody(t *testing.T) {
// length invalid
buf = make([]byte, 3)
b = &ImportLookupBody{Api: IPV4_IMPORT_LOOKUP}
- err = b.DecodeFromBytes(buf, 2)
+ err = b.DecodeFromBytes(buf, 2, "")
assert.NotEqual(nil, err)
}
@@ -882,7 +882,7 @@ func Test_NexthopRegisterBody(t *testing.T) {
for v := MinZapiVer; v <= MaxZapiVer; v++ {
// Test DecodeFromBytes()
b := &NexthopRegisterBody{Api: command[v]}
- err := b.DecodeFromBytes(bufIn, v)
+ err := b.DecodeFromBytes(bufIn, v, "")
assert.Nil(err)
// Test decoded values
@@ -894,7 +894,7 @@ func Test_NexthopRegisterBody(t *testing.T) {
assert.Equal(net.ParseIP("2001:db8:1:1::1").To16(), b.Nexthops[1].Prefix)
// Test Serialize()
- bufOut, err := b.Serialize(v)
+ bufOut, err := b.Serialize(v, "")
assert.Nil(err)
// Test serialised value
@@ -950,7 +950,7 @@ func Test_NexthopUpdateBody(t *testing.T) {
// Test DecodeFromBytes()
b := &NexthopUpdateBody{Api: command[v]}
- err := b.DecodeFromBytes(bufIn, v)
+ err := b.DecodeFromBytes(bufIn, v, "")
assert.Nil(err)
// Test decoded values
@@ -982,12 +982,12 @@ func Test_GetLabelChunkBody(t *testing.T) {
binary.BigEndian.PutUint32(buf[8:], 89) //End
b := &GetLabelChunkBody{}
- err := b.DecodeFromBytes(buf, v)
+ err := b.DecodeFromBytes(buf, v, "")
assert.Equal(nil, err)
//Serialize
b.ChunkSize = 10
- buf, err = b.Serialize(v)
+ buf, err = b.Serialize(v, "")
assert.Equal(nil, err)
assert.Equal(byte(routeType[v]), buf[0])
bi := make([]byte, 4)
@@ -1006,11 +1006,11 @@ func Test_VrfLabelBody(t *testing.T) {
bufIn[4] = byte(AFI_IP)
bufIn[5] = byte(LSP_BGP)
b := &VrfLabelBody{}
- err := b.DecodeFromBytes(bufIn, v)
+ err := b.DecodeFromBytes(bufIn, v, "")
assert.Equal(nil, err)
//Serialize
var bufOut []byte
- bufOut, err = b.Serialize(v)
+ bufOut, err = b.Serialize(v, "")
assert.Equal(nil, err)
assert.Equal(bufIn, bufOut)
}