From c9d11e6230c49cdfd1f17829be0e877aba05e90b Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Thu, 26 Mar 2020 04:53:23 +0100 Subject: [PATCH] Filter: Remove mixed address tests and fix formatting --- filter/test.conf | 42 +++++++----------------------------------- filter/trie.c | 4 ++-- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/filter/test.conf b/filter/test.conf index d0941e11..634816fd 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -380,6 +380,9 @@ function t_enum() { bt_assert(format(RTS_DUMMY) = "(enum 30)0"); bt_assert(format(RTS_STATIC) = "(enum 30)1"); + bt_assert(format(NET_IP4) = "(enum 36)1"); + bt_assert(format(NET_VPN6) = "(enum 36)4"); + bt_assert(RTS_STATIC ~ [RTS_STATIC, RTS_DEVICE]); bt_assert(RTS_BGP !~ [RTS_STATIC, RTS_DEVICE]); } @@ -458,7 +461,8 @@ function t_prefix_set() prefix set pxs; { pxs = [ 1.2.0.0/16, 1.4.0.0/16+, 44.66.88.64/30{24,28}, 12.34.56.0/24{8,16} ]; - bt_assert(format(pxs) = "[1.2.0.0/112{::0.1.0.0}, 1.4.0.0/112{::0.1.255.255}, 12.34.0.0/112{::1.255.0.0}, 44.66.88.64/124{::1f0}]"); + bt_assert(format(pxs) = "[1.2.0.0/16{0.1.0.0}, 1.4.0.0/16{0.1.255.255}, 12.34.0.0/16{1.255.0.0}, 44.66.88.64/28{0.0.1.240}]"); + bt_assert(1.2.0.0/16 ~ pxs); bt_assert(1.4.0.0/16 ~ pxs); bt_assert(1.4.0.0/18 ~ pxs); @@ -1038,6 +1042,7 @@ rd x; bt_assert(x != 2:12345:20000); bt_assert(!(x > 12345:200010)); + bt_assert(format(0:1:2) = "1:2"); bt_assert(format(10.0.0.1:1000) = "10.0.0.1:1000"); bt_assert(format(100000:20000) = "100000:20000"); bt_assert(format(2:100000:20000) = "100000:20000"); @@ -1247,7 +1252,7 @@ int j; filter roa_filter { - if net ~ [ 10.0.0.0/8{16,24}, 2000::/3{16,96} ] then { + if net ~ [ 10.0.0.0/8{16,24} ] || net ~ [ 2000::/3{16,96} ] then { accept; } reject; @@ -1333,39 +1338,6 @@ bt_test_suite(t_roa_check, "Testing ROA"); -/* - * Testing Mixed Net Types - * ----------------------- - */ - -function t_mixed_prefix() -prefix set pxs; -prefix set pxt; -{ - pxs = [ 98.45.0.0/16, 128.128.0.0/12+, 2200::/42-, ::ffff:d000:0/100{98,102}]; - bt_assert(format(pxs) = "[::/0, ::/2{c000::}, 98.45.0.0/112{::0.1.0.0}, 128.128.0.0/108{::0.31.255.255}, 208.0.0.0/100{::124.0.0.0}, 2200::/42{ffff:ffff:ffc0::}]"); - bt_assert(::fe00:0:0/88 !~ pxs); - bt_assert(::fffe:0:0/95 !~ pxs); - bt_assert(::ffff:d800:0/101 ~ pxs); - bt_assert(216.0.0.0/5 ~ pxs); - bt_assert(212.0.0.0/6 ~ pxs); - bt_assert(212.0.0.0/7 !~ pxs); - bt_assert(::ffff:8080:8080/121 ~ pxs); - bt_assert(::/0 ~ pxs); - bt_assert(0.0.0.0/0 !~ pxs); - bt_assert(128.135.64.17/32 ~ pxs); - -# pxt = [ 0:1:2 10.1.10.0/24, 0:5:10000 10.1.10.0/24 ]; -# print pxt; - - bt_assert(format(NET_IP4) = "(enum 36)1"); ## if (net.type = NET_IP4) ... - bt_assert(format(NET_VPN6) = "(enum 36)4"); - bt_assert(format(0:1:2) = "1:2"); -} - -bt_test_suite(t_mixed_prefix, "Testing mixed net types"); - - filter vpn_filter { bt_assert(format(net) = "1:2 10.1.10.0/24"); diff --git a/filter/trie.c b/filter/trie.c index a0deeaa1..1a4e1ac3 100644 --- a/filter/trie.c +++ b/filter/trie.c @@ -438,7 +438,7 @@ trie_node_format4(const struct f_trie_node4 *t, buffer *buf) return; if (ip4_nonzero(t->accept)) - buffer_print(buf, "%4I/%d{%4I}, ", t->addr, t->plen, t->accept); + buffer_print(buf, "%I4/%d{%I4}, ", t->addr, t->plen, t->accept); trie_node_format4(t->c[0], buf); trie_node_format4(t->c[1], buf); @@ -451,7 +451,7 @@ trie_node_format6(const struct f_trie_node6 *t, buffer *buf) return; if (ip6_nonzero(t->accept)) - buffer_print(buf, "%6I/%d{%6I}, ", t->addr, t->plen, t->accept); + buffer_print(buf, "%I6/%d{%I6}, ", t->addr, t->plen, t->accept); trie_node_format6(t->c[0], buf); trie_node_format6(t->c[1], buf);