From e480068262528c9d60222c57109b432f5263826f Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 18 Oct 2017 16:09:22 +0200 Subject: netns: use read built-in instead of ncat hack for dmesg This misses lines that are greater than 128 bytes -- read returns -EINVAL -- but the lines we care about anyway are less than that, so we simply keep looping and skip the bad reads when this happens. Not ideal, but probably the best we can do in pure bash. And, importantly, it's much better than streaming this over a TCP socket, which was an even uglier hack. --- src/tests/netns.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/tests/netns.sh') diff --git a/src/tests/netns.sh b/src/tests/netns.sh index 2d77479..1aa741d 100755 --- a/src/tests/netns.sh +++ b/src/tests/netns.sh @@ -412,12 +412,10 @@ ip0 link del wg0 ! n0 wg show doesnotexist || false declare -A objects -n0 ncat -i 1 -l -p 1111 < /dev/kmsg & -waitncattcp $netns0 -while read -r line; do +while read -t 0.1 -r line 2>/dev/null || [[ $? -ne 142 ]]; do [[ $line =~ .*(wg[0-9]+:\ [A-Z][a-z]+\ [0-9]+)\ .*(created|destroyed).* ]] || continue objects["${BASH_REMATCH[1]}"]+="${BASH_REMATCH[2]}" -done < <(n0 ncat -i 1 127.0.0.1 1111) +done < /dev/kmsg alldeleted=1 for object in "${!objects[@]}"; do if [[ ${objects["$object"]} != *createddestroyed ]]; then -- cgit v1.2.3-59-g8ed1b