From f686a17eafa0bb5e9b0665c646fac09c9f95c0a5 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sat, 11 Mar 2017 14:31:39 +0100 Subject: fib: Support existence check This allows to check whether a FIB entry exists for a given packet by comparing the expression with a boolean keyword like so: | fib daddr oif exists The implementation requires introduction of a generic expression flag EXPR_F_BOOLEAN which allows relational expression to signal it's LHS that a boolean comparison is being done (indicated by boolean type on RHS). In contrast to exthdr existence checks, fib expression can't know this in beforehand because the LHS syntax is absolutely identical to a non-boolean comparison. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- tests/py/inet/fib.t | 3 +++ tests/py/inet/fib.t.payload | 10 ++++++++++ 2 files changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/py/inet/fib.t b/tests/py/inet/fib.t index 9ee282ab..dbe45d95 100644 --- a/tests/py/inet/fib.t +++ b/tests/py/inet/fib.t @@ -12,3 +12,6 @@ fib saddr . iif oifname "lo";ok fib daddr . iif type local;ok fib daddr . iif type vmap { blackhole : drop, prohibit : drop, unicast : accept };ok fib daddr . oif type local;fail + +fib daddr oif exists;ok +fib daddr oif missing;ok diff --git a/tests/py/inet/fib.t.payload b/tests/py/inet/fib.t.payload index f5258165..1d4c3d94 100644 --- a/tests/py/inet/fib.t.payload +++ b/tests/py/inet/fib.t.payload @@ -20,3 +20,13 @@ __map%d test-ip 0 ip test-ip prerouting [ fib daddr . iif type => reg 1 ] [ lookup reg 1 set __map%d dreg 0 ] + +# fib daddr oif exists +ip test-ip prerouting + [ fib daddr oif present => reg 1 ] + [ cmp eq reg 1 0x00000001 ] + +# fib daddr oif missing +ip test-ip prerouting + [ fib daddr oif present => reg 1 ] + [ cmp eq reg 1 0x00000000 ] -- cgit v1.2.3