ethernet_interface: Detect nicEnabled from systemd-networkd
Our current method of interface detection can race with
systemd-networkd. If systemd-networkd takes too long to transition from
the initialized state to bringing up the link, phosphor-networkd will
see the link as administratively down and treat it as if it should be
Unmanaged. This is incorrect and causes us to lose BMC network
information about 1% of boots with our current configuration. This has
the consequence of being persistent across powercycles and even across
firmware updates. Without using some method of intervention, this
prevents automated tooling from configuring the management interface.
systemd-networkd can actually inform us to the state of network
interfaces via DBus. We can monitor the AdministrativeState property to
determine whether or not our NIC should be enabled. We now wait until
systemd-networkd has progressed far enough to detect it.
Change-Id: Ic5cb7e6805791e040ab145517e3b1c9e8b146851
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/ethernet_interface.hpp b/src/ethernet_interface.hpp
index 8e28b51..fef1579 100644
--- a/src/ethernet_interface.hpp
+++ b/src/ethernet_interface.hpp
@@ -93,10 +93,12 @@
* @param[in] parent - parent object.
* @param[in] emitSignal - true if the object added signal needs to be
* send.
+ * @param[in] enabled - Override the lookup of nicEnabled
*/
EthernetInterface(sdbusplus::bus::bus& bus, const std::string& objPath,
DHCPConf dhcpEnabled, Manager& parent,
- bool emitSignal = true);
+ bool emitSignal = true,
+ std::optional<bool> enabled = std::nullopt);
/** @brief Function used to load the nameservers.
*/
@@ -176,9 +178,6 @@
/** Retrieve Link State */
bool linkUp() const override;
- /** Retrieve NIC State */
- bool nicEnabled() const override;
-
/** Set value of NICEnabled */
bool nicEnabled(bool value) override;
@@ -366,6 +365,11 @@
* @returns true/false value if the address is static
*/
bool originIsManuallyAssigned(IP::AddressOrigin origin);
+
+ /** @brief Determines if the NIC is enabled in systemd
+ * @returns true/false value if the NIC is enabled
+ */
+ bool queryNicEnabled() const;
};
} // namespace network