]> git.bitcoin.ninja Git - flowspec-xdp/commitdiff
Don't spuriously error printing drop counts when there are no rules
authorMatt Corallo <git@bluematt.me>
Tue, 9 Jul 2024 18:45:34 +0000 (18:45 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 9 Jul 2024 18:45:34 +0000 (18:45 +0000)
dropcount.sh

index 6278955bb1e967fb60eeb846647c7632a0cfea8f..6960ef9b15c7bed89e050cf39036bfa4d0f0cb52 100755 (executable)
@@ -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
 }