summaryrefslogtreecommitdiff
path: root/meta-google
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2023-03-24 12:41:39 +0300
committerWilliam A. Kennington III <wak@google.com>2023-03-25 02:04:01 +0300
commit0e5de5d94982c64a29c418024e708776d811667c (patch)
tree0103fa6e5a26269e5bfd3fc6bab0b7ca8139a044 /meta-google
parent14cc201df2046a622a1c83c85ac2c7d3fd26ae4c (diff)
downloadopenbmc-0e5de5d94982c64a29c418024e708776d811667c.tar.xz
meta-google: gbmc-bridge: Parse link addresses for TERM
We can't look directly at the `/var/google/gbmc-br-ip` file for all platforms, so we need to look up the addresses directly from the bridge interface. Change-Id: Ib2a178e61d413a6e771a80a5b9eb44591daa5b5a Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'meta-google')
-rw-r--r--meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-dhcp-term.sh37
1 files changed, 29 insertions, 8 deletions
diff --git a/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-dhcp-term.sh b/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-dhcp-term.sh
index c3b5a33659..46bf136049 100644
--- a/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-dhcp-term.sh
+++ b/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-dhcp-term.sh
@@ -13,16 +13,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# If we don't have a saved IP, we keep running indefinitely
-if ! srcip="$(cat /var/google/gbmc-br-ip 2>/dev/null)"; then
- echo 'Missing saved gbmc-br IP' >&2
- exit 0
-fi
+# shellcheck source=meta-google/recipes-google/networking/network-sh/lib.sh
+source /usr/share/network/lib.sh || exit
# Wait until a well known service is network available
-echo "Waiting for network reachability" >&2
-while ! ping -I "$srcip" -c 1 -W 1 2001:4860:4860::8888 >/dev/null 2>&1; do
- sleep 1
+echo 'Waiting for network reachability' >&2
+while true; do
+ before=$SECONDS
+ addrs="$(ip addr show gbmcbr | grep '^ *inet6' | awk '{print $2}')"
+ for addr in $addrs; do
+ # Remove the prefix length
+ ip="${addr%/*}"
+ ip_to_bytes ip_bytes "$ip" || continue
+ # Ignore ULAs and non-gBMC addresses
+ (( ip_bytes[0] & 0xfc == 0xfc || ip_bytes[8] != 0xfd )) && continue
+ # Only allow for the short, well known addresses <pfx>:fd01:: and not
+ # <pfx>:fd00:83c1:292d:feef. Otherwise, powercycle may be unavailable.
+ (( ip_bytes[9] == 0 )) && continue
+ for i in {10..15}; do
+ (( ip_bytes[i] != 0 )) && continue 2
+ done
+ echo "Trying reachability from $ip" >&2
+ for i in {0..5}; do
+ ping -I "$ip" -c 1 -W 1 2001:4860:4860::8888 >/dev/null 2>&1 && break 3
+ sleep 1
+ done
+ done
+ # Ensure we only complete the addr lookup loop every 10s
+ tosleep=$((before + 10 - SECONDS))
+ if (( tosleep > 0 )); then
+ sleep $tosleep
+ fi
done
# We need to guarantee we wait at least 5 minutes from reachable in