| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
RULESET="table ip t { |
| 4 |
set s { |
| 5 |
type mark |
| 6 |
flags interval |
| 7 |
elements = { |
| 8 |
0x23-0x42, 0x1337 |
| 9 |
} |
| 10 |
} |
| 11 |
}" |
| 12 |
|
| 13 |
$NFT -f - <<< "$RULESET" || { echo "can't apply basic ruleset"; exit 1; } |
| 14 |
|
| 15 |
$NFT get element ip t s '{ 0x23-0x42 }' || { |
| 16 |
echo "can't find existing range 0x23-0x42" |
| 17 |
exit 1 |
| 18 |
} |
| 19 |
|
| 20 |
$NFT get element ip t s '{ 0x26-0x28 }' || { |
| 21 |
echo "can't find existing sub-range 0x26-0x28" |
| 22 |
exit 1 |
| 23 |
} |
| 24 |
|
| 25 |
$NFT get element ip t s '{ 0x26-0x99 }' && { |
| 26 |
echo "found non-existing range 0x26-0x99" |
| 27 |
exit 1 |
| 28 |
} |
| 29 |
|
| 30 |
$NFT get element ip t s '{ 0x55-0x99 }' && { |
| 31 |
echo "found non-existing range 0x55-0x99" |
| 32 |
exit 1 |
| 33 |
} |
| 34 |
|
| 35 |
$NFT get element ip t s '{ 0x55 }' && { |
| 36 |
echo "found non-existing element 0x55" |
| 37 |
exit 1 |
| 38 |
} |
| 39 |
|
| 40 |
$NFT get element ip t s '{ 0x1337 }' || { |
| 41 |
echo "can't find existing element 0x1337" |
| 42 |
exit 1 |
| 43 |
} |