ipmid: channel: add match function to reset config on network changes
The IPMID load the channel config once at startup and will fail to pick
up any network interfaces added after that. Added a dbus matching
function again `xyz.openbmc_project.Network` to detect new networks and
reload the Channel Configs.
Teseted:
The network information via IPMI is populated correctly. The information
before the change is empty since ipmid parse the information before it
is ready on the system.
```
$ uptime
00:02:42 up 0:02, 0 users, load average: 9.38, 4.96, 1.92
$ ipmitool lan6 print 11
Getting parameter(s)...
IPv6/IPv4 Support:
IPv6 only: no
IPv4 and IPv6: yes
IPv6 Destination Addresses for LAN alerting: yes
IPv6/IPv4 Addressing Enables: both
IPv6 Status:
Static address max: 15
Dynamic address max: 15
SLAAC support: yes
...
```
Change-Id: I6478cea3642c524e55a9dbc96c3deaca90feb089
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/user_channel/channel_mgmt.cpp b/user_channel/channel_mgmt.cpp
index 41b477d..5797a19 100644
--- a/user_channel/channel_mgmt.cpp
+++ b/user_channel/channel_mgmt.cpp
@@ -59,6 +59,8 @@
static constexpr const char* dBusPropertiesInterface =
"org.freedesktop.DBus.Properties";
static constexpr const char* propertiesChangedSignal = "PropertiesChanged";
+static constexpr const char* interfaceAddedSignal = "InterfacesAdded";
+static constexpr const char* interfaceRemovedSignal = "InterfacesRemoved";
// STRING DEFINES: Should sync with key's in JSON
static constexpr const char* nameString = "name";
@@ -95,6 +97,12 @@
std::unique_ptr<sdbusplus::bus::match_t> chPropertiesSignal
__attribute__((init_priority(101)));
+std::unique_ptr<sdbusplus::bus::match_t> chInterfaceAddedSignal
+ __attribute__((init_priority(101)));
+
+std::unique_ptr<sdbusplus::bus::match_t> chInterfaceRemovedSignal
+ __attribute__((init_priority(101)));
+
// String mappings use in JSON config file
static std::unordered_map<std::string, EChannelMediumType> mediumTypeMap = {
{"reserved", EChannelMediumType::reserved},
@@ -289,6 +297,8 @@
if (signalHndlrObjectState)
{
chPropertiesSignal.reset();
+ chInterfaceAddedSignal.reset();
+ chInterfaceRemovedSignal.reset();
sigHndlrLock.unlock();
}
}
@@ -347,6 +357,22 @@
processChAccessPropChange(path, props);
});
signalHndlrObjectState = true;
+
+ chInterfaceAddedSignal = std::make_unique<sdbusplus::bus::match_t>(
+ bus,
+ sdbusplus::bus::match::rules::type::signal() +
+ sdbusplus::bus::match::rules::member(interfaceAddedSignal) +
+ sdbusplus::bus::match::rules::argNpath(
+ 0, std::string(networkIntfObjectBasePath) + "/"),
+ [&](sdbusplus::message::message& msg) { loadChannelConfig(); });
+
+ chInterfaceRemovedSignal = std::make_unique<sdbusplus::bus::match_t>(
+ bus,
+ sdbusplus::bus::match::rules::type::signal() +
+ sdbusplus::bus::match::rules::member(interfaceRemovedSignal) +
+ sdbusplus::bus::match::rules::argNpath(
+ 0, std::string(networkIntfObjectBasePath) + "/"),
+ [&](sdbusplus::message::message& msg) { loadChannelConfig(); });
}
}