meta-google: gbmc-ncsi-config: Add route policy

If an external NIC is used, this will fix the triangle routing scenario
so that traffic directed down the NCSI path will return on the NCSI
path, instead of taking the default route.

Change-Id: I53054563dd4f121950fcc20d2fdf8b118f5c50be
Signed-off-by: William A. Kennington III <wak@google.com>
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 014b3b7..34c59ab 100644
--- a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-ra.sh
+++ b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-ra.sh
@@ -17,12 +17,23 @@
 IP_OFFSET=1
 # NCSI is known to be closer to the ToR than bridge routes. Prefer over bridge routes.
 ROUTE_METRIC=900
+ROUTE_TABLE=900
 
 update_rtr() {
   busctl set-property xyz.openbmc_project.Network /xyz/openbmc_project/network/"$RA_IF" \
     xyz.openbmc_project.Network.EthernetInterface DefaultGateway6 s "" || true
 
   default_update_rtr "$@"
+
+  # Add additional gateway information
+  for file in /run/systemd/network/{00,}-bmc-$RA_IF.network; do
+    mkdir -p "$file.d"
+    printf '[Route]\nGateway=%s\nGatewayOnLink=true\nTable=%d' \
+      "$rtr" "$ROUTE_TABLE" >"$file.d"/10-gateway-table.conf
+  done
+
+  ip -6 route replace default via "$rtr" onlink dev "$RA_IF" table "$ROUTE_TABLE" || \
+    networkctl reload && networkctl reconfigure "$RA_IF"
 }
 
 ncsi_is_active() {