summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2022-04-30 00:26:05 +0300
committerWilliam A. Kennington III <wak@google.com>2022-05-02 19:55:52 +0300
commit7d346b7258b63ddc31c007b8b63b11aaa8d07b54 (patch)
tree0f9dc23832ef494355219794fc94e05ea28da1a5
parent70d6c5ef7ec7427bfe1ca117ed50f4639ed04790 (diff)
downloadopenbmc-7d346b7258b63ddc31c007b8b63b11aaa8d07b54.tar.xz
meta-google: gbmc-ncsi-config: Don't mark explicit addresses deprecated
We want the machine to correctly report that the address was assigned from the host. If we don't do this it can sometimes become unassigned. Change-Id: I5de00c53c5fa831025b9ffdf1ad194b094075194 Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r--meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-deprecated-ips.sh.in37
1 files changed, 23 insertions, 14 deletions
diff --git a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-deprecated-ips.sh.in b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-deprecated-ips.sh.in
index 96037ea450..fdfa87803f 100644
--- a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-deprecated-ips.sh.in
+++ b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-deprecated-ips.sh.in
@@ -20,6 +20,25 @@ gbmc_ncsi_br_deprecated_ips_init=
gbmc_ncsi_br_deprecated_ips_confip=
gbmc_ncsi_br_deprecated_ips_lastip=
+gbmc_ncsi_br_deprecated_ips_addr_contents() {
+ local addr="$1"
+
+ # If our address is assigned explicitly, don't mark it deprecated
+ local line
+ for line in $(grep '^Address=' /etc/systemd/network/*-bmc-@NCSI_IF@.network); do
+ # Remove `Address=` on the input line
+ local apfx="$(echo "$line" | sed 's,^[^=]*=,,')"
+ # ip_pfx_concat is used to normalize the address string for comparison
+ [[ "$addr/128" == "$(ip_pfx_concat "$apfx" ::)" ]] && return
+ done
+
+ cat <<EOF
+[Address]
+Address=$addr/128
+PreferredLifetime=0
+EOF
+}
+
gbmc_ncsi_br_deprecated_ips_update() {
[ -n "$gbmc_ncsi_br_deprecated_ips_init" ] || return
[ "$gbmc_ncsi_br_deprecated_ips_confip" != "$gbmc_ncsi_br_deprecated_ips_lastip" ] || return
@@ -44,20 +63,10 @@ gbmc_ncsi_br_deprecated_ips_update() {
pfx_bytes[8]=0
pfx_bytes[9]=0
local host_pfx="$(ip_bytes_to_str pfx_bytes)"
- read -r -d '' contents <<EOF
-[Address]
-Address=$pfx/128
-PreferredLifetime=0
-[Address]
-Address=$stateless_pfx/128
-PreferredLifetime=0
-[Address]
-Address=$stateless_ip/128
-PreferredLifetime=0
-[Address]
-Address=$host_pfx/128
-PreferredLifetime=0
-EOF
+ contents+="$(gbmc_ncsi_br_deprecated_ips_addr_contents "$pfx")"$'\n'
+ contents+="$(gbmc_ncsi_br_deprecated_ips_addr_contents "$stateless_pfx")"$'\n'
+ contents+="$(gbmc_ncsi_br_deprecated_ips_addr_contents "$stateless_ip")"$'\n'
+ contents+="$(gbmc_ncsi_br_deprecated_ips_addr_contents "$host_pfx")"$'\n'
read -r -d '' nfcontents <<EOF
table inet filter {
chain ncsi_input {