meta-google: gbmc-mac-config: Fix MAC address too large failure
The existing one would fail when the MAC address from EEPROM + MAC
address count >= 0xff. Fix this so that it will only fail when it is
strictly greater than 0xff.
Example failure: if `mac[5]` is 0xfc and `num` is 4, in this case even
after the MAC address assignments are done, it will fail due to the last
checked exceeded 0xff.
Signed-off-by: Anthony <anthonyhkf@google.com>
Change-Id: If24debed070bdd500cb0f3df6aa4c49d8f3af365
diff --git a/meta-google/recipes-google/networking/files/gbmc-mac-config.sh.in b/meta-google/recipes-google/networking/files/gbmc-mac-config.sh.in
index d10eb98..398445e 100644
--- a/meta-google/recipes-google/networking/files/gbmc-mac-config.sh.in
+++ b/meta-google/recipes-google/networking/files/gbmc-mac-config.sh.in
@@ -59,6 +59,11 @@
# Write out each MAC override to the runtime networkd configuration
for (( i=0; i<num; i++ )); do
+ if (( mac[5] > 0xff )); then
+ echo "MAC assignment too large: ${mac[@]}" >&2
+ rc=2
+ break
+ fi
for intf in ${num_to_intfs[$i]}; do
macstr=$(printf '%02x:%02x:%02x:%02x:%02x:%02x' "${mac[@]}")
echo "Setting $intf to $macstr" >&2
@@ -71,11 +76,7 @@
printf '[NetDev]\nMACAddress=%s\n' "$macstr" >"$override"/50-mac.conf
done
done
- if (( ++mac[5] > 0xff )); then
- echo "MAC assignment too large: ${mac[@]}" >&2
- rc=2
- break
- fi
+ (( ++mac[5] ))
done
exit $rc