summaryrefslogtreecommitdiff
path: root/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2021-05-11 02:48:43 +0300
committerWilliam A. Kennington III <wak@google.com>2021-05-11 23:35:56 +0300
commitbdbe7ce8bb2a01f4ed04389d677f3724f0ece044 (patch)
tree7575efc1eb022be85f6e32dea152c159752b70cc /meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in
parent8fb92589e9368cff81460e89feb9da4de1f82ab8 (diff)
downloadopenbmc-bdbe7ce8bb2a01f4ed04389d677f3724f0ece044.tar.xz
meta-google: gbmc-bridge: Remove custom ip parsing logic
Change-Id: I455ab70094cfdc79b38097a838051f51b3c852da Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in')
-rw-r--r--meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in32
1 files changed, 17 insertions, 15 deletions
diff --git a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in
index e033fd2a5..949f04f45 100644
--- a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in
+++ b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in
@@ -23,35 +23,37 @@ gbmc_ncsi_br_pub_addr_update() {
printf 'gBMC Bridge Pub Addr from NCSI: %s\n' \
"${gbmc_ncsi_br_pub_addr_lastip:-(deleted)}" >&2
- local pfx=
+ local pfx_bytes=()
if [ -n "$gbmc_ncsi_br_pub_addr_lastip" ]; then
- # Pad the address out to a /64 and ensure that it doesn't have extra bits
- pfx="${gbmc_ncsi_br_pub_addr_lastip%::}"
- while true; do
- # Count `:` in `pfx` by removing them and diffing their lengths
- local nos="${pfx//:/}"
- (( ${#pfx} - ${#nos} >= 3 )) && break
- pfx+=":0"
+ ip_to_bytes pfx_bytes "$gbmc_ncsi_br_pub_addr_lastip"
+ # Ensure we don't have more than a /64 address
+ local i
+ for (( i = 8; i < 16; ++i )); do
+ if (( pfx_bytes[$i] != 0 )); then
+ pfx_bytes=()
+ break
+ fi
done
- # Addresses that have more than 64bits of prefix (more than 3 separators)
- # do not work with this scheme. Ignore them.
- (( ${#pfx} - ${#nos} == 3 )) || pfx=
fi
local contents='[Network]'$'\n'
- if [ -n "$pfx" ]; then
+ if (( ${#pfx_bytes[@]} != 0 )); then
+ pfx_bytes[8]=0xfd
+ local stateless_pfx="$(ip_bytes_to_str pfx_bytes)"
+ pfx_bytes[9]=0x01
+ local ncsi_pfx="$(ip_bytes_to_str pfx_bytes)"
local here=
read -r -d '' here <<EOF
-Address=${pfx}:fd01::/128
+Address=$ncsi_pfx/128
IPv6PrefixDelegation=yes
[IPv6PrefixDelegation]
RouterLifetimeSec=60
[IPv6Prefix]
-Prefix=${pfx}:fd00::/80
+Prefix=$stateless_pfx/80
PreferredLifetimeSec=60
ValidLifetimeSec=60
[IPv6RoutePrefix]
-Route=${pfx}:fd01::/80
+Route=$ncsi_pfx/80
LifetimeSec=60
EOF
contents+="$here"$'\n'