diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-03-19 22:56:12 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-03-19 22:56:12 +0900 |
commit | cda7c44afe723be74e39266823b54ba28d0ec019 (patch) | |
tree | 08cf46dd438c449b562000aed2c45780a019c535 /packet/bgp/bgp_test.go | |
parent | 33b1ed91697abc273317c9ad7d1579dabebb9e5f (diff) |
packet/bgp: make serialization of ipv4/v6 nlri goroutine-safe
The serialization of ipv4/v6 nlri should be goroutine-safe but somehow not.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp/bgp_test.go')
-rw-r--r-- | packet/bgp/bgp_test.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/packet/bgp/bgp_test.go b/packet/bgp/bgp_test.go index 1b9df371..248fb346 100644 --- a/packet/bgp/bgp_test.go +++ b/packet/bgp/bgp_test.go @@ -63,10 +63,17 @@ func Test_Message(t *testing.T) { func Test_IPAddrPrefixString(t *testing.T) { ipv4 := NewIPAddrPrefix(24, "129.6.10.0") assert.Equal(t, "129.6.10.0/24", ipv4.String()) - ipv6 := NewIPv6AddrPrefix(18, "3343:faba:3903::1") - assert.Equal(t, "3343:faba:3903::1/18", ipv6.String()) - ipv6 = NewIPv6AddrPrefix(18, "3343:faba:3903::0") - assert.Equal(t, "3343:faba:3903::/18", ipv6.String()) + ipv4 = NewIPAddrPrefix(24, "129.6.10.1") + assert.Equal(t, "129.6.10.0/24", ipv4.String()) + ipv4 = NewIPAddrPrefix(22, "129.6.129.0") + assert.Equal(t, "129.6.128.0/22", ipv4.String()) + + ipv6 := NewIPv6AddrPrefix(64, "3343:faba:3903::0") + assert.Equal(t, "3343:faba:3903::/64", ipv6.String()) + ipv6 = NewIPv6AddrPrefix(64, "3343:faba:3903::1") + assert.Equal(t, "3343:faba:3903::/64", ipv6.String()) + ipv6 = NewIPv6AddrPrefix(63, "3343:faba:3903:129::0") + assert.Equal(t, "3343:faba:3903:128::/63", ipv6.String()) } func Test_RouteTargetMembershipNLRIString(t *testing.T) { @@ -787,7 +794,7 @@ func Test_CompareFlowSpecNLRI(t *testing.T) { func Test_MpReachNLRIWithIPv4MappedIPv6Prefix(t *testing.T) { assert := assert.New(t) - n1 := NewIPv6AddrPrefix(120, "::ffff:10.0.0.1") + n1 := NewIPv6AddrPrefix(120, "::ffff:10.0.0.0") buf1, err := n1.Serialize() assert.Nil(err) n2, err := NewPrefixFromRouteFamily(RouteFamilyToAfiSafi(RF_IPv6_UC)) @@ -806,7 +813,7 @@ func Test_MpReachNLRIWithIPv4MappedIPv6Prefix(t *testing.T) { label := NewMPLSLabelStack(2) - n3 := NewLabeledIPv6AddrPrefix(120, "::ffff:10.0.0.1", *label) + n3 := NewLabeledIPv6AddrPrefix(120, "::ffff:10.0.0.0", *label) buf1, err = n3.Serialize() assert.Nil(err) n4, err := NewPrefixFromRouteFamily(RouteFamilyToAfiSafi(RF_IPv6_MPLS)) |