meta-google: gbmc-ip-monitor: Fix optional metric attribute

This fixes parsing addresses that have a weight metric.

Change-Id: Ibe93523caea0dccc77bec04e494f46c3db85bbf9
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/meta-google/recipes-google/networking/files/gbmc-ip-monitor-test.sh b/meta-google/recipes-google/networking/files/gbmc-ip-monitor-test.sh
index 8b5f349..7c39f59 100755
--- a/meta-google/recipes-google/networking/files/gbmc-ip-monitor-test.sh
+++ b/meta-google/recipes-google/networking/files/gbmc-ip-monitor-test.sh
@@ -125,7 +125,7 @@
 }
 
 testParseAddrAdd() {
-  expect_err 0 gbmc_ip_monitor_parse_line '[ADDR]2: eno2 inet6 fd01:ff2:5687:4:cf03:45f3:983a:96eb/128 scope global temporary dynamic'
+  expect_err 0 gbmc_ip_monitor_parse_line '[ADDR]2: eno2 inet6 fd01:ff2:5687:4:cf03:45f3:983a:96eb/128 metric 1024 scope global temporary dynamic'
   expect_streq "$change" 'addr'
   expect_streq "$action" 'add'
   expect_streq "$intf" 'eno2'
diff --git a/meta-google/recipes-google/networking/files/gbmc-ip-monitor.sh b/meta-google/recipes-google/networking/files/gbmc-ip-monitor.sh
index 9da090f..90986e3 100755
--- a/meta-google/recipes-google/networking/files/gbmc-ip-monitor.sh
+++ b/meta-google/recipes-google/networking/files/gbmc-ip-monitor.sh
@@ -66,9 +66,11 @@
     pfx_re='^\[ADDR\](Deleted )?[0-9]+:[[:space:]]*'
     intf_re='([^ ]+)[[:space:]]+'
     fam_re='([^ ]+)[[:space:]]+'
-    addr_re='([^/]+)/[0-9]+[[:space:]]+(brd[[:space:]]+[^ ]+[[:space:]]+)?'
+    addr_re='([^/]+)/[0-9]+[[:space:]]+'
+    metric_re='(metric[[:space:]]+[^ ]+[[:space:]]+)?'
+    brd_re='(brd[[:space:]]+[^ ]+[[:space:]]+)?'
     scope_re='scope[[:space:]]+([^ ]+)[[:space:]]*(.*)'
-    combined_re="${pfx_re}${intf_re}${fam_re}${addr_re}${scope_re}"
+    combined_re="${pfx_re}${intf_re}${fam_re}${addr_re}${metric_re}${brd_re}${scope_re}"
     if ! [[ "$line" =~ ${combined_re} ]]; then
       echo "Failed to parse addr: $line" >&2
       return 1
@@ -79,8 +81,8 @@
     intf="${BASH_REMATCH[2]}"
     fam="${BASH_REMATCH[3]}"
     ip="${BASH_REMATCH[4]}"
-    scope="${BASH_REMATCH[6]}"
-    flags="${BASH_REMATCH[7]}"
+    scope="${BASH_REMATCH[7]}"
+    flags="${BASH_REMATCH[8]}"
   elif [[ "$line" == '[ROUTE]'* ]]; then
     line="${line#[ROUTE]}"
     change=route