From 4382c5e98994472cbc896c1c241e534e6ef551c3 Mon Sep 17 00:00:00 2001 From: Yuxiao Zhang Date: Fri, 5 May 2023 16:10:16 -0700 Subject: meta-google: gbmc-bridge: skip gbmcbr config if ip does not change GBMC bridge ip is set up via different sources at different moments. This change skips the unnecessary reconfiguration so that the network will be less disturbed. Change-Id: I0ecbad0693398b32037c6be7228444a7d7f89076 Signed-off-by: Yuxiao Zhang --- .../recipes-google/networking/gbmc-bridge/gbmc-br-lib.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'meta-google') diff --git a/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-lib.sh b/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-lib.sh index d3bf95d89b..95516d6107 100644 --- a/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-lib.sh +++ b/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-lib.sh @@ -70,6 +70,9 @@ gbmc_br_reload_ip() { return 0 fi + # Remove legacy network configuration + rm -rf /etc/systemd/network/{00,}-bmc-gbmcbr.network.d + local pfx_bytes=() if ! ip_to_bytes pfx_bytes "$ip"; then echo "Ignoring Invalid IPv6: $ip" >&2 @@ -111,17 +114,17 @@ EOF gbmc_br_set_ip() { local ip="${1-}" - + local old_ip= if [ -n "$ip" ]; then + old_ip="$(cat /var/google/gbmc-br-ip 2>/dev/null)" + [ "$old_ip" != "$ip" ] || return mkdir -p /var/google || return echo "$ip" >/var/google/gbmc-br-ip || return else + [ -f "/var/google/gbmc-br-ip" ] || return rm -rf /var/google/gbmc-br-ip fi - # Remove legacy network configuration - rm -rf /etc/systemd/network/{00,}-bmc-gbmcbr.network.d - gbmc_br_run_hooks GBMC_BR_LIB_SET_IP_HOOKS "$ip" || return gbmc_br_reload_ip "$ip" -- cgit v1.2.3