aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tests/netns.sh
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
commite480068262528c9d60222c57109b432f5263826f (patch)
treea532e45ed09f0d231acd13547ce1a140e46d661b /src/tests/netns.sh
parentversion: bump snapshot (diff)
downloadwireguard-monolithic-historical-e480068262528c9d60222c57109b432f5263826f.tar.xz
wireguard-monolithic-historical-e480068262528c9d60222c57109b432f5263826f.zip
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.
Diffstat (limited to 'src/tests/netns.sh')
-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