0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 01:31:55 +00:00

ROA: Extended and more thorough test

There was a suspicion that maybe the BIRD 3 version of ROA gets the
digesting wrong. This test covers the nastiest cornercases we could
think about, so now we can expect it to be right.
This commit is contained in:
Katerina Kubecova 2024-12-13 16:16:59 +01:00 committed by Maria Matejka
parent f2925d15fc
commit 4c3ac54ee3

View File

@ -2414,6 +2414,141 @@ prefix pfx;
bt_test_suite(t_roa_check, "Testing ROA");
roa6 table r61;
protocol static
{
roa6 { table r61; import filter roa_filter; };
route 2001:0db8::/32 max 35 as 1000;
route 2001:0db8::/32 max 40 as 1001;
route 2001:0db8::/34 max 38 as 1002;
route 2001:0db8::/33 max 36 as 1003;
route 2001:0db8::/36 max 36 as 1004;
route 2001:0db8:c000::/34 max 38 as 1005;
}
function t_roa_subprefix_check()
{
bt_assert(roa_check(r61, 2001:0db8::/31, 1000) = ROA_UNKNOWN);
bt_assert(roa_check(r61, 2001:0db8::/32, 1000) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/33, 1000) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/35, 1000) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/36, 1000) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:8000::/33, 1000) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:c000::/34, 1000) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:e000::/35, 1000) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:f000::/36, 1000) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/31, 1001) = ROA_UNKNOWN);
bt_assert(roa_check(r61, 2001:0db8::/32, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/33, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/34, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/35, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/36, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/37, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/38, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/39, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/40, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/41, 1001) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:8000::/33, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:c000::/34, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:e000::/35, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:f000::/36, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:f800::/37, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:fc00::/38, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:fe00::/39, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:ff00::/40, 1001) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:ff80::/41, 1001) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/31, 1002) = ROA_UNKNOWN);
bt_assert(roa_check(r61, 2001:0db8::/32, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/33, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/34, 1002) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/35, 1002) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/36, 1002) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/37, 1002) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/38, 1002) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/39, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/40, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/41, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:8000::/33, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:c000::/34, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:e000::/35, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:f000::/36, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:f800::/37, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:fc00::/38, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:fe00::/39, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:ff00::/40, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:ff80::/41, 1002) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/31, 1003) = ROA_UNKNOWN);
bt_assert(roa_check(r61, 2001:0db8::/32, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/33, 1003) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/34, 1003) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/35, 1003) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/36, 1003) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/37, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/38, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/39, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/40, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/41, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:8000::/33, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:c000::/34, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:e000::/35, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:f000::/36, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:f800::/37, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:fc00::/38, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:fe00::/39, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:ff00::/40, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:ff80::/41, 1003) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/31, 1004) = ROA_UNKNOWN);
bt_assert(roa_check(r61, 2001:0db8::/32, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/33, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/34, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/35, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/36, 1004) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8::/37, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/38, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/39, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/40, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/41, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:8000::/33, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:c000::/34, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:e000::/35, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:f000::/36, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:f800::/37, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:fc00::/38, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:fe00::/39, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:ff00::/40, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:ff80::/41, 1004) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/31, 1005) = ROA_UNKNOWN);
bt_assert(roa_check(r61, 2001:0db8::/32, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/33, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/34, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/35, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/36, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/37, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/38, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/39, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/40, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8::/41, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:8000::/33, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:c000::/34, 1005) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:e000::/35, 1005) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:f000::/36, 1005) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:f800::/37, 1005) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:fc00::/38, 1005) = ROA_VALID);
bt_assert(roa_check(r61, 2001:0db8:fe00::/39, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:ff00::/40, 1005) = ROA_INVALID);
bt_assert(roa_check(r61, 2001:0db8:ff80::/41, 1005) = ROA_INVALID);
}
bt_test_suite(t_roa_subprefix_check, "Testing ROA subprefixes");
aspa table at;
protocol static