ncsid: Fix IP / Gateway updating
Sometimes phosphor-networkd incorrectly determines that DHCP should be
enabled. This prevents us from assigning IPs and gateways to the BMC.
Disable DHCP to fix assignment.
Change-Id: I91c8da79afb2ff1f1dba924f8c229ee8862bdeab
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/subprojects/ncsid/src/ncsid_lib.sh b/subprojects/ncsid/src/ncsid_lib.sh
index 86b5036..a8fca22 100644
--- a/subprojects/ncsid/src/ncsid_lib.sh
+++ b/subprojects/ncsid/src/ncsid_lib.sh
@@ -454,3 +454,14 @@
printf '{"router_ip":"%s","router_mac":"%s","stateful_address":"%s"}\n' \
"$ip" "$mac" "$staddr"
}
+
+# Sets the network configuration of an interface to be static
+SetStatic() {
+ local service="$1"
+ local netdev="$2"
+
+ echo "Disabling DHCP" >&2
+ busctl set-property "$service" "$(EthObjRoot "$netdev")" \
+ xyz.openbmc_project.Network.EthernetInterface DHCPEnabled \
+ s xyz.openbmc_project.Network.EthernetInterface.DHCPConf.none
+}
diff --git a/subprojects/ncsid/src/ncsid_udhcpc4.script b/subprojects/ncsid/src/ncsid_udhcpc4.script
index 9c22756..bb6fa6a 100644
--- a/subprojects/ncsid/src/ncsid_udhcpc4.script
+++ b/subprojects/ncsid/src/ncsid_udhcpc4.script
@@ -49,7 +49,8 @@
SuppressTerm
local service='xyz.openbmc_project.Network'
local rc=0
- UpdateIP "$service" "$interface" "$ip" "$mask" && \
+ SetStatic "$service" "$interface" && \
+ UpdateIP "$service" "$interface" "$ip" "$mask" && \
UpdateGateway "$service" "$interface" "$router" && \
UpdateNeighbor "$service" "$interface" "$router" "$router_mac" || \
rc=$?
diff --git a/subprojects/ncsid/src/ncsid_udhcpc6.script b/subprojects/ncsid/src/ncsid_udhcpc6.script
index cfed671..c913ebe 100644
--- a/subprojects/ncsid/src/ncsid_udhcpc6.script
+++ b/subprojects/ncsid/src/ncsid_udhcpc6.script
@@ -22,7 +22,8 @@
SuppressTerm
local service='xyz.openbmc_project.Network'
local rc=0
- UpdateIP "$service" "$interface" "$ipv6" '128' && \
+ SetStatic "$service" "$interface" && \
+ UpdateIP "$service" "$interface" "$ipv6" '128' && \
UpdateGateway "$service" "$interface" "$router_ip" && \
UpdateNeighbor "$service" "$interface" "$router_ip" "$router_mac" || \
rc=$?
diff --git a/subprojects/ncsid/src/update_ra_gw.sh b/subprojects/ncsid/src/update_ra_gw.sh
index 77d77f4..6d2ef3a 100644
--- a/subprojects/ncsid/src/update_ra_gw.sh
+++ b/subprojects/ncsid/src/update_ra_gw.sh
@@ -28,8 +28,10 @@
(( lifetime > 0 )) || return
echo "Setting default router: $rtr at $mac" >&2
- UpdateGateway xyz.openbmc_project.Network "$NCSI_IF" "$rtr" || return
- UpdateNeighbor xyz.openbmc_project.Network "$NCSI_IF" "$rtr" "$mac" || return
+ local svc=xyz.openbmc_project.Network
+ SetStatic "$svc" "$NCSI_IF" || return
+ UpdateGateway "$svc" "$NCSI_IF" "$rtr" || return
+ UpdateNeighbor "$svc" "$NCSI_IF" "$rtr" "$mac" || return
retries=-1
old_mac="$mac"