From: Matt Corallo Date: Tue, 9 Jul 2024 18:45:34 +0000 (+0000) Subject: Don't spuriously error printing drop counts when there are no rules X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=1a37034c514fd3c131a1060b9a0802e1d0897538;p=flowspec-xdp Don't spuriously error printing drop counts when there are no rules --- diff --git a/dropcount.sh b/dropcount.sh index 6278955..6960ef9 100755 --- a/dropcount.sh +++ b/dropcount.sh @@ -34,8 +34,10 @@ echo "$MAP_CONTENTS" | { echo -e "${PACKETS[2]}\t$(( ${BYTES[2]} / 1000 ))\tInvalid/rejected IHL IPv4 field" echo -e "${PACKETS[3]}\t$(( ${BYTES[3]} / 1000 ))\tRejected IPv6 fragments" C=4 - while read LINE; do - echo -e "${PACKETS["$C"]}\t$(( ${BYTES["$C"]} / 1000 ))\t$LINE" - C=$(( $C + 1 )) - done < "$(dirname ${BASH_SOURCE[0]})/installed-rules.txt" + if [ "$(wc -l "$(dirname ${BASH_SOURCE[0]})/installed-rules.txt")" != "0" ]; then + while read LINE; do + echo -e "${PACKETS["$C"]}\t$(( ${BYTES["$C"]} / 1000 ))\t$LINE" + C=$(( $C + 1 )) + done < "$(dirname ${BASH_SOURCE[0]})/installed-rules.txt" + fi }