diff options
author | Tahir Azim <tazim@amazon.com> | 2020-12-02 05:08:27 +0000 |
---|---|---|
committer | Tahir Azim <tahir.azim@gmail.com> | 2020-12-16 18:12:24 +1100 |
commit | 5aa7108d85b6926eca99978a2fb0e728176aae98 (patch) | |
tree | 42e6eeed7879c172378407ec4095490cd0f116c8 /internal/pkg/table/path_test.go | |
parent | 066e791610596c9bb76cb15f1b3c91c1b620bc03 (diff) |
Enable IPv6 and IPv4 labeled prefixes to match against prefix set in policy
Diffstat (limited to 'internal/pkg/table/path_test.go')
-rw-r--r-- | internal/pkg/table/path_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/pkg/table/path_test.go b/internal/pkg/table/path_test.go index 421502fa..50681a0b 100644 --- a/internal/pkg/table/path_test.go +++ b/internal/pkg/table/path_test.go @@ -2,6 +2,7 @@ package table import ( + "net" "testing" "time" @@ -363,3 +364,22 @@ func TestReplaceAS(t *testing.T) { assert.Equal(t, list[2], uint32(10)) assert.Equal(t, list[3], uint32(2)) } + +func TestNLRIToIPNet(t *testing.T) { + _, n1, _ := net.ParseCIDR("30.30.30.0/24") + ipNet := nlriToIPNet(bgp.NewIPAddrPrefix(24, "30.30.30.0")) + assert.Equal(t, n1, ipNet) + + _, n2, _ := net.ParseCIDR("2806:106e:19::/48") + ipNet = nlriToIPNet(bgp.NewIPv6AddrPrefix(48, "2806:106e:19::")) + assert.Equal(t, n2, ipNet) + + labels := bgp.NewMPLSLabelStack(100, 200) + _, n3, _ := net.ParseCIDR("30.30.30.0/24") + ipNet = nlriToIPNet(bgp.NewLabeledIPAddrPrefix(24, "30.30.30.0", *labels)) + assert.Equal(t, n3, ipNet) + + _, n4, _ := net.ParseCIDR("2806:106e:19::/48") + ipNet = nlriToIPNet(bgp.NewLabeledIPv6AddrPrefix(48, "2806:106e:19::", *labels)) + assert.Equal(t, n4, ipNet) +} |