| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# test adding many elements to an interval map |
| 4 |
# even with HOWMANY=2 there are memory allocation failures in the current |
| 5 |
# master - the patch fixes that |
| 6 |
# NOTE this is only an issue with two separate nft calls |
| 7 |
|
| 8 |
HOWMANY=2 |
| 9 |
|
| 10 |
tmpfile=$(mktemp) |
| 11 |
if [ ! -w $tmpfile ] ; then |
| 12 |
echo "Failed to create tmp file" >&2 |
| 13 |
exit 0 |
| 14 |
fi |
| 15 |
|
| 16 |
trap "rm -rf $tmpfile" EXIT # cleanup if aborted |
| 17 |
|
| 18 |
generate_add() { |
| 19 |
echo -n "{" |
| 20 |
for ((i=1; i<=HOWMANY; i++)) ; do |
| 21 |
for ((j=1; j<=HOWMANY; j++)) ; do |
| 22 |
[ "$i" == "$HOWMANY" ] && [ "$j" == "$HOWMANY" ] && break |
| 23 |
echo -n "10.${i}.${j}.0/24 : 10.0.${i}.${j}, " |
| 24 |
done |
| 25 |
done |
| 26 |
echo -n "}" |
| 27 |
} |
| 28 |
|
| 29 |
generate_test() { |
| 30 |
count=0 |
| 31 |
elements="" |
| 32 |
for ((i=1; i<=HOWMANY; i++)) ; do |
| 33 |
for ((j=1; j<=HOWMANY; j++)) ; do |
| 34 |
((count++)) |
| 35 |
elements="${elements}10.${i}.${j}.0/24 : 10.0.${i}.${j}" |
| 36 |
[ "$i" == "$HOWMANY" ] && [ "$j" == "$HOWMANY" ] && break |
| 37 |
if [ "$count" == "2" ] ; then |
| 38 |
count=0 |
| 39 |
elements="${elements},\\n\\t\\t\\t " |
| 40 |
else |
| 41 |
elements="${elements}, " |
| 42 |
fi |
| 43 |
done |
| 44 |
done |
| 45 |
echo -e "$elements" |
| 46 |
} |
| 47 |
|
| 48 |
echo "add table x |
| 49 |
add map x y { type ipv4_addr : ipv4_addr; flags interval; } |
| 50 |
add element x y $(generate_add)" > $tmpfile |
| 51 |
|
| 52 |
set -e |
| 53 |
$NFT -f $tmpfile |
| 54 |
|
| 55 |
n=$HOWMANY |
| 56 |
echo "add element x y { 10.${n}.${n}.0/24 : 10.0.${n}.${n} }" > $tmpfile |
| 57 |
|
| 58 |
$NFT -f $tmpfile |