mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 01:31:55 +00:00
filter/test.conf: add ROA check and operator tests
This commit is contained in:
parent
e58f8c28d2
commit
cd6ca9b1f6
100
filter/test.conf
100
filter/test.conf
@ -59,33 +59,83 @@ function fifteen()
|
||||
return 15;
|
||||
}
|
||||
|
||||
/*
|
||||
roa table rl
|
||||
roa4 table r4;
|
||||
roa6 table r6;
|
||||
|
||||
protocol static
|
||||
{
|
||||
roa 10.110.0.0/16 max 16 as 1000;
|
||||
roa 10.120.0.0/16 max 24 as 1000;
|
||||
roa 10.130.0.0/16 max 24 as 2000;
|
||||
roa 10.130.128.0/18 max 24 as 3000;
|
||||
roa4 { table r4; };
|
||||
route 10.110.0.0/16 max 16 as 1000 blackhole;
|
||||
route 10.120.0.0/16 max 24 as 1000 blackhole ;
|
||||
route 10.130.0.0/16 max 24 as 2000 blackhole;
|
||||
route 10.130.128.0/18 max 24 as 3000 blackhole;
|
||||
}
|
||||
|
||||
function test_roa()
|
||||
protocol static
|
||||
{
|
||||
roa6 { table r6; };
|
||||
route 2001:0db8:85a3:8a2e::/64 max 96 as 1000 blackhole;
|
||||
}
|
||||
|
||||
function test_roa_check()
|
||||
{
|
||||
# cannot be tested in __startup(), sorry
|
||||
print "Testing ROA";
|
||||
print "Should be true: ", roa_check(rl, 10.10.0.0/16, 1000) = ROA_UNKNOWN,
|
||||
" ", roa_check(rl, 10.0.0.0/8, 1000) = ROA_UNKNOWN,
|
||||
" ", roa_check(rl, 10.110.0.0/16, 1000) = ROA_VALID,
|
||||
" ", roa_check(rl, 10.110.0.0/16, 2000) = ROA_INVALID,
|
||||
" ", roa_check(rl, 10.110.32.0/20, 1000) = ROA_INVALID,
|
||||
" ", roa_check(rl, 10.120.32.0/20, 1000) = ROA_VALID;
|
||||
print "Should be true: ", roa_check(rl, 10.120.32.0/20, 2000) = ROA_INVALID,
|
||||
" ", roa_check(rl, 10.120.32.32/28, 1000) = ROA_INVALID,
|
||||
" ", roa_check(rl, 10.130.130.0/24, 1000) = ROA_INVALID,
|
||||
" ", roa_check(rl, 10.130.130.0/24, 2000) = ROA_VALID,
|
||||
" ", roa_check(rl, 10.130.30.0/24, 3000) = ROA_INVALID,
|
||||
" ", roa_check(rl, 10.130.130.0/24, 3000) = ROA_VALID;
|
||||
print "Should be true: ", roa_check(r4, 10.10.0.0/16, 1000) = ROA_UNKNOWN,
|
||||
" ", roa_check(r4, 10.0.0.0/8, 1000) = ROA_UNKNOWN,
|
||||
" ", roa_check(r4, 10.110.0.0/16, 1000) = ROA_VALID,
|
||||
" ", roa_check(r4, 10.110.0.0/16, 2000) = ROA_INVALID,
|
||||
" ", roa_check(r4, 10.110.32.0/20, 1000) = ROA_INVALID,
|
||||
" ", roa_check(r4, 10.120.32.0/20, 1000) = ROA_VALID;
|
||||
print "Should be true: ", roa_check(r4, 10.120.32.0/20, 2000) = ROA_INVALID,
|
||||
" ", roa_check(r4, 10.120.32.32/28, 1000) = ROA_INVALID,
|
||||
" ", roa_check(r4, 10.130.130.0/24, 1000) = ROA_INVALID,
|
||||
" ", roa_check(r4, 10.130.130.0/24, 2000) = ROA_VALID,
|
||||
" ", roa_check(r4, 10.130.30.0/24, 3000) = ROA_INVALID,
|
||||
" ", roa_check(r4, 10.130.130.0/24, 3000) = ROA_VALID;
|
||||
print "Should be true: ", roa_check(r6, 2001:0db8:85a3:8a2e:1234::/80, 1000) = ROA_VALID,
|
||||
" ", roa_check(r6, 2001:0db8:85a3:8a2e:1234::/97, 1000) = ROA_INVALID,
|
||||
" ", roa_check(r6, 2001:0db8:85a3:8a2e::/64, 1000) = ROA_VALID,
|
||||
" ", roa_check(r6, 2001:0db8:85a3::/48, 1000) = ROA_UNKNOWN;
|
||||
|
||||
print "Should be true: ", roa_check(r4, 10.10.0.0/16, 1000) = ROA_UNKNOWN,
|
||||
" ", roa_check(r4, 10.0.0.0/8, 1000) = ROA_UNKNOWN,
|
||||
" ", roa_check(r4, 10.110.0.0/16, 1000) = ROA_VALID,
|
||||
" ", roa_check(r4, 10.110.0.0/16, 2000) = ROA_INVALID,
|
||||
" ", roa_check(r4, 10.110.32.0/20, 1000) = ROA_INVALID,
|
||||
" ", roa_check(r4, 10.120.32.0/20, 1000) = ROA_VALID;
|
||||
|
||||
print "Should be true: ", roa_check(r6, 2001:0db8:85a3:8a2e:1234::/80, 1000) = ROA_VALID,
|
||||
" ", roa_check(r6, 2001:0db8:85a3:8a2e:1234::/97, 1000) = ROA_INVALID,
|
||||
" ", roa_check(r6, 2001:0db8:85a3:8a2e::/64, 1000) = ROA_VALID,
|
||||
" ", roa_check(r6, 2001:0db8:85a3::/48, 1000) = ROA_UNKNOWN;
|
||||
|
||||
print "Should be true: ", roa_check(r4, 2001:0db8:85a3:8a2e:1234::/97, 1000) = ROA_INVALID ||
|
||||
roa_check(r6, 2001:0db8:85a3:8a2e:1234::/97, 1000) = ROA_INVALID;
|
||||
|
||||
print "Should be false: ", roa_check(r4, 2001:0db8:85a3:8a2e:1234::/80, 1000) = ROA_INVALID ||
|
||||
roa_check(r6, 2001:0db8:85a3:8a2e:1234::/80, 1000) = ROA_INVALID,
|
||||
" ", roa_check(r4, 2001:0db8:85a3::/48, 1000) = ROA_INVALID ||
|
||||
roa_check(r6, 2001:0db8:85a3::/48, 1000) = ROA_INVALID;
|
||||
|
||||
print "Should be true: ", 10.130.130.0/24 ~ 0.0.0.0/0,
|
||||
" ", 2001:0db8:85a3:8a2e::/64 ~ ::/0;
|
||||
print "Should be false: ", 10.130.130.0/24 ~ ::/0,
|
||||
" ", 2001:0db8:85a3:8a2e::/64 ~ 0.0.0.0/0;
|
||||
}
|
||||
|
||||
function roa_operators_test()
|
||||
prefix pfx;
|
||||
{
|
||||
print "Testing ROA prefix operators '.maxlen' and '.asn':";
|
||||
|
||||
pfx = 12.13.0.0/16 max 24 as 1234;
|
||||
print pfx;
|
||||
print "Should be true: ", pfx.len = 16, " ", pfx.maxlen = 24, " ", pfx.asn = 1234;
|
||||
|
||||
pfx = 1000::/8 max 32 as 1234;
|
||||
print pfx;
|
||||
print "Should be true: ", pfx.len = 8, " ", pfx.maxlen = 32, " ", pfx.asn = 1234;
|
||||
}
|
||||
*/
|
||||
|
||||
function path_test()
|
||||
bgpmask pm1;
|
||||
@ -202,8 +252,6 @@ eclist el2;
|
||||
print "eclist A union B: ", add( el2, el );
|
||||
print "eclist A isect B: ", filter( el, el2 );
|
||||
print "eclist A \ B: ", delete( el, el2 );
|
||||
|
||||
# test_roa();
|
||||
}
|
||||
|
||||
function bla()
|
||||
@ -387,6 +435,8 @@ string st;
|
||||
test_pxset([ 10.0.0.0/16{8,12}, 20.0.0.0/16{24,28} ]);
|
||||
print "What will this do? ", [ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ];
|
||||
|
||||
roa_operators_test();
|
||||
|
||||
print "Testing functions...";
|
||||
callme ( 1, 2 );
|
||||
callme ( 2, 2 );
|
||||
@ -413,7 +463,9 @@ string st;
|
||||
include "test.conf.inc";
|
||||
|
||||
print "done";
|
||||
quitbird;
|
||||
print "Well, now call from birdc `eval test_roa_check()', please.";
|
||||
return 1;
|
||||
# quitbird;
|
||||
# print "*** FAIL: this is unreachable";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user