diff options
author | Johnathan Mantey <johnathanx.mantey@intel.com> | 2020-01-08 23:08:44 +0300 |
---|---|---|
committer | Johnathan Mantey <johnathanx.mantey@intel.com> | 2020-02-14 21:25:05 +0300 |
commit | aa05fb27ebd2429c29040708ff05eb27407bd963 (patch) | |
tree | 08a3ebee42e716d86b4ac672b17d1d452119c4de /redfish-core/lib/ethernet.hpp | |
parent | 45b1b13506d17540cefdc842487a4be939a183c8 (diff) | |
download | bmcweb-aa05fb27ebd2429c29040708ff05eb27407bd963.tar.xz |
Report NIC link status via netlink carrier state
Update Redfish to use a DBus boolean value specifically intended for
communicating the NIC link state. Existing Intel server boards have a
NCSI channel with a speed value always assigned to 100Mbps. This makes
identifying link state impossible via the network speed value. The
DBus boolean uses the netlink carrier on/off state which is more
accurate.
Tested:
BMC Console commands:
ip link set down dev eth0
Get managers/bmc/eth0 state ;; LinkStatus is LinkDown
ip link set up dev eth0
Get managers/bmc/eth0 state ;; LinkStatus is LinkUp
Remove NIC cable from RJ45 connector
Get managers/bmc/eth0 state ;; LinkStatus is LinkDown
Insert NIC cable into RJ45 connector
Get managers/bmc/eth0 state ;; LinkStatus is LinkUp
Change-Id: I93d3f716a0afc563e3312e99b4a4163187985521
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
Diffstat (limited to 'redfish-core/lib/ethernet.hpp')
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index b6f3baa9e1..4998a9500d 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -97,6 +97,7 @@ struct EthernetInterfaceData bool NTPEnabled; bool HostNameEnabled; bool SendHostNameEnabled; + bool linkUp; std::string DHCPEnabled; std::string operatingMode; std::string hostname; @@ -265,6 +266,15 @@ inline bool extractEthernetInterfaceData(const std::string ðiface_id, ethData.speed = *speed; } } + else if (propertyPair.first == "LinkUp") + { + const bool *linkUp = + std::get_if<bool>(&propertyPair.second); + if (linkUp != nullptr) + { + ethData.linkUp = *linkUp; + } + } else if (propertyPair.first == "Nameservers") { const std::vector<std::string> *nameservers = @@ -1616,7 +1626,6 @@ class EthernetInterface : public Node json_response["InterfaceEnabled"] = true; if (ethData.speed == 0) { - json_response["LinkStatus"] = "NoLink"; json_response["Status"] = { {"Health", "OK"}, {"State", "Disabled"}, @@ -1624,12 +1633,13 @@ class EthernetInterface : public Node } else { - json_response["LinkStatus"] = "LinkUp"; json_response["Status"] = { {"Health", "OK"}, {"State", "Enabled"}, }; } + + json_response["LinkStatus"] = ethData.linkUp ? "LinkUp" : "LinkDown"; json_response["SpeedMbps"] = ethData.speed; json_response["MACAddress"] = ethData.mac_address; json_response["DHCPv4"]["DHCPEnabled"] = |