rt: update test scripts and fix documentation
PATCH 1/1 rt: update test scripts and fix documentation
From: Anders K. Pedersen <[email protected]>
Replace tests/files/expr-rt with Python based tests, and replace ether type with meta nfproto, which generates a bit fewer instructions.
--- doc/nft.xml | 6 +++--- src/evaluate.c | 4 ++-- tests/files/expr-rt | 21 --------------------- tests/py/any/rt.t | 7 +++++++ tests/py/any/rt.t.payload | 5 +++++ tests/py/inet/rt.t | 8 ++++++++ tests/py/inet/rt.t.payload | 14 ++++++++++++++ tests/py/ip/rt.t | 6 ++++++ tests/py/ip/rt.t.payload | 5 +++++ tests/py/ip6/rt0.t | 6 ++++++ tests/py/ip6/rt0.t.payload | 5 +++++ 11 files changed, 61 insertions(+), 26 deletions(-)
doc/nft.xml +3 -3
@@ -1315,7 +1315,7 @@ filter prerouting meta mark set 0xdead fib daddr . mark type vmap { backhole : d <para> <table frame="all"> <title>Routing expression types</title> - <tgroup cols='4' align='left' colsep='1' rowsep='1'> + <tgroup cols='3' align='left' colsep='1' rowsep='1'> <colspec colname='c1'/> <colspec colname='c2'/> <colspec colname='c3'/>
@@ -1375,8 +1375,8 @@ filter output rt classid 10 # IP family dependent rt expressions ip filter output rt nexthop 192.168.0.1 ip6 filter output rt nexthop fd00::1 -inet filter ether type ip output rt nexthop 192.168.0.1 -inet filter ether type ip6 output rt nexthop fd00::1 +inet filter meta nfproto ipv4 output rt nexthop 192.168.0.1 +inet filter meta nfproto ipv6 output rt nexthop fd00::1 </programlisting> </example> </para>
src/evaluate.c +2 -2
@@ -639,8 +639,8 @@ static int expr_evaluate_rt(struct eval_ctx *ctx, struct expr **expr) err:return expr_error (ctx->msgs, rt, -"ether type ip or ip6 must be specified before " -"routing expression" ); +"meta nfproto ipv4 or ipv6 must be specified " +"before routing expression" ); }/*
tests/files/expr-rt deleted +0 -21
@@ -1,21 +0,0 @@ -#! nft -f - -add table ip filter -add chain ip filter output { type filter hook output priority 0 ; } - -add table ip6 filter -add chain ip6 filter output { type filter hook output priority 0 ; } - -add table inet filter -add chain inet filter output { type filter hook output priority 0 ; } - -# rt: classid (see /etc/iproute2/rt_realms) -add rule ip filter output rt classid cosmos counter -add rule ip6 filter output rt classid cosmos counter -add rule inet filter output rt classid cosmos counter - -# rt: nexthop -add rule ip filter output rt nexthop 192.168.0.1 counter -add rule ip6 filter output rt nexthop fd00::1 counter -add rule inet filter output ether type ip rt nexthop 192.168.0.1 counter -add rule inet filter output ether type ip6 rt nexthop fd00::1 counter
tests/py/any/rt.t new file +7 -0
@@ -0,0 +1,7 @@ +:output;type filter hook input priority 0 + +*ip;test-ip4;output +*ip6;test-ip6;output +*inet;test-inet;output + +rt classid "cosmos";ok
tests/py/any/rt.t.payload new file +5 -0
@@ -0,0 +1,5 @@ +# rt classid "cosmos" +ip test-ip4 input + [ rt load classid => reg 1 ] + [ cmp eq reg 1 0x00000000 ] +
tests/py/inet/rt.t new file +8 -0
@@ -0,0 +1,8 @@ +:output;type filter hook input priority 0 + +*inet;test-inet;output + +rt nexthop 192.168.0.1;fail +rt nexthop fd00::1;fail +meta nfproto ipv4 rt nexthop 192.168.0.1;ok +meta nfproto ipv6 rt nexthop fd00::1;ok
tests/py/inet/rt.t.payload new file +14 -0
@@ -0,0 +1,14 @@ +# meta nfproto ipv4 rt nexthop 192.168.0.1 +inet test-inet output + [ meta load nfproto => reg 1 ] + [ cmp eq reg 1 0x00000002 ] + [ rt load nexthop4 => reg 1 ] + [ cmp eq reg 1 0x0100a8c0 ] + +# meta nfproto ipv6 rt nexthop fd00::1 +inet test-inet output + [ meta load nfproto => reg 1 ] + [ cmp eq reg 1 0x0000000a ] + [ rt load nexthop6 => reg 1 ] + [ cmp eq reg 1 0x000000fd 0x00000000 0x00000000 0x01000000 ] +
tests/py/ip/rt.t new file +6 -0
@@ -0,0 +1,6 @@ +:output;type filter hook input priority 0 + +*ip;test-ip4;output + +rt nexthop 192.168.0.1;ok +rt nexthop fd00::1;fail
tests/py/ip/rt.t.payload new file +5 -0
@@ -0,0 +1,5 @@ +# rt nexthop 192.168.0.1 +ip test-ip4 output + [ rt load nexthop4 => reg 1 ] + [ cmp eq reg 1 0x0100a8c0 ] +
tests/py/ip6/rt0.t new file +6 -0
@@ -0,0 +1,6 @@ +:output;type filter hook input priority 0 + +*ip6;test-ip6;output + +rt nexthop 192.168.0.1;fail +rt nexthop fd00::1;ok
tests/py/ip6/rt0.t.payload new file +5 -0
@@ -0,0 +1,5 @@ +# rt nexthop fd00::1 +ip6 test-ip6 output + [ rt load nexthop6 => reg 1 ] + [ cmp eq reg 1 0x000000fd 0x00000000 0x00000000 0x01000000 ] +
Florian Westphal
maintainerQuoted 4 lines · Anders K. Pedersen | Cohaesio
Replace tests/files/expr-rt with Python based tests, and replace ether type with meta nfproto, which generates a bit fewer instructions.
Signed-off-by Anders K. Pedersen <[email protected]>
Quoted 12 lines
--- doc/nft.xml | 6 +++--- src/evaluate.c | 4 ++-- tests/files/expr-rt | 21 --------------------- tests/py/any/rt.t | 7 +++++++ tests/py/any/rt.t.payload | 5 +++++ tests/py/inet/rt.t | 8 ++++++++ tests/py/inet/rt.t.payload | 14 ++++++++++++++ tests/py/ip/rt.t | 6 ++++++ tests/py/ip/rt.t.payload | 5 +++++ tests/py/ip6/rt0.t | 6 ++++++ tests/py/ip6/rt0.t.payload | 5 +++++
Why rt0.t and not ip6/rt.t? (I can fix this locally, no need to resend)
Florian Westphal
maintainerQuoted 18 lines · Florian Westphal
Quoted 4 lines · Anders K. Pedersen | Cohaesio
Replace tests/files/expr-rt with Python based tests, and replace ether type with meta nfproto, which generates a bit fewer instructions.
Signed-off-by Anders K. Pedersen <[email protected]>Quoted 12 lines
--- doc/nft.xml | 6 +++--- src/evaluate.c | 4 ++-- tests/files/expr-rt | 21 --------------------- tests/py/any/rt.t | 7 +++++++ tests/py/any/rt.t.payload | 5 +++++ tests/py/inet/rt.t | 8 ++++++++ tests/py/inet/rt.t.payload | 14 ++++++++++++++ tests/py/ip/rt.t | 6 ++++++ tests/py/ip/rt.t.payload | 5 +++++ tests/py/ip6/rt0.t | 6 ++++++ tests/py/ip6/rt0.t.payload | 5 +++++
Quoted 1 line
Why rt0.t and not ip6/rt.t? (I can fix this locally, no need to resend)
To answer my own question: because ip6/rt.t already exists but tests something different.
I pushed this patch, thanks.