ncsid: UpdateIP should not add the nul address
It's technically safe, but it produces errors unnecessarily.
Change-Id: I48aee2560f9bf58553147febe6b3abaf49c7414d
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/.beautysh-ignore b/.beautysh-ignore
new file mode 100644
index 0000000..1875ac4
--- /dev/null
+++ b/.beautysh-ignore
@@ -0,0 +1 @@
+subprojects/ncsid/src/ncsid_lib.sh
diff --git a/subprojects/ncsid/src/ncsid_lib.sh b/subprojects/ncsid/src/ncsid_lib.sh
index 52c73d0..fd7c998 100644
--- a/subprojects/ncsid/src/ncsid_lib.sh
+++ b/subprojects/ncsid/src/ncsid_lib.sh
@@ -346,7 +346,7 @@
function UpdateIP() {
local service="$1"
local netdev="$2"
- local ip="$3"
+ local ip="$(normalize_ip $3)"
local prefix="$4"
local should_add=1
@@ -356,7 +356,7 @@
while read entry; do
eval "$(echo "$entry" | JSONToVars)" || return $?
eval "$(GetIP "$service" "$object" | JSONToVars)" || return $?
- if [ "$(normalize_ip "$Address")" = "$(normalize_ip "$ip")" ] && \
+ if [ "$(normalize_ip "$Address")" = "$ip" ] && \
[ "$PrefixLength" = "$prefix" ]; then
should_add=0
elif MatchingAF "$ip" "$Address"; then
@@ -371,6 +371,11 @@
DeleteObject "${delete_services[$i]}" "${delete_objects[$i]}" || true
done
+ # The default address is treated as a delete only request
+ if [ "$ip" = :: -o "$ip" = 0.0.0.0 ]; then
+ return
+ fi
+
if (( should_add == 0 )); then
echo "Not adding IP: $ip/$prefix" >&2
else