summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Kosenkov <NKosenkov@IBS.RU>2022-08-23 10:47:29 +0300
committerNikita Kosenkov <NKosenkov@IBS.RU>2022-08-23 10:47:29 +0300
commit3595e1a9e3906a38fd0271a3a3fd63ca1ff82ba5 (patch)
tree5f1b5ce46ae1b572e3d00c99933e99832718e5c5
parent3542588580debb4fbc206df4b41ec95b2eeb9813 (diff)
downloadopenbmc-3595e1a9e3906a38fd0271a3a3fd63ca1ff82ba5.tar.xz
SILABMC-216: Added NTP sync status check and additional log about it
-rw-r--r--meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Added-additional-log-about-NTP-sync-status.patch41
-rw-r--r--meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend3
-rw-r--r--meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network/0002-Added-check-of-sync-status-with-NTP-servers.patch210
-rw-r--r--meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network_%.bbappend1
4 files changed, 254 insertions, 1 deletions
diff --git a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Added-additional-log-about-NTP-sync-status.patch b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Added-additional-log-about-NTP-sync-status.patch
new file mode 100644
index 0000000000..ef6514e48d
--- /dev/null
+++ b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Added-additional-log-about-NTP-sync-status.patch
@@ -0,0 +1,41 @@
+From 1b4c6999fa854fa947e9b91e1bdfff22abc541ef Mon Sep 17 00:00:00 2001
+From: Nikita Kosenkov <NKosenkov@IBS.RU>
+Date: Tue, 23 Aug 2022 10:09:10 +0300
+Subject: [PATCH] Added additional log about NTP synchronization status
+
+---
+ .../include/registries/openbmc_message_registry.hpp | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp
+index 2b8d476c..3199412e 100644
+--- a/redfish-core/include/registries/openbmc_message_registry.hpp
++++ b/redfish-core/include/registries/openbmc_message_registry.hpp
+@@ -2290,13 +2290,23 @@ constexpr std::array registry = {
+ MessageEntry{
+ "BMCTimeNotUpdatedViaNTP",
+ {
+- "Indicates that time was restored from recorded timestamp.",
++ "Indicates that timed out waiting for reply from NTP server.",
+ "BMC timed out waiting for reply from NTP server: %1 (%2).",
+ "Warning",
+ 0,
+ {},
+ "None.",
+ }},
++ MessageEntry{
++ "BMCTimeNotResolvedNTPServers",
++ {
++ "Indicates that failed to resolve NTP server addresses.",
++ "BMC Failed to resolve NTP server addresses.",
++ "Warning",
++ 0,
++ {},
++ "None.",
++ }},
+
+ };
+ } // namespace redfish::registries::openbmc
+--
+2.35.1
+
diff --git a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend
index 55acebb4f4..2ba10a776f 100644
--- a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend
+++ b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend
@@ -10,7 +10,8 @@ SRC_URI += "\
file://0005-Add-Sensor-Warning-Threshold-Edit.patch \
file://0006-IBS-bmcweb-evt-registry-add-BMCTimeUpdatedViaNTP.patch \
file://0007-Add-critical-thresholds-to-redfish.patch \
- file://0008-Add-additional-logs-about-time-sync.patch \
+ file://0008-Add-additional-logs-about-time-sync.patch \
+ file://0009-Added-additional-log-about-NTP-sync-status.patch \
"
EXTRA_OEMESON += "\
diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network/0002-Added-check-of-sync-status-with-NTP-servers.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network/0002-Added-check-of-sync-status-with-NTP-servers.patch
new file mode 100644
index 0000000000..0b18b594ba
--- /dev/null
+++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network/0002-Added-check-of-sync-status-with-NTP-servers.patch
@@ -0,0 +1,210 @@
+From e4492d4f1e29731db6ac278ecb121cb47a8e204f Mon Sep 17 00:00:00 2001
+From: Nikita Kosenkov <NKosenkov@IBS.RU>
+Date: Tue, 23 Aug 2022 10:00:35 +0300
+Subject: [PATCH] Added check of synchronization status with NTP servers
+
+This functionality provides users with an additional log
+about the state of synchronization with NTP servers.
+
+The definition occurs on an indirect basis:
+If the 'ServerAddress' property is empty,
+then we consider that it was not possible
+to obtain the IP address of the NTP server.
+
+Similarly, 'timedatectl show-timesync --property ServerAddress --value'.
+---
+ src/network_manager_main.cpp | 115 ++++++++++++++++++++++++++++++++++-
+ src/types.hpp | 4 ++
+ 2 files changed, 116 insertions(+), 3 deletions(-)
+
+diff --git a/src/network_manager_main.cpp b/src/network_manager_main.cpp
+index 349c2ea..5d47c0c 100644
+--- a/src/network_manager_main.cpp
++++ b/src/network_manager_main.cpp
+@@ -6,11 +6,13 @@
+ #include "watch.hpp"
+
+ #include <linux/netlink.h>
++#include <systemd/sd-journal.h>
+
+ #include <filesystem>
+ #include <fstream>
+ #include <functional>
+ #include <memory>
++#include <algorithm>
+ #ifdef SYNC_MAC_FROM_INVENTORY
+ #include <nlohmann/json.hpp>
+ #endif
+@@ -49,6 +51,7 @@ namespace network
+ std::unique_ptr<phosphor::network::Manager> manager = nullptr;
+ std::unique_ptr<Timer> refreshObjectTimer = nullptr;
+ std::unique_ptr<Timer> reloadTimer = nullptr;
++std::unique_ptr<Timer> checkNtpSyncStatusTimer = nullptr;
+
+ #ifdef SYNC_MAC_FROM_INVENTORY
+ std::unique_ptr<sdbusplus::bus::match::match> EthInterfaceMatch = nullptr;
+@@ -230,17 +233,66 @@ void watchEthernetInterface(sdbusplus::bus::bus& bus,
+ }
+ }
+ }
+-
+ #endif
+
++void watchNTPServers(sdbusplus::bus::bus& bus)
++{
++ static std::unique_ptr<sdbusplus::bus::match::match> NTPServersMatch;
++
++ auto callback = [](sdbusplus::message::message& message) {
++ std::string intfName;
++ std::map<std::string, std::variant<std::string>> properties;
++
++ try
++ {
++ message.read(intfName, properties);
++ }
++ catch (const std::exception& e)
++ {
++ log<level::ERR>("Unable to read properties from"
++ "xyz.openbmc_project.Network.EthernetInterface");
++
++ return;
++ }
++ if (properties.empty())
++ {
++ log<level::ERR>("Empty PropertiesChanged signal received");
++ return;
++ }
++
++ // we only want to check for NTPServers
++ if (properties.begin()->first != "NTPServers")
++ {
++ return;
++ }
++
++ std::string* NTPServers = std::get_if<std::string>(&(properties.begin()->second));
++ if (NTPServers == nullptr)
++ {
++ log<level::ERR>("NTPServers - property invalid");
++ return;
++ }
++
++ // call check sync status
++ checkNtpSyncStatusTimer->restartOnce(ntpSyncTimeout);
++ };
++
++ NTPServersMatch = std::make_unique<sdbusplus::bus::match::match>(
++ bus,
++ "type='signal',member='PropertiesChanged', "
++ "interface='org.freedesktop.DBus.Properties', "
++ "arg0='xyz.openbmc_project.Network.EthernetInterface'",
++ callback);
++}
++
+ /** @brief refresh the network objects. */
+ void refreshObjects()
+ {
+ if (manager)
+ {
+- log<level::INFO>("Refreshing the objects.");
++ log<level::INFO>("Refreshing the objects");
+ manager->createChildObjects();
+- log<level::INFO>("Refreshing complete.");
++ log<level::INFO>("Refreshing complete");
+ }
+ }
+
+@@ -254,12 +306,67 @@ void reloadNetworkd()
+ }
+ }
+
++void checkNtpSyncStatus()
++{
++ log<level::INFO>("Checking NTP sync status");
++
++ // DBUS - ServerAddress property (iay)
++ using ServerAddress = std::tuple<int32_t, std::vector<uint8_t>>;
++ std::variant<ServerAddress> propServerAddress;
++
++ auto getProperty = [](auto propName, auto &result) -> bool {
++ try
++ {
++ auto b = sdbusplus::bus::new_default_system();
++ auto method =
++ b.new_method_call(
++ "org.freedesktop.timesync1",
++ "/org/freedesktop/timesync1",
++ "org.freedesktop.DBus.Properties", "Get");
++
++ method.append("org.freedesktop.timesync1.Manager", propName);
++ auto reply = b.call(method);
++ reply.read(result);
++ }
++ catch (const sdbusplus::exception::exception& ex)
++ {
++ log<level::ERR>("Exception occurred during getting of "
++ "property from org.freedesktop.timesync1.Manager");
++ return false;
++ }
++ return true;
++ };
++
++ if(getProperty("ServerAddress", propServerAddress))
++ {
++ auto serverAddress = std::get<ServerAddress>(propServerAddress);
++
++ // get first value from "ServerAddress property (iay)"
++ // using this parameter, you can understand whether
++ // it was possible to resolve the NTP address
++ if(std::get<int32_t>(serverAddress) <= 0)
++ {
++ sd_journal_send(
++ "MESSAGE=BMC Failed to resolve NTP server addresses",
++ "PRIORITY=%i", LOG_WARNING,
++ "REDFISH_MESSAGE_ID=%s",
++ "OpenBMC.0.1.BMCTimeNotResolvedNTPServers",
++ NULL);
++ }
++ }
++
++ log<level::INFO>("Checking NTP sync status complete");
++}
++
+ void initializeTimers()
+ {
+ auto event = sdeventplus::Event::get_default();
+ refreshObjectTimer =
+ std::make_unique<Timer>(event, std::bind(refreshObjects));
+ reloadTimer = std::make_unique<Timer>(event, std::bind(reloadNetworkd));
++
++ checkNtpSyncStatusTimer =
++ std::make_unique<Timer>(event, std::bind(checkNtpSyncStatus));
+ }
+
+ } // namespace network
+@@ -329,6 +436,8 @@ int main(int /*argc*/, char** /*argv*/)
+ phosphor::network::watchEthernetInterface(bus, configJson);
+ #endif
+
++ phosphor::network::watchNTPServers(bus);
++
+ // Trigger the initial object scan
+ // This is intentionally deferred, to ensure that systemd-networkd is
+ // fully configured.
+diff --git a/src/types.hpp b/src/types.hpp
+index 69a314d..0de7a3f 100644
+--- a/src/types.hpp
++++ b/src/types.hpp
+@@ -34,6 +34,10 @@ constexpr auto reloadTimeout = 3s;
+ // configuration takes 3-4 sec after systemd-networkd restart.
+ constexpr auto refreshTimeout = reloadTimeout + 7s;
+
++// check the synchronization status
++// after updating the list of NTP servers after 60 seconds
++constexpr auto ntpSyncTimeout = 60s;
++
+ namespace systemd
+ {
+ namespace config
+--
+2.35.1
+
diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network_%.bbappend b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network_%.bbappend
index 4283da0ff6..dd25d3bbae 100644
--- a/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network_%.bbappend
+++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network_%.bbappend
@@ -2,4 +2,5 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI += " \
file://0001-Fix-enable-DHCP-back.patch \
+ file://0002-Added-check-of-sync-status-with-NTP-servers.patch \
"