summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-18 16:09:22 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-31 16:21:54 +0100
commitc4974e7c3c948d692be397448698d0d3c0670704 (patch)
tree81b979e572c5a9f225389cb95243dc2cf3a83e82
parentd0646b6d88ca54240c61f36255d5684904ca98c3 (diff)
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. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rwxr-xr-xsrc/tests/netns.sh6
1 files changed, 2 insertions, 4 deletions
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