1#!/bin/sh 2 3case "$XT_MULTI" in 4*xtables-nft-multi) 5 ;; 6*) 7 echo "skip $XT_MULTI" 8 exit 0 9 ;; 10esac 11 12get_entries_count() { # (chain) 13 $XT_MULTI ebtables -L $1 | sed -n 's/.*entries: \([0-9]*\).*/\1/p' 14} 15 16set -x 17 18for t in filter nat;do 19 $XT_MULTI ebtables -t $t -L || exit 1 20 $XT_MULTI ebtables -t $t -X || exit 1 21 $XT_MULTI ebtables -t $t -F || exit 1 22done 23 24for t in broute foobar ;do 25 $XT_MULTI ebtables -t $t -L && 26 $XT_MULTI ebtables -t $t -X && 27 $XT_MULTI ebtables -t $t -F 28 if [ $? -eq 0 ]; then 29 echo "Expect nonzero return for unsupported table" 30 exit 1 31 fi 32done 33 34 35$XT_MULTI ebtables -t filter -N FOO || exit 1 36$XT_MULTI ebtables -t filter -N FOO 37if [ $? -eq 0 ]; then 38 echo "Duplicate chain FOO" 39 $XT_MULTI ebtables -t filter -L 40 exit 1 41fi 42 43entries=$(get_entries_count FOO) 44if [ $entries -ne 0 ]; then 45 echo "Unexpected entries count in empty unreferenced chain (expected 0, have $entries)" 46 $XT_MULTI ebtables -L 47 exit 1 48fi 49 50$XT_MULTI ebtables -A FORWARD -j FOO 51entries=$(get_entries_count FORWARD) 52if [ $entries -ne 1 ]; then 53 echo "Unexpected entries count in FORWARD chain (expected 1, have $entries)" 54 $XT_MULTI ebtables -L 55 exit 1 56fi 57 58entries=$(get_entries_count FOO) 59if [ $entries -ne 0 ]; then 60 echo "Unexpected entries count in empty referenced chain (expected 0, have $entries)" 61 $XT_MULTI ebtables -L 62 exit 1 63fi 64 65$XT_MULTI ebtables -A FOO -j ACCEPT 66entries=$(get_entries_count FOO) 67if [ $entries -ne 1 ]; then 68 echo "Unexpected entries count in non-empty referenced chain (expected 1, have $entries)" 69 $XT_MULTI ebtables -L 70 exit 1 71fi 72 73$XT_MULTI ebtables -t filter -N BAR || exit 1 74$XT_MULTI ebtables -t filter -N BAZ || exit 1 75 76$XT_MULTI ebtables -t filter -L | grep -q FOO || exit 1 77$XT_MULTI ebtables -t filter -L | grep -q BAR || exit 1 78$XT_MULTI ebtables -t filter -L | grep -q BAZ || exit 1 79 80$XT_MULTI ebtables -t filter -L BAZ || exit 1 81$XT_MULTI ebtables -t filter -X BAZ || exit 1 82$XT_MULTI ebtables -t filter -L BAZ | grep -q BAZ 83if [ $? -eq 0 ]; then 84 echo "Deleted chain -L BAZ ok, expected failure" 85 $XT_MULTI ebtables -t filter -L 86 exit 1 87fi 88 89$XT_MULTI ebtables -t filter -E FOO BAZ || exit 1 90$XT_MULTI ebtables -t filter -L | grep -q FOO && exit 1 91$XT_MULTI ebtables -t filter -L | grep -q BAZ || exit 1 92 93$XT_MULTI ebtables -t $t -F || exit 0 94