meta-google: gbmc-bridge: fix ip check
We want to priortize stateful ip, the current code is buggy and ip
was randomly selected between stateful and stateless.
Tested: locally verified that the ip check logic is expected.
gbmc-ip-monitor.sh[9646]: stateful 2607:f8b0:809e:446:fd02::
gbmc-ip-monitor.sh[9646]: gBMC Bridge Updating GW source [2607:f8b0:809e:446:fd02::]: default via fe80::2695:2fff:fec2:d3c dev gbmcbr proto ra metric 1056 pref medium
gbmc-ip-monitor.sh[9646]: 2607:f8b0:809e:446:fd00:5c33:7bbb:394a and 2607:f8b0:809e:446:fd02::
gbmc-ip-monitor.sh[9646]: stateful exist 2607:f8b0:809e:446:fd02::
Change-Id: I9ae8f675e5dc50d62941fb177966d4c5062c370e
Signed-off-by: Yuxiao Zhang <yuxiaozhang@google.com>
diff --git a/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-gw-src.sh b/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-gw-src.sh
index 693c728..dbf2157 100644
--- a/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-gw-src.sh
+++ b/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-gw-src.sh
@@ -94,10 +94,10 @@
return 1
fi
# Ignore ULAs and non-gBMC addresses
- if (( ip_bytes[0] & 0xfe == 0xfc || ip_bytes[8] != 0xfd )); then
+ if (( (ip_bytes[0] & 0xfe) == 0xfc || ip_bytes[8] != 0xfd )); then
return 0
fi
- if (( ip_bytes[9] & 0x0f != 0 )); then
+ if (( (ip_bytes[9] & 0x0f) != 0 )); then
local -n gbmc_br_gw_src_ip=gbmc_br_gw_src_ip_stateful
else
local -n gbmc_br_gw_src_ip=gbmc_br_gw_src_ip_stateless