From: Martin Schwenke Date: Mon, 7 Mar 2016 23:03:12 +0000 (+1100) Subject: ctdb-tests: Allow tcptickle_sniff_wait_show() to filter by MAC address X-Git-Tag: tdb-1.3.9~457 X-Git-Url: http://git.samba.org/samba.git/?a=commitdiff_plain;h=6b51ea35fdc25aa5109e8c9f4596e346832acd95;p=sfrench%2Fsamba-autobuild%2F.git ctdb-tests: Allow tcptickle_sniff_wait_show() to filter by MAC address tcpdump does not support filtering on MAC address when reading from a file. Therefore, this is implemented by conditionally using grep to filter the output of tcpdump. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/complex/scripts/local.bash b/ctdb/tests/complex/scripts/local.bash index 103a71f5919..7787de8f111 100644 --- a/ctdb/tests/complex/scripts/local.bash +++ b/ctdb/tests/complex/scripts/local.bash @@ -126,8 +126,23 @@ tcpdump_wait () tcpdump_check () { - local found=$(tcpdump -n -r $tcpdump_filename \ - "$filter" 2>/dev/null | wc -l) + # It would be much nicer to add "ether src + # $releasing_mac" to the filter. However, tcpdump + # does not allow MAC filtering unless an ethernet + # interface is specified with -i. It doesn't work + # with "-i any" and it doesn't work when reading from + # a file. :-( + local found + if [ -n "$releasing_mac" ] ; then + found=$(tcpdump -n -e -r "$tcpdump_filename" \ + "$filter" 2>/dev/null | + grep -c "In ${releasing_mac}") + else + found=$(tcpdump -n -e -r "$tcpdump_filename" \ + "$filter" 2>/dev/null | + wc -l) + fi + [ $found -ge $count ] } @@ -196,6 +211,8 @@ tcptickle_sniff_start () tcptickle_sniff_wait_show () { + local releasing_mac="$1" # optional, used by tcpdump_wait() + tcpdump_wait 1 "$tcptickle_reset" echo "GOOD: here are some TCP tickle packets:"