meta-google: gbmc-mac-config: Allow rollover MAC assignments
This allows for MAC assignments like `0c:c4:13:4d:d4:ff` of `2`,
where the second address requires a rollover to `0c:c4:13:4d:d5:00`
Change-Id: Ief1489e4f99b27c9af7d4b5f1826dccf36863e0f
Signed-off-by: William A. Kennington III <wak@google.com>
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 dce4611..aaa9920 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
@@ -60,13 +60,17 @@
done
# Write out each MAC override to the runtime networkd configuration
+lower=$(((mac[3] << 16) | (mac[4] << 8) | mac[5]))
for (( i=0; i<num; i++ )); do
- if (( mac[5] > 0xff )); then
+ if (( lower > 0xffffff )); then
echo "MAC assignment too large: ${mac[*]}" >&2
rc=2
break
fi
for intf in ${num_to_intfs[$i]}; do
+ mac[3]=$(((lower >> 16) & 0xff))
+ mac[4]=$(((lower >> 8) & 0xff))
+ mac[5]=$(((lower >> 0) & 0xff))
macstr=$(printf '%02x:%02x:%02x:%02x:%02x:%02x' "${mac[@]}")
echo "Setting $intf to $macstr" >&2
for override in /run/systemd/network/{00,}-bmc-$intf.network.d; do
@@ -85,7 +89,7 @@
echo "Setting MAC($macstr) on $intf failed" >&2
fi
done
- (( ++mac[5] ))
+ (( ++lower ))
done
exit $rc