meta-google: Refactor networkd reloads to one place

We want to have common logging and conditional routines when we talk to
networkd.

Change-Id: I44c83c8137399d2126c565a1f753520603a9f97b
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-deprecated-ips.sh.in b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-deprecated-ips.sh.in
index 93c6b27..c2783be 100644
--- a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-deprecated-ips.sh.in
+++ b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-deprecated-ips.sh.in
@@ -15,6 +15,7 @@
 [ -n "${gbmc_ncsi_br_deprecated_ips_lib-}" ] && return
 
 source /usr/share/network/lib.sh || exit
+source /usr/share/gbmc-net-lib.sh || exit
 
 gbmc_ncsi_br_deprecated_ips_init=
 gbmc_ncsi_br_deprecated_ips_confip=
@@ -115,9 +116,7 @@
       lookup $GBMC_NCSI_ROUTE_TABLE || st=$?
   fi
 
-  if (( st != 0 )); then
-    networkctl reload && networkctl reconfigure @NCSI_IF@
-  fi
+  (( st == 0 )) || gbmc_net_networkd_reload @NCSI_IF@
 
   local rfile=/run/nftables/40-gbmc-ncsi-br.rules
   mkdir -p -m 755 "$(dirname "$rfile")"
diff --git a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-ra.sh b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-ra.sh
index 34c59ab..ca8fa05 100644
--- a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-ra.sh
+++ b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-ra.sh
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# shellcheck source=meta-google/recipes-google/networking/gbmc-net-common/gbmc-net-lib.sh
+source /usr/share/gbmc-net-lib.sh || exit
+
 RA_IF=$1
 IP_OFFSET=1
 # NCSI is known to be closer to the ToR than bridge routes. Prefer over bridge routes.
@@ -33,7 +36,7 @@
   done
 
   ip -6 route replace default via "$rtr" onlink dev "$RA_IF" table "$ROUTE_TABLE" || \
-    networkctl reload && networkctl reconfigure "$RA_IF"
+    gbmc_net_networkd_reload "$RA_IF"
 }
 
 ncsi_is_active() {
@@ -78,7 +81,7 @@
     ip -6 addr del "$old_ncsi_pfx/128" dev gbmcbr || true
   fi
   ip -6 addr replace "$pfx/128" dev gbmcbr || \
-    (networkctl reload && networkctl reconfigure gbmcbr) || true
+    gbmc_net_networkd_reload gbmcbr || true
   old_ncsi_pfx=$pfx
 
   echo "Set NCSI addr $pfx on gbmcbr" >&2