ncsid: update_ra_gw: Improve gateway discovery speed
The rdisc6 binary when run in a subshell buffers all of the output
instead of sending each line. This results in a long delay to figure out
the gateway address.
We can fix this by running it through `script`, which removes the
buffering and allows us to nearly instantly update our route.
Tested: Ran on our AMD Rome system and verified that the gateway was
quickly being updated.
Change-Id: I22350d6bd95665ab853c3f1273c0d6e4ff60718e
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/subprojects/ncsid/src/update_ra_gw.sh b/subprojects/ncsid/src/update_ra_gw.sh
index 84be9ef..9403b28 100644
--- a/subprojects/ncsid/src/update_ra_gw.sh
+++ b/subprojects/ncsid/src/update_ra_gw.sh
@@ -67,6 +67,8 @@
args+=(-d)
fi
while read line; do
+ # `script` terminates all lines with a CRLF, remove it
+ line="${line:0:-1}"
if [ -z "$line" ]; then
lifetime=
mac=
@@ -81,7 +83,7 @@
mac=
rtr=
fi
- done < <(exec rdisc6 "${args[@]}" 2>/dev/null)
+ done < <(exec script -q -c "rdisc6 ${args[*]}" /dev/null 2>/dev/null)
# If rdisc6 exits early we still want to wait the full `w` time before
# starting again.
(( timeout = start + w - SECONDS ))