#!/bin/bash # NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr) test_set_stmt() { local i=$1 local stmt1=$2 local stmt2=$3 RULESET="table x { set y$i { type ipv4_addr $stmt1 elements = { 5.5.5.$i $stmt1, 6.6.6.$i $stmt2 } } chain y$i { ip daddr @y$i } }" $NFT -f - <<< $RULESET # should work if [ $? -ne 0 ] then exit 1 fi # should work $NFT add element x y$i { 2.2.2.$i $stmt2 } if [ $? -ne 0 ] then exit 1 fi # should work $NFT add element x y$i { 3.3.3.$i } if [ $? -ne 0 ] then exit 1 fi } test_set_stmt "0" "counter packets 1 bytes 2" "counter packets 3 bytes 4" test_set_stmt "1" "limit rate 1/second" "limit rate 5/second" test_set_stmt "2" "ct count over 2" "ct count over 5" test_set_stmt "3" "last" "last" test_set_stmt "4" "quota over 1000 bytes" "quota over 30000 bytes used 1000 bytes" exit 0