aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
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-23 00:44:41 +0200
commit5b73fb10f42a32a9b6e3a6212027660bcd2ca928 (patch)
treee845278c814d493c7dd61ba6ceb749ce7b4c691d /src
parentcompat: these patches will soon work their way into stable (diff)
downloadwireguard-monolithic-historical-5b73fb10f42a32a9b6e3a6212027660bcd2ca928.tar.xz
wireguard-monolithic-historical-5b73fb10f42a32a9b6e3a6212027660bcd2ca928.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')
-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